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 CheckPublicHeaders.cmake 12 # @brief CMake script used to check whether public headers were added/removed. 14 # This script removes the deprecated public headers from the build tree and 15 # then throws a fatal error if public header files were added or removed to 18 # @ingroup CMakeUtilities 19 ############################################################################## 21 # ---------------------------------------------------------------------------- 24 message (FATAL_ERROR
"Missing argument CMAKE_FILE!")
27 if (NOT REFERENCE_FILE)
28 message (FATAL_ERROR "Missing argument REFERENCE_FILE!")
43 # ---------------------------------------------------------------------------- 46 COMMAND ${CMAKE_COMMAND} -E compare_files
"${CMAKE_FILE}" "${REFERENCE_FILE}" 47 RESULT_VARIABLE EXIT_CODE
52 if (EXIT_CODE EQUAL 0)
58 # ---------------------------------------------------------------------------- 59 # remove obsolete public headers 62 include (
"${CMAKE_FILE}")
64 unset (${VARIABLE_NAME}) 65 include ("${REFERENCE_FILE}
") 66 foreach (H IN LISTS _HEADERS) 67 list (FIND ${VARIABLE_NAME} "${H}
" IDX) 69 # TODO: this hard coded /include path may break for custom include directories 70 string (REGEX REPLACE "^.*/include/
" "" H "${H}
") 71 string (REGEX REPLACE "\\.in$
" "" H "${H}
") 77 # ---------------------------------------------------------------------------- 78 # remove files if different 79 if (CMAKE_FILE_DIFFERS) 80 file (REMOVE "${CMAKE_FILE}
") 81 file (REMOVE "${REFERENCE_FILE}
") 82 file (REMOVE "${REFERENCE_FILE}.update
") 85 # ---------------------------------------------------------------------------- 86 # fatal error if files added/removed 87 if (CMAKE_FILE_DIFFERS AND ERRORMSG) 88 message (FATAL_ERROR "${ERRORMSG}
")
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.