Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/objecthierarchy2/cmake/AddSourceFiles.cmake @ 2398

Last change on this file since 2398 was 2131, checked in by rgrieder, 16 years ago

Added CMakeLists.txt to every subfolder and adjusted accordingly.
The CMake script I have written can be used as follows:
ADD_SOURCE_DIRECTORY(_source_list directory) # Adds a new source subdirectory where _source_list is the name of the source list in CURRENT folder
ADD_SOURCE_FILES(_source_list) # Adds the source files in a subdirectory to the source list in the super directory (has to be called!)

Note: When adding more subdirectories in a subdirectory, call ADD_SOURCE_FILES after ADD_SOURCE_DIRECTORY!

File size: 1.6 KB
Line 
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
18MACRO(ADD_SOURCE_DIRECTORY _target_list _directory)
19
20  # Subfolder puts source files into CMake Cache variable _CACHED_SOURCE_FILES
21  ADD_SUBDIRECTORY(${_directory})
22
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}")
27  ENDFOREACH(_source_file)
28
29ENDMACRO(ADD_SOURCE_DIRECTORY)
30
31
32MACRO(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
39ENDMACRO(ADD_SOURCE_FILES)
Note: See TracBrowser for help on using the repository browser.