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 ############################################################################## 12 # @brief Glob source files and optionally compare to previous glob result. 13 ############################################################################## 15 include (
"${CMAKE_CURRENT_LIST_DIR}/CommonTools.cmake")
18 message (FATAL_ERROR "Missing EXPRESSIONS argument!")
21 message (FATAL_ERROR "Missing SOURCES_FILE argument!")
25 foreach (EXPRESSION IN LISTS EXPRESSIONS)
26 if (EXPRESSION MATCHES "[*][*]")
27 string (REPLACE "**" "*" EXPRESSION "${EXPRESSION}
") 28 file (GLOB_RECURSE _SOURCES "${EXPRESSION}
") 29 list (APPEND SOURCES ${_SOURCES}) 30 elseif (EXPRESSION MATCHES "[*?]|\\[[0-9]+-[0-9]+\\]
") 31 file (GLOB _SOURCES "${EXPRESSION}
") 32 list (APPEND SOURCES ${_SOURCES}) 34 list (APPEND SOURCES "${EXPRESSION}
") 38 list (REMOVE_DUPLICATES SOURCES) 42 foreach (SOURCE IN LISTS SOURCES) 43 if (SOURCE MATCHES "^\\$<
") # preserve generator expressions 44 list (APPEND _SOURCES "${SOURCE}
") 46 get_filename_component (SOURCE_NAME "${SOURCE}
" NAME) 47 if (NOT SOURCE MATCHES "(^|/).(svn|git)/
" AND NOT SOURCE_NAME MATCHES "^\\.
") 48 list (APPEND _SOURCES "${SOURCE}
") 52 set (SOURCES ${_SOURCES}) 56 basis_write_list ("${SOURCES_FILE}
" INITIAL_SOURCES ${SOURCES}) 58 include ("${SOURCES_FILE}
") 59 if (NOT "${
SOURCES}
" STREQUAL "${INITIAL_SOURCES}
") 60 # touching this file which is included by basis_add_glob_target() 61 # re-triggers CMake upon the next build 62 execute_process (COMMAND "${CMAKE_COMMAND}
" -E touch "${SOURCES_FILE}
") 63 message (FATAL_ERROR "${ERRORMSG}
")