Changeset 2518 for code/branches/buildsystem2/cmake/AddSourceFiles.cmake
- Timestamp:
- Dec 21, 2008, 10:36:51 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/buildsystem2/cmake/AddSourceFiles.cmake
r2131 r2518 16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 17 17 18 MACRO(ADD_SOURCE_DIRECTORY _target_list _directory) 18 # BIG FAT NOTE: 19 # There's possibly a bug in the CMake behaviour when using PARENT_SCOPE. 20 # It seems like the parent variable doesn't get updated locally but written 21 # correclty to the parent scope. So accessing a parent variable will always 22 # return its value BEFORE the local scope was created! Mind this when 23 # updating to a new CMake version. 19 24 20 # Subfolder puts source files into CMake Cache variable _CACHED_SOURCE_FILES 25 # Adds source files to the internal handler 26 MACRO(ADD_SOURCE_FILES) 27 28 # Write to parent scoped variables AND to our own scope 29 # (Also see the big fat note at the beginning of the file) 30 # --> _source_files_internal_parent stays constant here, not matter what! 31 SET(_source_files_internal_local ${_source_files_internal_local} ${ARGN}) 32 SET(_source_files_internal_parent ${_source_files_internal_local} PARENT_SCOPE) 33 34 ENDMACRO(ADD_SOURCE_FILES) 35 36 37 # Adds a subdirectory to the internal souce file handler 38 MACRO(ADD_SOURCE_DIRECTORY _directory) 39 40 # Save variable 41 SET(_source_files_internal_temp ${_source_files_internal_local}) 42 # Clear the local variable because we use it in the child scope 43 SET(_source_files_internal_local) 44 45 # Subfolder puts source files into CMake variable _source_files_internal_parent 21 46 ADD_SUBDIRECTORY(${_directory}) 47 # Recover our own local variable 48 SET(_source_files_internal_local ${_source_files_internal_temp}) 22 49 23 50 # Put the directory name in front of each source file from the subfolder 24 # and add it to the source list in the current directory25 FOREACH(_source_file ${_ CACHED_SOURCE_FILES})26 LIST(APPEND ${_target_list}"${_directory}/${_source_file}")51 SET(_source_files_internal_temp) 52 FOREACH(_source_file ${_source_files_internal_parent}) 53 LIST(APPEND _source_files_internal_temp "${_directory}/${_source_file}") 27 54 ENDFOREACH(_source_file) 55 56 # Add the content of the temporary list 57 ADD_SOURCE_FILES(${_source_files_internal_temp}) 28 58 29 59 ENDMACRO(ADD_SOURCE_DIRECTORY) 30 60 61 # Writes the content from the internal variables to a user specified one 62 MACRO(WRITE_SOURCE_FILES _variable_name) 31 63 32 MACRO(ADD_SOURCE_FILES _source_list) 33 34 # Put the source file into a variable that still exists in this_folder/../ 35 # Use FORCE to always overwrite the cache variable 36 SET(_CACHED_SOURCE_FILES ${${_source_list}} CACHE STRING "" FORCE) 37 MARK_AS_ADVANCED(_CACHED_SOURCE_FILES FORCE) 64 SET(${_variable_name} ${_source_files_internal_local}) 38 65 39 ENDMACRO( ADD_SOURCE_FILES)66 ENDMACRO(WRITE_SOURCE_FILES)
Note: See TracChangeset
for help on using the changeset viewer.