Last active
August 29, 2015 13:56
-
-
Save ahundt/8994671 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/cmake/ProjectTools.cmake b/src/cmake/ProjectTools.cmake | |
index 718174a..cc93775 100644 | |
--- a/src/cmake/ProjectTools.cmake | |
+++ b/src/cmake/ProjectTools.cmake | |
@@ -803,7 +803,15 @@ function (basis_configure_public_headers) | |
# considered include directories | |
basis_get_relative_path (INCLUDE_DIR "${PROJECT_SOURCE_DIR}" "${PROJECT_INCLUDE_DIR}") | |
set (INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/${INCLUDE_DIR}") | |
- | |
+ | |
+ get_cmake_property(_variableNames VARIABLES) | |
+ foreach (_variableName ${_variableNames}) | |
+ if(NOT ${_variablename} STREQUAL BASIS_PROPERTIES_ON_TESTS_RE) | |
+ set(ALL_VARIABLES_COMMAND_LINE "${ALL_VARIABLES_COMMAND_LINE} -D ${_variableName}=\"${${_variableName}}\"\n") | |
+ endif() | |
+ endforeach() | |
+ message(STATUS "COMMON_ARGS:${COMMON_ARGS} ALL_VARIABLES_COMMAND_LINE:${ALL_VARIABLES_COMMAND_LINE}") | |
+ | |
# -------------------------------------------------------------------------- | |
# clean up last run before the error because a file was added/removed | |
file (REMOVE "${CMAKE_FILE}.tmp") | |
@@ -822,7 +830,7 @@ function (basis_configure_public_headers) | |
-D "PROJECT_INCLUDE_DIRS=${INCLUDE_DIRS}" | |
-D "BINARY_INCLUDE_DIR=${BINARY_INCLUDE_DIR}" | |
-D "EXTENSIONS=${EXTENSIONS}" | |
- -D "CACHE_FILE=${PROJECT_BINARY_DIR}/BasisCache.txt" | |
+ ${ALL_VARIABLES_COMMAND_LINE} | |
-D "CMAKE_FILE=${CMAKE_FILE}" | |
-P "${BASIS_MODULE_PATH}/ConfigureIncludeFiles.cmake" | |
RESULT_VARIABLE RT | |
@@ -946,7 +954,7 @@ function (basis_configure_public_headers) | |
-D "PROJECT_INCLUDE_DIRS=${INCLUDE_DIRS}" | |
-D "BINARY_INCLUDE_DIR=${BINARY_INCLUDE_DIR}" | |
-D "EXTENSIONS=${EXTENSIONS}" | |
- -D "CACHE_FILE=${PROJECT_BINARY_DIR}/BasisCache.txt" | |
+ ${ALL_VARIABLES_COMMAND_LINE} | |
-P "${BASIS_MODULE_PATH}/ConfigureIncludeFiles.cmake" | |
COMMAND "${CMAKE_COMMAND}" -E touch "${CMAKE_FILE}.updated" | |
DEPENDS ${PUBLIC_HEADERS} | |
@@ -1782,7 +1790,7 @@ macro (basis_project_impl) | |
# dump currently defined CMake variables such that these can be used to | |
# configure the .in public header and module files during the build step | |
- basis_dump_variables ("${PROJECT_BINARY_DIR}/BasisCache.txt") | |
+ #basis_dump_variables ("${PROJECT_BINARY_DIR}/BasisCache.txt") | |
basis_include_directories (BEFORE "${BINARY_INCLUDE_DIR}" | |
"${PROJECT_INCLUDE_DIR}" | |
"${PROJECT_CODE_DIRS}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/cmake/ProjectTools.cmake b/src/cmake/ProjectTools.cmake | |
index 718174a..ebb1ec5 100644 | |
--- a/src/cmake/ProjectTools.cmake | |
+++ b/src/cmake/ProjectTools.cmake | |
@@ -1782,11 +1782,54 @@ macro (basis_project_impl) | |
# dump currently defined CMake variables such that these can be used to | |
# configure the .in public header and module files during the build step | |
- basis_dump_variables ("${PROJECT_BINARY_DIR}/BasisCache.txt") | |
+ #basis_dump_variables ("${PROJECT_BINARY_DIR}/BasisCache.txt") | |
basis_include_directories (BEFORE "${BINARY_INCLUDE_DIR}" | |
"${PROJECT_INCLUDE_DIR}" | |
"${PROJECT_CODE_DIRS}") | |
- basis_configure_public_headers () | |
+ | |
+ | |
+ # ---------------------------------------------------------------------------- | |
+ # configure header files | |
+ set ( | |
+ EXTENSIONS | |
+ ".h" | |
+ ".hh" | |
+ ".hpp" | |
+ ".hxx" | |
+ ".inl" | |
+ ".txx" | |
+ ".inc" | |
+ ) | |
+ | |
+ # configure all .in files with substitution | |
+ set (CONFIGURED_HEADERS) | |
+ foreach (INCLUDE_DIR IN LISTS PROJECT_INCLUDE_DIRS) | |
+ set (PATTERN) | |
+ foreach (E IN LISTS EXTENSIONS) | |
+ list (APPEND PATTERN "${INCLUDE_DIR}/*${E}.in") | |
+ endforeach () | |
+ file (GLOB_RECURSE FILES RELATIVE "${INCLUDE_DIR}" PROJECT_HEADER_EXTENSIONS) | |
+ foreach (HEADER IN LISTS FILES) | |
+ get_filename_component (SOURCE "${INCLUDE_DIR}/${HEADER}" ABSOLUTE) | |
+ configure_file ("${SOURCE}" "${BINARY_INCLUDE_DIR}/${HEADER}" @ONLY) | |
+ list (APPEND CONFIGURED_HEADERS "${SOURCE}") | |
+ endforeach () | |
+ | |
+ # configure all other files without substitution | |
+ set (PATTERN) | |
+ foreach (E IN LISTS EXTENSIONS) | |
+ list (APPEND PATTERN "${INCLUDE_DIR}/*${E}") | |
+ endforeach () | |
+ | |
+ file (GLOB_RECURSE FILES RELATIVE "${INCLUDE_DIR}" PROJECT_HEADER_EXTENSIONS) | |
+ foreach (HEADER IN LISTS FILES) | |
+ get_filename_component (SOURCE "${INCLUDE_DIR}/${HEADER}" ABSOLUTE) | |
+ configure_file ("${SOURCE}" "${BINARY_INCLUDE_DIR}/${HEADER}" COPYONLY) | |
+ list (APPEND CONFIGURED_HEADERS "${SOURCE}") | |
+ endforeach () | |
+ endforeach () | |
+ | |
+ #basis_configure_public_headers () | |
basis_configure_script_libraries () | |
# -------------------------------------------------------------------------- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think the second solution is the one we should prefer then. It's ok to leave the feature of configuring the header files during build time. It is anyway better practice to really just have a single
config.h.in
which then defines macros/constants with the configured values that can be used in all other source code.Remove lines 44-55 from your second snippet. That was only needed to copy all header files, not just those with
.in
suffix. You really don't want to do that again. It will cause quite some troubles and frustration with the BASIS users.This was more of a problem while BASIS was yet copying just all header files. But you can still have the check run during build time. No need to configure the files during build time. Only for that step you need to know what the values of all the CMake variables was during configuration. You just need to add a custom command similar to
CheckPublicHeaders.cmake
and provide it with a list of header files that were configured/copied to the build tree. It's only purpose will be to check whether the corresponding input.h.in
file still exists in the source tree. If not, it will remove the copy from the build tree. As you expect only a few number of.h.in
files, you can pass the relative paths of these files easily via-D
option tocmake
.