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)
61 # Although pthreads is supported, it is not in a way yet that is
63 option(OPTION_USE_THREADS "Use threads" OFF)
65 option(OPTION_USE_THREADS "Use threads" ON)
67 option(OPTION_USE_NSIS "Use NSIS to create windows installer; enable only for stable releases" OFF)
68 option(OPTION_TOOLS_ONLY "Build only tools target" OFF)
69 option(OPTION_DOCS_ONLY "Build only docs target" OFF)
72 set(OPTION_TOOLS_ONLY ON PARENT_SCOPE)
76 # Show the values of the generic options.
80 function(show_options)
81 message(STATUS "Option Package Dependencies - ${OPTION_PACKAGE_DEPENDENCIES}")
82 message(STATUS "Option Dedicated - ${OPTION_DEDICATED}")
83 message(STATUS "Option Install FHS - ${OPTION_INSTALL_FHS}")
84 message(STATUS "Option Use assert - ${OPTION_USE_ASSERTS}")
85 message(STATUS "Option Use threads - ${OPTION_USE_THREADS}")
86 message(STATUS "Option Use NSIS - ${OPTION_USE_NSIS}")
89 # Add the definitions for the options that are selected.
91 # add_definitions_based_on_options()
93 function(add_definitions_based_on_options)
95 add_definitions(-DDEDICATED)
98 if(NOT OPTION_USE_THREADS)
99 add_definitions(-DNO_THREADS)
102 if(OPTION_USE_ASSERTS)
103 add_definitions(-DWITH_ASSERT)
105 add_definitions(-DNDEBUG)