1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402
|
# let's go with lower case for commands (or at least be consistent)
# arbitrarily following http://techbase.kde.org/Policies/CMake_Coding_Style#Upper.2Flower_casing
cmake_minimum_required(VERSION 2.8)
if(CMAKE_MAJOR_VERSION GREATER 2)
# Continue to support compatiable interface for _DEBUG on targets
# see: http://www.cmake.org/cmake/help/v3.0/policy/CMP0043.html
cmake_policy(SET CMP0043 OLD)
endif()
# We don't use C but CMake on linux complains if we don't have it enabled
project(wxlauncher CXX C)
set(VERSION_MAJOR 0)
set(VERSION_MINOR 11)
set(VERSION_PATCH 0)
message("--- Configuring wxLauncher ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_SOURCE_DIR}/cmake/include")
set(CMAKE_OSX_ARCHITECTURES i386)
if(NOT(DEFINED IS_WIN32 OR DEFINED IS_LINUX OR DEFINED IS_APPLE))
if(WIN32)
set(IS_WIN32 TRUE)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(IS_APPLE TRUE)
else()
set(IS_LINUX TRUE)
endif()
endif()
if(DEFINED WXVER AND NOT WXVER MATCHES "PLATFORM")
# we are given an explict wxWidgets version we must use
# which means we are probably on CI builder
message("-- Explicitly told to use WXVER ${WXVER}")
if(NOT DEFINED wxWidgets_ROOT_DIR OR NOT wxWidgets_ROOT_DIR)
set(wxWidgets_ROOT_DIR $ENV{WXWIDGETS${WXVER}})
endif()
message("--- Searching for wxWidgets in ${wxWidgets_ROOT_DIR}")
if(WXVER MATCHES "2.8")
find_package(wxWidgets 2.8.10
COMPONENTS base core net xml html adv qa richtext)
elseif(WXVER MATCHES "3.0")
find_package(wxWidgets 3.0.2
COMPONENTS base core net xml html adv qa richtext)
else()
message(FATAL_ERROR "Unknown WXVER forced")
endif()
#ensure we have the correct version with or without stl as requested
if(NOT DEFINED HAVE_WXUSE_STL
OR NOT wxWidgets_ROOT_DIR MATCHES STL_TEST_WX_ROOT)
# Save for later to test if root changes
set(STL_TEST_WX_ROOT ${wxWidgets_ROOT_DIR})
message("-- Testing wxUSE_STL")
try_compile(HAVE_WXUSE_STL ${CMAKE_BINARY_DIR}
SOURCES ${CMAKE_SOURCE_DIR}/cmake/test_wxstl.cpp
COMPILE_DEFINITIONS "/I${wxWidgets_LIB_DIR}/${wxWidgets_CONFIGURATION} /I${wxWidgets_ROOT_DIR}/include")
if(WXVER MATCHES "stl")
if(NOT HAVE_WXUSE_STL)
message(FATAL_ERROR "wxUSE_STL required but not provided")
endif()
else()
if(HAVE_WXUSE_STL)
message(FATAL_ERROR "wxUSE_STL enabled but was not requested")
endif()
endif()
endif()
else()
message("-- Searching for wxWidgets")
find_package(wxWidgets 2.8.10
COMPONENTS base core net xml html adv qa richtext)
endif()
if(NOT wxWidgets_FOUND)
message(FATAL_ERROR "Unable to locate wxWidgets")
endif()
if(NOT PYTHON_EXECUTABLE)
# Only try to find python iff not already given
include(FindPythonInterp) #PYTHON_EXECUTABLE
endif()
find_program(GIT_EXECUTABLE git)
option(onlinehelpmaker_debug "Have the onlinehelpmaker.py script output debug information" OFF)
if(onlinehelpmaker_debug)
set(HELPMAKER_DEBUG "-d")
set(HELPMAKER_QUIET "")
else(onlinehelpmaker_debug)
set(HELPMAKER_DEBUG "")
option(onlinehelpmaker_quiet "Have onlinehelpmaker.py produce even less output than normal" ON)
if(onlinehelpmaker_quiet)
set(HELPMAKER_QUIET "-q")
else()
set(HELPMAKER_QUIET "")
endif()
endif(onlinehelpmaker_debug)
# This needs to be set so that VS2008 will link against the most recent
# version of the CRT, the one that is being distrubuted in the installer
if(IS_WIN32)
add_definitions("/D_BIND_TO_CURRENT_CRT_VERSION=1")
add_definitions("/D_CRT_SECURE_NO_WARNINGS")
endif(IS_WIN32)
set(helphtblocation ${CMAKE_CURRENT_BINARY_DIR}/generated/onlinehelp.htb)
option(DEVELOPMENT_MODE "Doing development (cannot build installer in this mode)" OFF)
if(DEVELOPMENT_MODE)
set(HELP_HTB_LOCATION ${helphtblocation})
set(RESOURCES_PATH ${PROJECT_SOURCE_DIR}/resources)
else(DEVELOPMENT_MODE)
if (NOT DEFINED RESOURCES_PATH)
if(IS_WIN32)
set(RESOURCES_PATH resources)
elseif(IS_APPLE)
set(RESOURCES_PATH wxlauncher.app/Contents/Resources)
else()
set(RESOURCES_PATH /usr/share/freespace2-launcher/)
endif()
endif()
set(HELP_HTB_LOCATION ${RESOURCES_PATH}/onlinehelp.htb)
endif(DEVELOPMENT_MODE)
option(PROFILE_DEBUGGING "Extra verbose debug logs that include snapshots of profile contents at important steps while auto-save is off" OFF)
if(DEFINED $ENV{OPTIONS} AND $ENV{OPTIONS} STREQUAL "DisableAll")
set(OPTION_DEFAULT OFF)
else()
set(OPTION_DEFAULT ON)
endif()
if(IS_WIN32)
# Don't offer features that can only work on Windows
option(USE_SPEECH "Build launcher with speech support?" ${OPTION_DEFAULT})
endif()
option(USE_JOYSTICK "Build launcher with joystick support?" ${OPTION_DEFAULT})
option(USE_OPENAL "Build launcher with OpenAL support?" ${OPTION_DEFAULT})
if(USE_OPENAL)
find_package(OpenAL REQUIRED)
include_directories(${OPENAL_INCLUDE_DIR})
endif(USE_OPENAL)
IF(UNIX)
INCLUDE(FindPkgConfig)
PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2)
set(SDL2_INCLUDES ${SDL2_INCLUDE_DIRS})
else()
set(SDL2_INCLUDES "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/SDL2-2_0_3/include")
IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
# 64-bit
set(ARCH "x64")
ELSE(CMAKE_SIZEOF_VOID_P EQUAL 8)
# 32-bit
set(ARCH "x86")
ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(SDL2_LIBRARIES "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/SDL2-2_0_3/lib/${ARCH}/SDL2.lib")
set(SDL2_DLL "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/SDL2-2_0_3/lib/${ARCH}/SDL2.dll")
endif()
include_directories(${SDL2_INCLUDES})
set(HAS_SDL true)
if(IS_APPLE)
option(USING_SDL_FRAMEWORK "Check this if building with an SDL framework." ON)
endif()
# Make PLATFORM_USES_REGISTRY true only on windows, so that wxLauncher
# will not try to compile the registry code on non Win32 systems.
# Allow the user to define this as false even on windows if they want
if((IS_WIN32) AND (NOT DEFINED PLATFORM_USES_REGISTRY))
set(PLATFORM_USES_REGISTRY TRUE)
endif()
include(${wxWidgets_USE_FILE})
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR}/code)
# Check to see if we have a GIT executable so that we will be able to
# generate the version.cpp. If we don't have a hg binary, notify and
# create the target to copy a template version.
if(GIT_EXECUTABLE)
add_custom_target(version.cpp.maker ALL
COMMAND ${PYTHON_EXECUTABLE} scripts/version.cpp.maker.py build ${CMAKE_CURRENT_BINARY_DIR}/generated/version_strings.cpp ${CMAKE_CURRENT_BINARY_DIR}/version.cpp.maker.temp --gitpath=${GIT_EXECUTABLE}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
else()
add_custom_target(version.cpp.maker ALL
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/code/global/version_strings.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/generated/version_strings.cpp
)
message( "Cannot find a commandline Mercurial client (hg). version_strings.cpp will be generated by copying a dummy file.")
endif()
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_CURRENT_BINARY_DIR}/generated/version_strings.cpp)
add_custom_target(helpmaker ALL
COMMAND ${PYTHON_EXECUTABLE} scripts/onlinehelpmaker.py build ${helphtblocation} ${CMAKE_SOURCE_DIR}/onlinehelp ${HELPMAKER_QUIET} ${HELPMAKER_DEBUG} -t ${CMAKE_CURRENT_BINARY_DIR}/onlinehelpmaker -c ${CMAKE_CURRENT_BINARY_DIR}/generated/helplinks.cpp
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_CURRENT_BINARY_DIR}/generated/helplinks.cpp)
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${helphtblocation})
file(GLOB_RECURSE helpmaker_temp_files ${CMAKE_CURRENT_BINARY_DIR}/onlinehelpmaker/*.*)
# Call out the files that are built a part of the build
# The HTBs do not need to be run through a complier
set_source_files_properties(
${helphtblocation}
PROPERTIES GENERATED true EXTERNAL_OBJECT true)
set_source_files_properties(
${CMAKE_CURRENT_BINARY_DIR}/generated/helplinks.cpp
${CMAKE_CURRENT_BINARY_DIR}/generated/version_strings.cpp
PROPERTIES GENERATED true)
set(TAB_CODE_FILES
code/tabs/AdvSettingsPage.h
code/tabs/AdvSettingsPage.cpp
code/tabs/BasicSettingsPage.h
code/tabs/BasicSettingsPage.cpp
code/tabs/InstallPage.h
code/tabs/InstallPage.cpp
code/tabs/ModsPage.h
code/tabs/ModsPage.cpp
code/tabs/WelcomePage.h
code/tabs/WelcomePage.cpp
)
source_group(Tabs FILES ${TAB_CODE_FILES})
set(GUI_CONTROL_CODE_FILES
code/controls/BottomButtons.h
code/controls/BottomButtons.cpp
code/controls/FlagListBox.h
code/controls/FlagListBox.cpp
code/controls/LightingPresets.h
code/controls/LightingPresets.cpp
code/controls/Logger.h
code/controls/Logger.cpp
code/controls/ModList.h
code/controls/ModList.cpp
code/controls/StatusBar.h
code/controls/StatusBar.cpp
code/controls/TruncatableChoice.h
code/controls/TruncatableChoice.cpp
)
source_group("GUI Controls" FILES ${GUI_CONTROL_CODE_FILES})
set(GLOBAL_CODE_FILES
code/global/configure_launcher.h.in
${CMAKE_CURRENT_BINARY_DIR}/generated/configure_launcher.h
code/global/BasicDefaults.h
code/global/BasicDefaults.cpp
code/global/ids.h
code/global/MemoryDebugging.h
code/global/ModDefaults.h
code/global/ModDefaults.cpp
code/global/ModIniKeys.h
code/global/ModIniKeys.cpp
code/global/ProfileKeys.h
code/global/ProfileKeys.cpp
code/global/RegistryKeys.h
code/global/RegistryKeys.cpp
code/global/SkinDefaults.h
code/global/SkinDefaults.cpp
code/global/targetver.h
code/global/Utils.h
code/global/Utils.cpp
code/global/version.h
code/global/version.cpp
code/global/Compatibility.cpp
code/global/Compatibility.h)
source_group(Global FILES ${GLOBAL_CODE_FILES})
set(DATASTRUCTURE_CODE_FILES
code/datastructures/FlagInfo.cpp
code/datastructures/FlagFileData.h
code/datastructures/FlagFileData.cpp
code/datastructures/FSOExecutable.h
code/datastructures/FSOExecutable.cpp
code/datastructures/NewsSource.h
code/datastructures/NewsSource.cpp
code/datastructures/ResolutionMap.h
code/datastructures/ResolutionMap.cpp
)
source_group("Data Structures" FILES ${DATASTRUCTURE_CODE_FILES})
set(API_CODE_FILES
code/apis/CmdLineManager.h
code/apis/CmdLineManager.cpp
code/apis/EventHandlers.h
code/apis/EventHandlers.cpp
code/apis/FlagListManager.h
code/apis/FlagListManager.cpp
code/apis/FREDManager.h
code/apis/FREDManager.cpp
code/apis/HelpManager.h
code/apis/HelpManager.cpp
code/apis/JoystickManager.h
code/apis/JoystickManager.cpp
code/apis/OpenALManager.h
code/apis/OpenALManager.cpp
code/apis/ProfileManager.h
code/apis/ProfileManagerOperator.h
code/apis/ProfileManager.cpp
code/apis/ProfileManagerOperator.cpp
code/apis/ProfileProxy.h
code/apis/ProfileProxy.cpp
code/apis/SkinManager.h
code/apis/SkinManager.cpp
code/apis/SpeechManager.h
code/apis/SpeechManager.cpp
code/apis/TCManager.h
code/apis/TCManager.cpp
code/apis/PlatformProfileManager.h
code/apis/RegistryProfileManager.cpp
code/apis/FileProfileManager.cpp
code/apis/PlatformProfileManagerShared.cpp
)
source_group(Apis FILES ${API_CODE_FILES})
set(RESOURCE_FILES
platform/win32/wxlauncher.rc
${CMAKE_CURRENT_BINARY_DIR}/generated/version_strings.cpp
${CMAKE_CURRENT_BINARY_DIR}/generated/helplinks.cpp
)
source_group(Resources FILES ${RESOURCE_FILES})
set(CODE_FILES
code/MainWindow.h
code/MainWindow.cpp
code/wxLauncherApp.h
code/wxLauncherApp.cpp
)
source_group("Main Code Files" FILES ${CODE_FILES})
add_executable(wxlauncher WIN32 MACOSX_BUNDLE
${TAB_CODE_FILES}
${GUI_CONTROL_CODE_FILES}
${GLOBAL_CODE_FILES}
${DATASTRUCTURE_CODE_FILES}
${API_CODE_FILES}
${RESOURCE_FILES}
${CODE_FILES}
)
set_target_properties(wxlauncher
PROPERTIES LINKER_LANGUAGE CXX
POSITION_INDEPENDENT_CODE ON)
# Files that are not to be compiled directly
set_source_files_properties(
${CMAKE_CURRENT_BINARY_DIR}/generated/helplinks.cpp
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/onlinehelp.htb
${CMAKE_CURRENT_BINARY_DIR}/generated/configure_launcher.h
code/datastructures/FlagInfo.cpp
code/global/configure_launcher.h.in
PROPERTIES HEADER_FILE_ONLY true)
add_dependencies(wxlauncher helpmaker version.cpp.maker)
configure_file(${CMAKE_SOURCE_DIR}/code/global/configure_launcher.h.in
${CMAKE_CURRENT_BINARY_DIR}/generated/configure_launcher.h)
foreach(temp_file ${helpmaker_temp_files})
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES ${temp_file})
endforeach(temp_file)
target_link_libraries(wxlauncher ${wxWidgets_LIBRARIES} ${SDL2_LIBRARIES})
# adapted from http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_apply_resources_on_Mac_OS_X_automatically.3F
# copies necessary resources (and frameworks, if needed) to .app bundle
if(IS_APPLE)
set(APP_RESOURCES_PATH ${CMAKE_CURRENT_BINARY_DIR}/$(CONFIGURATION)/${RESOURCES_PATH})
set(APP_FRAMEWORKS_PATH ${CMAKE_CURRENT_BINARY_DIR}/$(CONFIGURATION)/wxlauncher.app/Contents/Frameworks)
add_custom_command(TARGET wxlauncher POST_BUILD
COMMAND rm -rf ${APP_RESOURCES_PATH}
COMMAND rm -rf ${APP_FRAMEWORKS_PATH}
COMMAND mkdir ${APP_RESOURCES_PATH}
COMMAND mkdir ${APP_FRAMEWORKS_PATH}
COMMAND cp ${PROJECT_SOURCE_DIR}/resources/* ${APP_RESOURCES_PATH}
COMMAND cp ${helphtblocation} ${APP_RESOURCES_PATH}
COMMAND cp ${PROJECT_SOURCE_DIR}/platform/macosx/wxlauncher.icns ${APP_RESOURCES_PATH})
if(USING_SDL_FRAMEWORK) # then copy the framework into the app
add_custom_command(TARGET wxlauncher POST_BUILD
COMMAND cp -R ${SDL_LIBRARY} ${APP_FRAMEWORKS_PATH})
endif(USING_SDL_FRAMEWORK)
endif(IS_APPLE)
# packaging
set(LAUNCHER_CMAKE_SOURCE_DIR ${CMAKE_SOURCE_DIR}/cmake)
if(DEVELOPMENT_MODE)
message( "Development mode is set. Building of installers is not allowed. Set DEVELOPMENT_MODE=OFF to build installers.")
configure_file(${CMAKE_SOURCE_DIR}/cmake/FailCPack.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/CPackConfig.cmake COPYONLY)
configure_file(${CMAKE_SOURCE_DIR}/cmake/FailCPack.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/CPackSourceConfig.cmake COPYONLY)
if(SDL2_DLL)
ADD_CUSTOM_COMMAND(
TARGET wxlauncher POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${SDL2_DLL}" "$<TARGET_FILE_DIR:wxlauncher>"
COMMENT "copying '${SDL2_DLL}'..."
)
endif()
else()
include(${LAUNCHER_CMAKE_SOURCE_DIR}/wxLauncherInstaller.cmake)
endif()
|