diff --git a/CMakeLists.txt b/CMakeLists.txt index 1080c55fc..d10721947 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,7 +79,7 @@ else() set(MULTI_LIB_HEADERS 0) function(compile_option VAR VALUE) target_compile_definitions(QuEST PRIVATE ${VAR}=${VALUE}) - set(${VAR} ${VALUE}) + set(${VAR} ${VALUE} PARENT_SCOPE) endfunction() endif() @@ -576,13 +576,18 @@ install(FILES DESTINATION "${QuEST_INSTALL_CONFIGDIR}" ) -install(FILES "${CMAKE_CURRENT_BINARY_DIR}/include/quest.h" +install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/quest/include/quest.h" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" ) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/include/quest/include/config.h" + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/quest/include" +) + install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/quest/include" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/quest" FILES_MATCHING PATTERN "*.h" + PATTERN "quest.h" EXCLUDE ) install(EXPORT QuESTTargets diff --git a/quest/include/CMakeLists.txt b/quest/include/CMakeLists.txt index 86a542dc5..bf0d1cd09 100644 --- a/quest/include/CMakeLists.txt +++ b/quest/include/CMakeLists.txt @@ -2,4 +2,4 @@ # @author Erich Essmann # @author Luc Jaulmes (using config file) -configure_file(quest.h.in "${CMAKE_BINARY_DIR}/include/quest.h" @ONLY) +configure_file(config.h.in "${CMAKE_BINARY_DIR}/include/quest/include/config.h" @ONLY) diff --git a/quest/include/config.h.in b/quest/include/config.h.in new file mode 100644 index 000000000..8326259b6 --- /dev/null +++ b/quest/include/config.h.in @@ -0,0 +1,22 @@ +#ifndef CONFIG_H +#define CONFIG_H + +// be warned, the below is sensitive to whitespace after the slash +#if !defined(FLOAT_PRECISION)\ + || !defined(COMPILE_MPI)\ + || !defined(COMPILE_OPENMP)\ + || !defined(COMPILE_CUDA)\ + || !defined(COMPILE_CUQUANTUM) + +// bind compile settings to installed exec +#if !@MULTI_LIB_HEADERS@ +#cmakedefine FLOAT_PRECISION @FLOAT_PRECISION@ +#cmakedefine01 COMPILE_MPI +#cmakedefine01 COMPILE_OPENMP +#cmakedefine01 COMPILE_CUDA +#cmakedefine01 COMPILE_CUQUANTUM +#endif + +#endif + +#endif \ No newline at end of file diff --git a/quest/include/modes.h b/quest/include/modes.h index b90797acd..667a3f053 100644 --- a/quest/include/modes.h +++ b/quest/include/modes.h @@ -15,27 +15,8 @@ -// ensure all mode flags are defined - -#ifndef COMPILE_MPI - #error "Compiler must define COMPILE_MPI" -#endif - -#ifndef COMPILE_OPENMP - #error "Compiler must define COMPILE_OPENMP" -#endif - -#ifndef COMPILE_CUDA - #error "Compiler must define COMPILE_CUDA" -#endif - -#ifndef COMPILE_CUQUANTUM - #error "Compiler must define COMPILE_CUQUANTUM" -#endif - - - // ensure all mode flags are valid values +// undefined allowed as undefined == 0 in C/C++ standards #if ! (COMPILE_MPI == 0 || COMPILE_MPI == 1) #error "Macro COMPILE_MPI must have value 0 or 1" diff --git a/quest/include/quest.h.in b/quest/include/quest.h similarity index 87% rename from quest/include/quest.h.in rename to quest/include/quest.h index 4ba420478..fcc49ab76 100644 --- a/quest/include/quest.h.in +++ b/quest/include/quest.h @@ -31,20 +31,12 @@ #define QUEST_H -// bind compile settings to installed exec -#if !@MULTI_LIB_HEADERS@ -#cmakedefine FLOAT_PRECISION @FLOAT_PRECISION@ -#cmakedefine01 COMPILE_MPI -#cmakedefine01 COMPILE_OPENMP -#cmakedefine01 COMPILE_CUDA -#cmakedefine01 COMPILE_CUQUANTUM -#endif - - // include version first so it is accessible to // debuggers in case a subsequent include fails #include "quest/include/version.h" +#include "quest/include/config.h" + // include before API headers since it validates // preprocessor configuration, and affirms macro // preconditions assumed by subsequent header