1 include(GNUInstallDirs)
3 # Set the options for the directories (personal, shared, global).
5 # set_directory_options()
7 function(set_directory_options)
9 set(DEFAULT_PERSONAL_DIR "Documents/OpenTTD")
10 set(DEFAULT_SHARED_DIR "/Library/Application Support/OpenTTD")
11 set(DEFAULT_GLOBAL_DIR "(not set)")
13 set(DEFAULT_PERSONAL_DIR "OpenTTD")
14 set(DEFAULT_SHARED_DIR "(not set)")
15 set(DEFAULT_GLOBAL_DIR "(not set)")
17 set(DEFAULT_PERSONAL_DIR ".${BINARY_NAME}")
18 set(DEFAULT_SHARED_DIR "(not set)")
19 set(DEFAULT_GLOBAL_DIR "${CMAKE_INSTALL_FULL_DATADIR}/${BINARY_NAME}")
21 message(FATAL_ERROR "Unknown OS found; please consider creating a Pull Request to add support for this OS.")
25 set(PERSONAL_DIR "${DEFAULT_PERSONAL_DIR}" CACHE STRING "Personal directory")
26 message(STATUS "Detecting Personal Data directory - ${PERSONAL_DIR}")
30 set(SHARED_DIR "${DEFAULT_SHARED_DIR}" CACHE STRING "Shared directory")
31 message(STATUS "Detecting Shared Data directory - ${SHARED_DIR}")
35 set(GLOBAL_DIR "${DEFAULT_GLOBAL_DIR}" CACHE STRING "Global directory")
36 message(STATUS "Detecting Global Data directory - ${GLOBAL_DIR}")
39 set(HOST_BINARY_DIR "" CACHE PATH "Full path to native cmake build directory")
42 # Set some generic options that influence what is being build.
47 option(OPTION_PACKAGE_DEPENDENCIES "Copy dependencies into lib/ for easy packaging (Linux only)" OFF)
49 if(UNIX AND NOT APPLE AND NOT OPTION_PACKAGE_DEPENDENCIES)
50 set(DEFAULT_OPTION_INSTALL_FHS ON)
52 set(DEFAULT_OPTION_INSTALL_FHS OFF)
55 option(OPTION_FORCE_COLORED_OUTPUT "Always produce ANSI-colored output (GNU/Clang only)." OFF)
57 option(OPTION_DEDICATED "Build dedicated server only (no GUI)" OFF)
58 option(OPTION_INSTALL_FHS "Install with Filesystem Hierarchy Standard folders" ${DEFAULT_OPTION_INSTALL_FHS})
59 option(OPTION_USE_ASSERTS "Use assertions; leave enabled for nightlies, betas, and RCs" ON)
60 option(OPTION_USE_NSIS "Use NSIS to create windows installer; enable only for stable releases" OFF)
61 option(OPTION_TOOLS_ONLY "Build only tools target" OFF)
62 option(OPTION_DOCS_ONLY "Build only docs target" OFF)
63 option(OPTION_ALLOW_INVALID_SIGNATURE "Allow loading of content with invalid signatures" OFF)
66 set(OPTION_TOOLS_ONLY ON PARENT_SCOPE)
69 option(OPTION_SURVEY_KEY "Survey-key to use for the opt-in survey (empty if you have none)" "")
72 # Show the values of the generic options.
76 function(show_options)
77 message(STATUS "Option Package Dependencies - ${OPTION_PACKAGE_DEPENDENCIES}")
78 message(STATUS "Option Dedicated - ${OPTION_DEDICATED}")
79 message(STATUS "Option Install FHS - ${OPTION_INSTALL_FHS}")
80 message(STATUS "Option Use assert - ${OPTION_USE_ASSERTS}")
81 message(STATUS "Option Use NSIS - ${OPTION_USE_NSIS}")
84 message(STATUS "Option Survey Key - USED")
86 message(STATUS "Option Survey Key - NOT USED")
89 if(OPTION_ALLOW_INVALID_SIGNATURE)
90 message(STATUS "Option Allow Invalid Signature - USED")
91 message(WARNING "Ignoring invalid signatures is a security risk! Use with care!")
95 # Add the definitions for the options that are selected.
97 # add_definitions_based_on_options()
99 function(add_definitions_based_on_options)
101 add_definitions(-DDEDICATED)
104 if(OPTION_USE_ASSERTS)
105 add_definitions(-DWITH_ASSERT)
107 add_definitions(-DNDEBUG)
110 if(OPTION_SURVEY_KEY)
111 add_definitions(-DSURVEY_KEY="${OPTION_SURVEY_KEY}")
114 if(OPTION_ALLOW_INVALID_SIGNATURE)
115 add_definitions(-DALLOW_INVALID_SIGNATURE)