1 # ============================================================================ 2 # Copyright (c) 2011-2012 University of Pennsylvania 3 # Copyright (c) 2013-2016 Andreas Schuh 6 # See COPYING file for license information or visit 7 # https://cmake-basis.github.io/download.html#license 8 # ============================================================================ 10 ############################################################################## 11 # @file ConfigureIncludeFiles.cmake 12 # @brief CMake script used to configure and copy the public header files. 14 # Besides configuring the files, this script optionally copies the header 15 # files to the build tree using the final relative path as used for the 16 # installation. This could be done directly during the configure step of 17 # CMake by code executed as part of the CMakeLists.txt files, but then 18 # whenever a header file is modified, CMake reconfigures the build system. 19 # Instead, this script is executed using execute_process() during the 20 # configure step of CMake and a custom build target is added which rebuilds 21 # whenever a header file was modified. Thus, only this script is re-executed, 22 # but not the entire build system re-configured. 24 # The relative path of each configured input header file in the source tree 25 # is appended to the output log file. This file can be used to determine 26 # whether a new header was added to the source tree and thus this script has 29 # @ingroup CMakeUtilities 30 ############################################################################## 32 # ---------------------------------------------------------------------------- 33 # requires bug fixed get_filename_component() of BASIS tools 34 include (
"${CMAKE_CURRENT_LIST_DIR}/CommonTools.cmake")
36 # ---------------------------------------------------------------------------- 39 message (FATAL_ERROR
"Missing argument PROJECT_INCLUDE_DIRS!")
47 message (FATAL_ERROR "Missing argument EXTENSIONS!")
58 # ---------------------------------------------------------------------------- 59 # include file which defines CMake variables for use in .h.in files 61 include (
"${CACHE_FILE}")
64 # ---------------------------------------------------------------------------- 65 # configure header files 66 foreach (INCLUDE_DIR IN LISTS PROJECT_INCLUDE_DIRS)
67 foreach (E IN LISTS EXTENSIONS)
68 list (APPEND PATTERN
"${INCLUDE_DIR}/*${E}")
70 file (GLOB_RECURSE FILES RELATIVE "${INCLUDE_DIR}
" ${PATTERN}) 71 foreach (HEADER IN LISTS FILES) 72 get_filename_component (SOURCE "${INCLUDE_DIR}/${HEADER}
" ABSOLUTE) 73 if (NOT PREVIEW AND HEADER MATCHES "\\.in$
") 74 string (REGEX REPLACE "\\.in$
" "" HEADER "${HEADER}
") 77 list (APPEND CONFIGURED_HEADERS "${SOURCE}
") 81 # ---------------------------------------------------------------------------- 82 # write CMake script with list of public header files 84 if (_CONFIGURED_HEADERS) 85 list (SORT _CONFIGURED_HEADERS) # deterministic order 87 file (WRITE "${CMAKE_FILE}
" "# Automatically generated by BASIS. DO NOT edit
this file!\nset (${
VARIABLE_NAME}\n
") 88 foreach (HEADER IN LISTS CONFIGURED_HEADERS) 89 file (APPEND "${CMAKE_FILE}
" " \
"${HEADER}\"\n")
91 file (APPEND
"${CMAKE_FILE}" ")\n")
cmake PROJECT_INCLUDE_DIRS
Absolute paths to directories of public header files in source tree.
cmake BINARY_INCLUDE_DIR
Absolute path to output directory for configured public header files.