Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/archive/tutorialHS09/cmake/SourceFileUtilities.cmake @ 10256

Last change on this file since 10256 was 2710, checked in by rgrieder, 16 years ago

Merged buildsystem3 containing buildsystem2 containing Adi's buildsystem branch back to the trunk.
Please update the media directory if you were not using buildsystem3 before.

  • Property svn:eol-style set to native
File size: 2.9 KB
Line 
1 #
2 #             ORXONOX - the hottest 3D action shooter ever to exist
3 #                             > www.orxonox.net <
4 #
5 #        This program is free software; you can redistribute it and/or
6 #         modify it under the terms of the GNU General Public License
7 #        as published by the Free Software Foundation; either version 2
8 #            of the License, or (at your option) any later version.
9 #
10 #       This program is distributed in the hope that it will be useful,
11 #        but WITHOUT ANY WARRANTY; without even the implied warranty of
12 #        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 #                 GNU General Public License for more details.
14 #
15 #   You should have received a copy of the GNU General Public License along
16 #      with this program; if not, write to the Free Software Foundation,
17 #     Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18 #
19 #
20 #  Author:
21 #    Reto Grieder
22 #  Description:
23 #    Several functions that help organising the source tree.
24 #    [ADD/SET]_SOURCE_FILES - Writes source files to the cache by force and
25 #                             adds the current directory.
26 #    GET_ALL_HEADER_FILES - Finds all header files recursively.
27 #    GENERATE_SOURCE_GROUPS - Set Visual Studio source groups.
28 #
29
30# Adds source files with the full path to a list
31FUNCTION(ADD_SOURCE_FILES _varname)
32  # Prefix the full path
33  SET(_fullpath_sources)
34  FOREACH(_file ${ARGN})
35    GET_SOURCE_FILE_PROPERTY(_filepath ${_file} LOCATION)
36    LIST(APPEND _fullpath_sources ${_filepath})
37  ENDFOREACH(_file)
38  # Write into the cache to avoid variable scoping in subdirs
39  SET(${_varname} ${${_varname}} ${_fullpath_sources} CACHE INTERNAL "Do not edit")
40ENDFUNCTION(ADD_SOURCE_FILES)
41
42
43# Sets source files with the full path
44FUNCTION(SET_SOURCE_FILES _varname)
45  # Prefix the full path
46  SET(_fullpath_sources)
47  FOREACH(_file ${ARGN})
48    GET_SOURCE_FILE_PROPERTY(_filepath ${_file} LOCATION)
49    LIST(APPEND _fullpath_sources ${_filepath})
50  ENDFOREACH(_file)
51  # Write into the cache to avoid variable scoping in subdirs
52  SET(${_varname} ${_fullpath_sources} CACHE INTERNAL "Do not edit")
53ENDFUNCTION(SET_SOURCE_FILES)
54
55
56# Search the entire directory tree for header files and add them to a variable
57MACRO(GET_ALL_HEADER_FILES _target_varname)
58  FILE(GLOB_RECURSE ${_target_varname} ${CMAKE_CURRENT_SOURCE_DIR} "*.h")
59ENDMACRO(GET_ALL_HEADER_FILES)
60
61
62# Generate source groups according to the directory structure
63FUNCTION(GENERATE_SOURCE_GROUPS)
64
65  FOREACH(_file ${ARGN})
66    GET_SOURCE_FILE_PROPERTY(_full_filepath ${_file} LOCATION)
67    FILE(RELATIVE_PATH _relative_path ${CMAKE_CURRENT_SOURCE_DIR} ${_full_filepath})
68    GET_FILENAME_COMPONENT(_relative_path ${_relative_path} PATH)
69    STRING(REPLACE "/" "\\\\" _group_path "${_relative_path}")
70    SOURCE_GROUP("Source\\${_group_path}" FILES ${_file})
71  ENDFOREACH(_file)
72
73ENDFUNCTION(GENERATE_SOURCE_GROUPS)
Note: See TracBrowser for help on using the repository browser.