[2710] | 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 | # |
---|
[5695] | 19 | # |
---|
| 20 | # Author: |
---|
| 21 | # Reto Grieder |
---|
| 22 | # Description: |
---|
| 23 | # Configures the compilers and sets build options. |
---|
| 24 | # |
---|
[1505] | 25 | |
---|
[5695] | 26 | # Required macros and functions |
---|
[2710] | 27 | INCLUDE(FlagUtilities) |
---|
[3196] | 28 | INCLUDE(TargetUtilities) |
---|
[2710] | 29 | |
---|
[5695] | 30 | # Configure the two headers and set some options |
---|
| 31 | INCLUDE(OrxonoxConfig.cmake) |
---|
[2710] | 32 | |
---|
[7163] | 33 | ####### Library Behaviour (dependencies) ######## |
---|
[2710] | 34 | |
---|
[7956] | 35 | # Disable auto linking completely for Boost and POCO |
---|
[5695] | 36 | ADD_COMPILER_FLAGS("-DBOOST_ALL_NO_LIB") |
---|
[7956] | 37 | ADD_COMPILER_FLAGS("-DPOCO_NO_AUTOMATIC_LIBS") |
---|
[2710] | 38 | |
---|
[5695] | 39 | # If no defines are specified, these libs get linked statically |
---|
| 40 | ADD_COMPILER_FLAGS("-DBOOST_ALL_DYN_LINK" WIN32 LINK_BOOST_DYNAMIC) |
---|
[7459] | 41 | #ADD_COMPILER_FLAGS("-DENET_DLL" WIN32 LINK_ENET_DYNAMIC) |
---|
[7944] | 42 | ADD_COMPILER_FLAGS("-DLUA_BUILD_AS_DLL" WIN32 LINK_LUA5.1_DYNAMIC) |
---|
[5695] | 43 | # If no defines are specified, these libs get linked dynamically |
---|
[7941] | 44 | ADD_COMPILER_FLAGS("-DCEGUI_STATIC -DTOLUA_STATIC" WIN32 NOT LINK_CEGUI_DYNAMIC) |
---|
[5695] | 45 | ADD_COMPILER_FLAGS("-DOGRE_STATIC_LIB" WIN32 NOT LINK_OGRE_DYNAMIC) |
---|
[5781] | 46 | ADD_COMPILER_FLAGS("-DSTATIC_BUILD" WIN32 NOT LINK_TCL_DYNAMIC) |
---|
[2710] | 47 | |
---|
[7163] | 48 | ######### Library Behaviour (external) ########## |
---|
| 49 | |
---|
[5781] | 50 | # Use TinyXML++ |
---|
| 51 | ADD_COMPILER_FLAGS("-DTIXML_USE_TICPP") |
---|
| 52 | |
---|
[7163] | 53 | # Default linking for externals is SHARED |
---|
| 54 | SET(ORXONOX_EXTERNAL_LINK_MODE SHARED CACHE STRING "Link mode for external libraries that we build ourselves. Note: on Windows, some libraries cannot be linked shared.") |
---|
| 55 | |
---|
| 56 | IF(ORXONOX_EXTERNAL_LINK_MODE STREQUAL "SHARED") |
---|
| 57 | SET(_external_shared_link TRUE) |
---|
| 58 | ELSE() |
---|
| 59 | SET(_external_shared_link FALSE) |
---|
| 60 | ENDIF() |
---|
| 61 | # If no defines are specified, these libs get linked dynamically |
---|
[7459] | 62 | ADD_COMPILER_FLAGS("-DENET_DLL" WIN32 _external_shared_link) |
---|
[7163] | 63 | ADD_COMPILER_FLAGS("-DOGRE_GUIRENDERER_STATIC_LIB" WIN32 NOT _external_shared_link) |
---|
| 64 | ADD_COMPILER_FLAGS("-DOIS_STATIC_LIB" WIN32 NOT _external_shared_link) |
---|
| 65 | |
---|
[2710] | 66 | ############## Include Directories ############## |
---|
| 67 | |
---|
| 68 | # Set the search paths for include files |
---|
| 69 | INCLUDE_DIRECTORIES( |
---|
[8071] | 70 | # OrxonoxConfig.h |
---|
| 71 | ${CMAKE_CURRENT_BINARY_DIR} |
---|
| 72 | |
---|
| 73 | # All includes in "externals" should be prefixed with the path |
---|
| 74 | # relative to "external" to avoid conflicts |
---|
| 75 | ${CMAKE_CURRENT_SOURCE_DIR}/external |
---|
| 76 | # Include directories needed even if only included by Orxonox |
---|
| 77 | ${CMAKE_CURRENT_SOURCE_DIR}/external/bullet |
---|
| 78 | ${CMAKE_CURRENT_SOURCE_DIR}/external/ois |
---|
| 79 | |
---|
[2710] | 80 | # External |
---|
| 81 | ${OGRE_INCLUDE_DIR} |
---|
[5781] | 82 | ${CEGUI_INCLUDE_DIR} |
---|
[8061] | 83 | ${CEGUI_TOLUA_INCLUDE_DIR} |
---|
[7459] | 84 | #${ENET_INCLUDE_DIR} |
---|
[2710] | 85 | ${Boost_INCLUDE_DIRS} |
---|
[7224] | 86 | ${POCO_INCLUDE_DIR} |
---|
[5781] | 87 | ${OPENAL_INCLUDE_DIRS} |
---|
| 88 | ${ALUT_INCLUDE_DIR} |
---|
| 89 | ${VORBIS_INCLUDE_DIR} |
---|
| 90 | ${OGG_INCLUDE_DIR} |
---|
[7944] | 91 | ${LUA5.1_INCLUDE_DIR} |
---|
[5781] | 92 | ${TCL_INCLUDE_PATH} |
---|
| 93 | ${DIRECTX_INCLUDE_DIR} |
---|
| 94 | ${ZLIB_INCLUDE_DIR} |
---|
[2710] | 95 | ) |
---|
| 96 | |
---|
[8095] | 97 | IF(CEGUI_OLD_VERSION) |
---|
| 98 | INCLUDE_DIRECTORIES(${CEGUILUA_INCLUDE_DIR}) |
---|
| 99 | ENDIF() |
---|
| 100 | |
---|
[7451] | 101 | IF (DBGHELP_FOUND) |
---|
| 102 | INCLUDE_DIRECTORIES(${DBGHELP_INCLUDE_DIR}) |
---|
| 103 | ENDIF() |
---|
| 104 | |
---|
[7960] | 105 | ############## CEGUI OGRE Renderer ############## |
---|
| 106 | |
---|
| 107 | IF(CEGUI_OGRE_RENDERER_BUILD_REQUIRED) |
---|
| 108 | SET(CEGUI_OGRE_RENDERER_LIBRARY ogreceguirenderer_orxonox) |
---|
| 109 | ENDIF() |
---|
| 110 | |
---|
[5752] | 111 | ################### Tolua Bind ################## |
---|
| 112 | |
---|
| 113 | # Create directory because the tolua application doesn't work otherwise |
---|
| 114 | IF(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/toluabind/${CMAKE_CFG_INTDIR}) |
---|
| 115 | FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/toluabind/${CMAKE_CFG_INTDIR}) |
---|
| 116 | ENDIF() |
---|
| 117 | |
---|
| 118 | INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/toluabind/${CMAKE_CFG_INTDIR}) |
---|
| 119 | |
---|
[2710] | 120 | ################ Sub Directories ################ |
---|
| 121 | |
---|
[5738] | 122 | ADD_SUBDIRECTORY(external) |
---|
| 123 | ADD_SUBDIRECTORY(libraries) |
---|
[5752] | 124 | ADD_SUBDIRECTORY(orxonox) |
---|
[5738] | 125 | ADD_SUBDIRECTORY(modules) |
---|
[1505] | 126 | |
---|
[7401] | 127 | ################## Executable ################### |
---|
[1854] | 128 | |
---|
[5752] | 129 | INCLUDE_DIRECTORIES( |
---|
| 130 | ${CMAKE_CURRENT_SOURCE_DIR}/libraries |
---|
| 131 | ${CMAKE_CURRENT_SOURCE_DIR}/orxonox |
---|
| 132 | ) |
---|
| 133 | |
---|
[5738] | 134 | # Translate argument |
---|
| 135 | IF(ORXONOX_USE_WINMAIN) |
---|
| 136 | SET(ORXONOX_WIN32 WIN32) |
---|
[2710] | 137 | ENDIF() |
---|
[1810] | 138 | |
---|
[8130] | 139 | SET(ORXONOX_MAIN_FILES Orxonox.cc) |
---|
| 140 | |
---|
| 141 | # Add special source file for OS X |
---|
| 142 | IF(APPLE) |
---|
| 143 | LIST(APPEND ORXONOX_MAIN_FILES OrxonoxMac.mm) |
---|
| 144 | ENDIF() |
---|
| 145 | |
---|
[5738] | 146 | ORXONOX_ADD_EXECUTABLE(orxonox-main |
---|
| 147 | # When defined as WIN32 this removes the console window on Windows |
---|
| 148 | ${ORXONOX_WIN32} |
---|
| 149 | LINK_LIBRARIES |
---|
| 150 | orxonox |
---|
| 151 | SOURCE_FILES |
---|
[8130] | 152 | ${ORXONOX_MAIN_FILES} |
---|
[5738] | 153 | OUTPUT_NAME orxonox |
---|
| 154 | ) |
---|
[7401] | 155 | # Main executable should depend on all modules |
---|
| 156 | ADD_DEPENDENCIES(orxonox-main ${ORXONOX_MODULES}) |
---|
[1810] | 157 | |
---|
[5752] | 158 | # Get name to configure the run scripts |
---|
[5738] | 159 | GET_TARGET_PROPERTY(_exec_loc orxonox-main LOCATION) |
---|
| 160 | GET_FILENAME_COMPONENT(_exec_name ${_exec_loc} NAME) |
---|
| 161 | SET(ORXONOX_EXECUTABLE_NAME ${_exec_name} CACHE INTERNAL "") |
---|
[5744] | 162 | |
---|
| 163 | |
---|
| 164 | # When using Visual Studio we want to use the output directory as working |
---|
| 165 | # directory and we also want to specify where the external dlls |
---|
| 166 | # (lua, ogre, etc.) are. The problem hereby is that these information cannot |
---|
| 167 | # be specified in CMake because they are not stored in the actual project file. |
---|
| 168 | # This workaround will create a configured *.vcproj.user file that holds the |
---|
| 169 | # right values. When starting the solution for the first time, |
---|
| 170 | # these get written to the *vcproj.yourPCname.yourname.user |
---|
| 171 | IF(MSVC) |
---|
| 172 | IF(CMAKE_CL_64) |
---|
| 173 | SET(MSVC_PLATFORM "x64") |
---|
| 174 | ELSE() |
---|
| 175 | SET(MSVC_PLATFORM "Win32") |
---|
| 176 | ENDIF() |
---|
[8057] | 177 | IF(MSVC10) |
---|
| 178 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/orxonox-main.vcxproj.user.in" "${CMAKE_CURRENT_BINARY_DIR}/orxonox-main.vcxproj.user") |
---|
| 179 | ELSE() |
---|
| 180 | STRING(REGEX REPLACE "^Visual Studio ([0-9][0-9]?).*$" "\\1" |
---|
| 181 | VISUAL_STUDIO_VERSION_SIMPLE "${CMAKE_GENERATOR}") |
---|
| 182 | CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/orxonox-main.vcproj.user.in" "${CMAKE_CURRENT_BINARY_DIR}/orxonox-main.vcproj.user") |
---|
| 183 | ENDIF() |
---|
[5744] | 184 | ENDIF(MSVC) |
---|
[7401] | 185 | |
---|
[8129] | 186 | # Apple Mac OS X specific build settings |
---|
| 187 | IF(APPLE) |
---|
| 188 | # On Apple we need to link to AppKit and Foundation frameworks |
---|
| 189 | TARGET_LINK_LIBRARIES(orxonox-main |
---|
| 190 | "-framework AppKit" |
---|
| 191 | "-framework Foundation" |
---|
| 192 | ) |
---|
| 193 | |
---|
| 194 | # Post-build step for the creation of the Dev-App bundle |
---|
| 195 | INCLUDE(PrepareDevBundle) |
---|
| 196 | ADD_CUSTOM_COMMAND( |
---|
| 197 | TARGET orxonox-main |
---|
| 198 | POST_BUILD |
---|
| 199 | # Copy the executable into the Orxonox.app |
---|
[8216] | 200 | COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/${ORXONOX_EXECUTABLE_NAME}" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/${PROJECT_NAME}.app/Contents/MacOS" |
---|
[8129] | 201 | # Copy the dev-build marker file to Orxonox.app |
---|
[8216] | 202 | COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/orxonox_dev_build.keep_me" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/${PROJECT_NAME}.app/Contents/MacOS" |
---|
| 203 | # Create a shortcut of the application to the root of the build tree |
---|
| 204 | COMMAND ${CMAKE_COMMAND} -E create_symlink "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/${PROJECT_NAME}.app" "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.app" |
---|
[8129] | 205 | ) |
---|
| 206 | ENDIF(APPLE) |
---|
| 207 | |
---|
[7401] | 208 | #################### Doxygen #################### |
---|
| 209 | |
---|
| 210 | # Prepare include paths for Doxygen. This is necessary to display |
---|
| 211 | # the correct path to use when including a file, e.g. |
---|
| 212 | # core/XMLPort.h instead of src/core/XMLPort.h |
---|
| 213 | |
---|
| 214 | INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/modules) |
---|
| 215 | GET_DIRECTORY_PROPERTY(_temp INCLUDE_DIRECTORIES) |
---|
| 216 | # Replace ';' by spaces |
---|
| 217 | STRING(REPLACE ";" " " _temp "${_temp}") |
---|
| 218 | SET(DOXYGEN_INCLUDE_DIRECTORIES "${_temp}" PARENT_SCOPE) |
---|