[2131] | 1 | # AddSourceFiles.cmake - CMake Module to include source files in subdirectories. |
---|
| 2 | # Author: Reto '1337' Grieder (2008) |
---|
| 3 | # |
---|
| 4 | # This program is free software; you can redistribute it and/or modify |
---|
| 5 | # it under the terms of the GNU General Public License as published by |
---|
| 6 | # the Free Software Foundation; either version 2 of the License, or |
---|
| 7 | # (at your option) any later version. |
---|
| 8 | # |
---|
| 9 | # This program is distributed in the hope that it will be useful, |
---|
| 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 12 | # GNU General Public License for more details. |
---|
| 13 | # |
---|
| 14 | # You should have received a copy of the GNU General Public License |
---|
| 15 | # along with this program; if not, write to the Free Software |
---|
| 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA |
---|
| 17 | |
---|
[2130] | 18 | MACRO(ADD_SOURCE_DIRECTORY _target_list _directory) |
---|
[2125] | 19 | |
---|
[2130] | 20 | # Subfolder puts source files into CMake Cache variable _CACHED_SOURCE_FILES |
---|
| 21 | ADD_SUBDIRECTORY(${_directory}) |
---|
[2125] | 22 | |
---|
[2130] | 23 | # Put the directory name in front of each source file from the subfolder |
---|
| 24 | # and add it to the source list in the current directory |
---|
| 25 | FOREACH(_source_file ${_CACHED_SOURCE_FILES}) |
---|
| 26 | LIST(APPEND ${_target_list} "${_directory}/${_source_file}") |
---|
[2125] | 27 | ENDFOREACH(_source_file) |
---|
[2130] | 28 | |
---|
| 29 | ENDMACRO(ADD_SOURCE_DIRECTORY) |
---|
| 30 | |
---|
| 31 | |
---|
| 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) |
---|
| 38 | |
---|
[2125] | 39 | ENDMACRO(ADD_SOURCE_FILES) |
---|