diff --git a/CMakeLists.txt b/CMakeLists.txt index aeb6c570ae88cfb6aa1b07cc8629e201b2a96a25..ff9acfba05ca3a6238768839c2997f6f77a6f535 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/misc/preprocess.sh b/misc/preprocess.sh index 1a6c4ce9b84143c144c0bc3dc0f59b65d4fb1566..1fa92ad3e52b0e44d36e7e1cfc5d3a444d309ac2 100755 --- a/misc/preprocess.sh +++ b/misc/preprocess.sh @@ -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 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bc2a42d257bfe720eabf1ecfff9a7d4ea7ec1369..ef58417687f82280fe9b74e4d6e9604950866497 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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)