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 | # Configures the binary output directory with files required for Orxonox |
---|
24 | # to run like orxonox.ini or the default keybindings. |
---|
25 | # Also creates a run-script in the root directory of the build tree. |
---|
26 | # |
---|
27 | |
---|
28 | SET(READ_ONLY_CONFIG_FILES |
---|
29 | def_keybindings.ini |
---|
30 | def_masterKeybindings.ini |
---|
31 | disco.txt |
---|
32 | irc.tcl |
---|
33 | remote.tcl |
---|
34 | telnet_server.tcl |
---|
35 | ) |
---|
36 | |
---|
37 | SET(WRITABLE_CONFIG_FILES |
---|
38 | orxonox.ini |
---|
39 | ) |
---|
40 | |
---|
41 | IF(TARDIS) |
---|
42 | # OGRE can't find fonts to display config screen on Tardis, |
---|
43 | # so providing default config file here (bug). |
---|
44 | LIST(APPEND WRITABLE_CONFIG_FILES ogre.cfg) |
---|
45 | ENDIF(TARDIS) |
---|
46 | |
---|
47 | # We need the same code for both READ_ONLY and WRITABLE config files |
---|
48 | MACRO(CONFIGURE_FILES _file_name _build_configs _read_only_arg) |
---|
49 | SET(_read_only ${_read_only_arg}) |
---|
50 | FOREACH(_build_config ${_build_configs}) |
---|
51 | # Is there an extra file in bin/Debug or bin/Release? |
---|
52 | IF(${_build_config} MATCHES "Rel") |
---|
53 | SET(_build_config_short "Release") |
---|
54 | ELSE() |
---|
55 | SET(_build_config_short "Debug") |
---|
56 | ENDIF() |
---|
57 | IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${_build_config_short}/${_file_name}) |
---|
58 | SET(_in_file ${CMAKE_CURRENT_SOURCE_DIR}/${_build_config_short}/${_file_name}) |
---|
59 | ELSE() |
---|
60 | SET(_in_file ${CMAKE_CURRENT_SOURCE_DIR}/${_file_name}) |
---|
61 | ENDIF() |
---|
62 | |
---|
63 | # Copy to the folder named like the build config for Visual Studio |
---|
64 | IF(CMAKE_CONFIGURATION_TYPES) |
---|
65 | SET(_out_file ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${_build_config}/${_file_name}) |
---|
66 | ELSE() |
---|
67 | SET(_out_file ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${_file_name}) |
---|
68 | ENDIF() |
---|
69 | # Only copy if target file doesn't exist. This may result in problems but |
---|
70 | # otherwise we might delete a user's config |
---|
71 | IF(NOT EXISTS ${_out_file} OR _read_only) |
---|
72 | CONFIGURE_FILE(${_in_file} ${_out_file} @ONLY) |
---|
73 | ENDIF() |
---|
74 | ENDFOREACH(_build_config) |
---|
75 | ENDMACRO(CONFIGURE_FILES) |
---|
76 | |
---|
77 | # Copy config files to all Visual Studio output directories |
---|
78 | IF(CMAKE_CONFIGURATION_TYPES) |
---|
79 | SET(BUILD_CONFIGS ${CMAKE_CONFIGURATION_TYPES}) |
---|
80 | ELSE() |
---|
81 | SET(CONFIG_OUT_PATHS_REL ".") |
---|
82 | SET(BUILD_CONFIGS ${CMAKE_BUILD_TYPE}) |
---|
83 | ENDIF() |
---|
84 | |
---|
85 | FOREACH(_file_name ${READ_ONLY_CONFIG_FILES}) |
---|
86 | CONFIGURE_FILES("${_file_name}" "${BUILD_CONFIGS}" TRUE) |
---|
87 | ENDFOREACH(_file_name) |
---|
88 | FOREACH(_file_name ${WRITABLE_CONFIG_FILES}) |
---|
89 | CONFIGURE_FILES("${_file_name}" "${BUILD_CONFIGS}" FALSE) |
---|
90 | ENDFOREACH(_file_name) |
---|
91 | |
---|
92 | ################ Run Scripts ################## |
---|
93 | |
---|
94 | # Create a run script for both Windows and Linux in the source root path if |
---|
95 | # CMake is not used to create multi-configuration project files |
---|
96 | IF(NOT CMAKE_CONFIGURATION_TYPES) |
---|
97 | IF(WIN32) |
---|
98 | SET(RUN_SCRIPT run.bat) |
---|
99 | # Note: Do not use FILE(TO_NATIVE_PATH) because it doesn't work for MinGW |
---|
100 | STRING(REGEX REPLACE "^([A-Z]\\:)\\/.*$" "\\1" WINDOWS_DRIVE_CHANGE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) |
---|
101 | STRING(REPLACE "/" "\\" CMAKE_RUNTIME_OUTPUT_DIRECTORY_WINDOWS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) |
---|
102 | STRING(REPLACE "/" "\\" ORXONOX_RUNTIME_LIBRARY_DIRECTORY_WINDOWS ${ORXONOX_RUNTIME_LIBRARY_DIRECTORY}) |
---|
103 | ELSE(UNIX) |
---|
104 | SET(RUN_SCRIPT run) |
---|
105 | ENDIF(WIN32) |
---|
106 | CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${RUN_SCRIPT} ${CMAKE_SOURCE_DIR}/${RUN_SCRIPT} @ONLY) |
---|
107 | CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${RUN_SCRIPT} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${RUN_SCRIPT} @ONLY) |
---|
108 | ENDIF(NOT CMAKE_CONFIGURATION_TYPES) |
---|