Skip to content
Snippets Groups Projects
Commit 6117386c authored by Stephan Schulz's avatar Stephan Schulz
Browse files

use compile_definitions and create preprocessed header file

parent 035b37c2
No related branches found
No related tags found
1 merge request!15CMake projectconfig
......@@ -76,20 +76,20 @@ if(CM_ALL_VTK_OUTPUT)
message(FATAL_ERROR "VTK not found, help CMake to find it by setting VTK_LIBRARY and VTK_INCLUDE_DIR")
endif()
# todo(s.schulz): this can be replaced from 3.12 onwards with add_compile_definitions
add_compile_options("-DALL_VTK_OUTPUT")
add_compile_definitions("ALL_VTK_OUTPUT")
endif(CM_ALL_VTK_OUTPUT)
if (CM_ALL_DEBUG)
message("Using ALL debug information")
add_compile_options("-DALL_DEBUG_ENABLED")
add_compile_definitions("ALL_DEBUG_ENABLED")
endif(CM_ALL_DEBUG)
if(CM_ALL_FORTRAN_ERROR_ABORT)
add_compile_options("-DALL_FORTRAN_ERROR_ABORT")
add_compile_definitions("ALL_FORTRAN_ERROR_ABORT")
endif()
if(CM_ALL_USE_F08 AND MPI_Fortran_HAVE_F08_MODULE)
add_compile_options("-DALL_USE_F08")
add_compile_definitions("DALL_USE_F08")
elseif(CM_ALL_USE_F08 AND NOT MPI_Fortran_HAVE_F08_MODULE)
message(FATAL_ERROR "Fortran 2008 MPI chosen, but MPI installation does not support the Fortran 2008 modules")
endif(CM_ALL_USE_F08 AND MPI_Fortran_HAVE_F08_MODULE)
......@@ -97,7 +97,7 @@ endif(CM_ALL_USE_F08 AND MPI_Fortran_HAVE_F08_MODULE)
if(CM_ALL_VORONOI)
message(STATUS "compiling voro++ version in contrib/voro++")
add_subdirectory(contrib/voro++)
add_compile_options("-DALL_VORONOI_ACTIVE")
add_compile_definitions("ALL_VORONOI_ACTIVE")
endif()
set(STB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/contrib/stb)
......
......@@ -2,14 +2,15 @@
# Usage:
# $1: path to include directory
# $2..: additional flags to gcc
# $2: output file
# $3..: additional defines (without -D)
# Either run this script in the include directory, or pass the include
# directory as an additional argument ($1).
set -euo pipefail
#set -x
set -x
HEADERS="ALL_CustomExceptions.hpp
ALL_Defines.h
......@@ -25,9 +26,16 @@ ALL_Voronoi.hpp"
PROCESSED_DIR=`mktemp -d`
CWD="$1"
CWD=`pwd`
cd "$1"
if [[ ${2:0:1} == / ]]
then
OUTFILE="$2"
else
OUTFILE="$CWD/$2"
fi
shift
shift
for f in $HEADERS
do
......@@ -36,8 +44,15 @@ done
cd "$PROCESSED_DIR"
gcc -E -fdirectives-only "$@" -o ALL.ii ALL.hpp
DEFINES=
for d in "$@"
do
DEFINES="$DEFINES -D$d"
done
gcc -E -fdirectives-only $DEFINES -o ALL.ii ALL.hpp
cat ALL.ii | sed -e 's!// PPIGNORE <!#include <!' > "$CWD/ALL_pp.hpp"
mkdir -p "${OUTFILE%/*}"
cat ALL.ii | sed -e 's!// PPIGNORE <!#include <!' > "$OUTFILE"
rm -rf $PROCESSED_DIR
......@@ -33,8 +33,6 @@ target_include_directories (ALL
# library is necessary.
target_link_libraries(ALL INTERFACE stdc++)
install(TARGETS ALL
EXPORT ALLTargets
RUNTIME DESTINATION bin
......@@ -42,8 +40,16 @@ install(TARGETS ALL
ARCHIVE DESTINATION lib
INCLUDES DESTINATION include)
install(FILES ${ALL_HEADER_FILES}
DESTINATION include)
get_property(_glob_comp_def DIRECTORY PROPERTY COMPILE_DEFINITIONS)
add_custom_command(
TARGET ALL
PRE_BUILD
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/../misc/preprocess.sh ${ALL_INCLUDE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/../include/ALL.hpp ${_glob_comp_def}
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/../include/ALL.hpp DESTINATION include)
#install(FILES ${ALL_HEADER_FILES}
# DESTINATION include)
if (CM_ALL_FORTRAN)
set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../modules)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment