25 |
25 |
26 #libraries are built shared unless explicitly added as a static |
26 #libraries are built shared unless explicitly added as a static |
27 option(BUILD_SHARED_LIBS "Build libraries as shared modules (on)" ON) |
27 option(BUILD_SHARED_LIBS "Build libraries as shared modules (on)" ON) |
28 |
28 |
29 if(WIN32 OR APPLE) |
29 if(WIN32 OR APPLE) |
30 option(PHYSFS_SYSTEM "Use system physfs (off)" OFF) |
|
31 option(LUA_SYSTEM "Use system lua (off)" OFF) |
30 option(LUA_SYSTEM "Use system lua (off)" OFF) |
32 else() |
31 else() |
33 option(PHYSFS_SYSTEM "Use system physfs (on)" ON) |
|
34 option(LUA_SYSTEM "Use system lua (on)" ON) |
32 option(LUA_SYSTEM "Use system lua (on)" ON) |
35 endif() |
33 endif() |
36 |
34 |
37 option(BUILD_ENGINE_LIBRARY "Enable hwengine library (off)" OFF) |
35 option(BUILD_ENGINE_LIBRARY "Enable hwengine library (off)" OFF) |
38 option(ANDROID "Enable Android build (off)" OFF) |
36 option(ANDROID "Enable Android build (off)" OFF) |
51 endif() |
49 endif() |
52 |
50 |
53 option(NOVERSIONINFOUPDATE "Disable update of version_info.txt. To be used if source is in a git/repo that is NOT the hedgewars repo" OFF) |
51 option(NOVERSIONINFOUPDATE "Disable update of version_info.txt. To be used if source is in a git/repo that is NOT the hedgewars repo" OFF) |
54 |
52 |
55 |
53 |
|
54 if(BUILD_ENGINE_C AND NOT NOVIDEOREC) |
|
55 if((CMAKE_BUILD_TYPE MATCHES "RELEASE") OR (CMAKE_BUILD_TYPE MATCHES "RELWITHDEBUGINFO")) |
|
56 message("NOTE: Video recorder support disabled. It's incompatible with BUILD_ENGINE_C") |
|
57 set(BUILD_ENGINE_C ON CACHE STRING "Required for BUILD_ENGINE_JS" FORCE) |
|
58 else() |
|
59 message("WARNING: Video recorder support is currently incompatible with BUILD_ENGINE_C, the video recorder won't work (but demos are fine)! See <https://issues.hedgewars.org/show_bug.cgi?id=722>.") |
|
60 endif() |
|
61 endif() |
56 if(BUILD_ENGINE_JS) |
62 if(BUILD_ENGINE_JS) |
57 if(NOT CMAKE_TOOLCHAIN_FILE) |
63 if(NOT CMAKE_TOOLCHAIN_FILE) |
58 message(FATAL_ERROR "Missing emscripten toolchain file\nClean your cache and rerun cmake with -DCMAKE_TOOLCHAIN_FILE=${CMAKE_SOURCE_DIR}/cmake_modules/Platform/Emscripten.cmake") |
64 message(FATAL_ERROR "Missing emscripten toolchain file\nClean your cache and rerun cmake with -DCMAKE_TOOLCHAIN_FILE=${CMAKE_SOURCE_DIR}/cmake_modules/Platform/Emscripten.cmake") |
59 endif() |
65 endif() |
60 |
66 |
61 set(BUILD_ENGINE_C ON CACHE STRING "Required for BUILD_ENGINE_JS" FORCE) |
67 set(BUILD_ENGINE_C ON CACHE STRING "Required for BUILD_ENGINE_JS" FORCE) |
62 set(BUILD_ENGINE_LIBRARY ON CACHE STRING "Required for BUILD_ENGINE_JS" FORCE) |
68 set(BUILD_ENGINE_LIBRARY ON CACHE STRING "Required for BUILD_ENGINE_JS" FORCE) |
63 set(NOAUTOUPDATE ON CACHE STRING "Required for BUILD_ENGINE_JS" FORCE) |
69 set(NOAUTOUPDATE ON CACHE STRING "Required for BUILD_ENGINE_JS" FORCE) |
64 set(PHYSFS_SYSTEM OFF CACHE STRING "Required for BUILD_ENGINE_JS" FORCE) |
|
65 set(LUA_SYSTEM OFF CACHE STRING "Required for BUILD_ENGINE_JS" FORCE) |
70 set(LUA_SYSTEM OFF CACHE STRING "Required for BUILD_ENGINE_JS" FORCE) |
66 set(NOVIDEOREC ON CACHE STRING "Required for BUILD_ENGINE_JS" FORCE) |
71 set(NOVIDEOREC ON CACHE STRING "Required for BUILD_ENGINE_JS" FORCE) |
67 set(NOSERVER ON CACHE STRING "Required for BUILD_ENGINE_JS" FORCE) |
72 set(NOSERVER ON CACHE STRING "Required for BUILD_ENGINE_JS" FORCE) |
68 set(GL2 ON CACHE STRING "Required for BUILD_ENGINE_JS" FORCE) |
73 set(GL2 ON CACHE STRING "Required for BUILD_ENGINE_JS" FORCE) |
69 set(BUILD_SHARED_LIBS OFF CACHE STRING "Required for BUILD_ENGINE_JS" FORCE) |
74 set(BUILD_SHARED_LIBS OFF CACHE STRING "Required for BUILD_ENGINE_JS" FORCE) |
70 |
75 |
71 set(target_binary_install_dir "bin" CACHE PATH "install dest for binaries") |
76 set(target_binary_install_dir "bin" CACHE PATH "install dest for binaries") |
72 set(target_library_install_dir "lib" CACHE PATH "install dest for libs") |
77 set(target_library_install_dir "lib" CACHE PATH "install dest for libs") |
73 endif() |
78 endif() |
74 |
79 |
|
80 if("${CMAKE_SIZEOF_VOID_P}" EQUAL "4" AND UNIX AND NOT APPLE) |
|
81 set(BUILD_ENGINE_C ON CACHE STRING "PAS2C force-enabled due to a freepascal 32 bit alignment bug" FORCE) |
|
82 endif() |
|
83 |
75 #system paths for finding required fonts (see share/hedgewars/Data/fonts) |
84 #system paths for finding required fonts (see share/hedgewars/Data/fonts) |
76 #subdirectories will NOT be searched. |
85 #subdirectories will NOT be searched. |
77 #all fonts that can't be found will be bundled with hedgewars |
86 #all fonts that can't be found will be bundled with hedgewars |
78 set(FONTS_DIRS "" CACHE STRING "Additional paths to folders where required fonts can be found ( ; is separator)") |
87 set(FONTS_DIRS "" CACHE STRING "Additional paths to folders where required fonts can be found ( ; is separator)") |
79 |
88 |
80 #versioning |
89 #versioning |
81 set(CPACK_PACKAGE_VERSION_MAJOR 0) |
90 set(CPACK_PACKAGE_VERSION_MAJOR 1) |
82 set(CPACK_PACKAGE_VERSION_MINOR 9) |
91 set(CPACK_PACKAGE_VERSION_MINOR 0) |
83 set(CPACK_PACKAGE_VERSION_PATCH "24.1") |
92 set(CPACK_PACKAGE_VERSION_PATCH 0) |
84 set(HEDGEWARS_PROTO_VER 55) |
93 set(HEDGEWARS_PROTO_VER 58) |
85 set(HEDGEWARS_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") |
94 if((CMAKE_BUILD_TYPE MATCHES "RELEASE") OR (CMAKE_BUILD_TYPE MATCHES "RELWITHDEBUGINFO")) |
|
95 set(HEDGEWARS_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") |
|
96 else() |
|
97 set(HEDGEWARS_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}-dev") |
|
98 endif() |
86 include(${CMAKE_MODULE_PATH}/revinfo.cmake) |
99 include(${CMAKE_MODULE_PATH}/revinfo.cmake) |
87 |
100 |
88 message(STATUS "Building ${HEDGEWARS_VERSION}-r${HEDGEWARS_REVISION} (${HEDGEWARS_HASH})") |
101 message(STATUS "Building ${HEDGEWARS_VERSION}-r${HEDGEWARS_REVISION} (${HEDGEWARS_HASH})") |
89 |
102 |
90 #io library paths |
103 #io library paths |
114 if(NOT BUILD_ENGINE_JS) |
127 if(NOT BUILD_ENGINE_JS) |
115 include(${CMAKE_MODULE_PATH}/compilerchecks.cmake) |
128 include(${CMAKE_MODULE_PATH}/compilerchecks.cmake) |
116 endif() |
129 endif() |
117 |
130 |
118 #set default compiler flags |
131 #set default compiler flags |
119 add_flag_append(CMAKE_C_FLAGS "-Wall -pipe") |
132 if(WIN32 AND VCPKG_TOOLCHAIN) |
120 add_flag_append(CMAKE_C_FLAGS_RELEASE "-O2") |
133 add_flag_append(CMAKE_C_FLAGS "/DWIN32_VCPKG /Wall") |
121 add_flag_append(CMAKE_C_FLAGS_DEBUG "-Wextra -O0") |
134 add_flag_append(CMAKE_C_FLAGS_RELEASE "/Ox") |
122 add_flag_append(CMAKE_CXX_FLAGS "-Wall -pipe") |
135 add_flag_append(CMAKE_C_FLAGS_DEBUG "/Od") |
123 add_flag_append(CMAKE_CXX_FLAGS_RELEASE "-O2") |
136 add_flag_append(CMAKE_CXX_FLAGS "/DWIN32_VCPKG /Wall") |
124 add_flag_append(CMAKE_CXX_FLAGS_DEBUG "-Wextra -O0") |
137 add_flag_append(CMAKE_CXX_FLAGS_RELEASE "/Ox") |
|
138 add_flag_append(CMAKE_CXX_FLAGS_DEBUG "/Od") |
|
139 else() |
|
140 add_flag_append(CMAKE_C_FLAGS "-Wall -pipe") |
|
141 add_flag_append(CMAKE_C_FLAGS_RELEASE "-O2") |
|
142 add_flag_append(CMAKE_C_FLAGS_DEBUG "-Wextra -O0") |
|
143 add_flag_append(CMAKE_CXX_FLAGS "-Wall -pipe") |
|
144 add_flag_append(CMAKE_CXX_FLAGS_RELEASE "-O2") |
|
145 add_flag_append(CMAKE_CXX_FLAGS_DEBUG "-Wextra -O0") |
|
146 endif() |
125 |
147 |
126 #CMake adds a lot of additional configuration flags, so let's clear them up |
148 #CMake adds a lot of additional configuration flags, so let's clear them up |
127 if(MINIMAL_FLAGS) |
149 if(MINIMAL_FLAGS) |
128 unset(CMAKE_C_FLAGS_RELEASE) |
150 unset(CMAKE_C_FLAGS_RELEASE) |
129 unset(CMAKE_C_FLAGS_DEBUG) |
151 unset(CMAKE_C_FLAGS_DEBUG) |
197 add_subdirectory(misc/liblua) |
219 add_subdirectory(misc/liblua) |
198 endif() |
220 endif() |
199 |
221 |
200 |
222 |
201 #physfs discovery |
223 #physfs discovery |
202 if(PHYSFS_SYSTEM) |
224 if(NOT PHYSFS_LIBRARY OR NOT PHYSFS_INCLUDE_DIR) |
203 if(NOT PHYSFS_LIBRARY OR NOT PHYSFS_INCLUDE_DIR) |
225 find_package(PhysFS) |
204 find_package(PhysFS) |
226 endif() |
205 endif() |
227 |
206 |
228 find_file(physfs_h physfs.h ${PHYSFS_INCLUDE_DIR}) |
207 find_file(physfs_h physfs.h ${PHYSFS_INCLUDE_DIR}) |
229 if(physfs_h) |
208 if(physfs_h) |
230 file(STRINGS ${physfs_h} physfs_majorversion REGEX "PHYSFS_VER_MAJOR[\t' ']+[0-9]+") |
209 file(STRINGS ${physfs_h} physfs_majorversion REGEX "PHYSFS_VER_MAJOR[\t' ']+[0-9]+") |
231 file(STRINGS ${physfs_h} physfs_minorversion REGEX "PHYSFS_VER_MINOR[\t' ']+[0-9]+") |
210 file(STRINGS ${physfs_h} physfs_minorversion REGEX "PHYSFS_VER_MINOR[\t' ']+[0-9]+") |
232 file(STRINGS ${physfs_h} physfs_patchversion REGEX "PHYSFS_VER_PATCH[\t' ']+[0-9]+") |
211 file(STRINGS ${physfs_h} physfs_patchversion REGEX "PHYSFS_VER_PATCH[\t' ']+[0-9]+") |
233 string(REGEX MATCH "([0-9]+)" physfs_majorversion "${physfs_majorversion}") |
212 string(REGEX MATCH "([0-9]+)" physfs_majorversion "${physfs_majorversion}") |
234 string(REGEX MATCH "([0-9]+)" physfs_minorversion "${physfs_minorversion}") |
213 string(REGEX MATCH "([0-9]+)" physfs_minorversion "${physfs_minorversion}") |
235 string(REGEX MATCH "([0-9]+)" physfs_patchversion "${physfs_patchversion}") |
214 string(REGEX MATCH "([0-9]+)" physfs_patchversion "${physfs_patchversion}") |
236 set(physfs_detected_ver "${physfs_majorversion}.${physfs_minorversion}.${physfs_patchversion}") |
215 set(physfs_detected_ver "${physfs_majorversion}.${physfs_minorversion}.${physfs_patchversion}") |
237 |
216 |
238 if(${physfs_detected_ver} VERSION_LESS 3.0.0) |
217 if(${physfs_detected_ver} VERSION_LESS 2.0.0) |
239 message(FATAL_ERROR "PhysFS version is too old (detected ${physfs_detected_ver}, required 3.0.0)\n" |
218 message(FATAL_ERROR "PhysFS version is too old (detected ${physfs_detected_ver}, required 2.0.0)\n" |
240 "Perform an update of PhysFS to fix this.") |
219 "Perform an update or rerun cmake with -DPHYSFS_SYSTEM=off to build the internal version") |
241 endif() |
220 endif() |
242 endif() |
221 endif() |
243 |
222 |
244 if(PHYSFS_LIBRARY AND PHYSFS_INCLUDE_DIR) |
223 if(PHYSFS_LIBRARY AND PHYSFS_INCLUDE_DIR) |
245 #use an IMPORTED tharget so that we can just use 'physfs' to link |
224 #use an IMPORTED tharget so that we can just use 'physfs' to link |
246 add_library(physfs UNKNOWN IMPORTED) |
225 add_library(physfs UNKNOWN IMPORTED) |
247 set_target_properties(physfs PROPERTIES IMPORTED_LOCATION ${PHYSFS_LIBRARY}) |
226 set_target_properties(physfs PROPERTIES IMPORTED_LOCATION ${PHYSFS_LIBRARY}) |
248 else() |
227 else() |
249 message(FATAL_ERROR "Missing PhysFS! Install PhysFS to fix this.") |
228 message(FATAL_ERROR "Missing PhysFS! Rerun cmake with -DPHYSFS_SYSTEM=off to build the internal version") |
|
229 endif() |
|
230 else() |
|
231 if(NOT PHYSFS_LIBRARY OR NOT PHYSFS_INCLUDE_DIR) |
|
232 message(STATUS "PhysFS will be provided by the bundled sources") |
|
233 endif() |
|
234 set(physfs_output_name "hwphysfs") |
|
235 add_subdirectory(misc/libphysfs) |
|
236 endif() |
250 endif() |
237 |
251 |
238 find_package_or_disable_msg(LIBAV NOVIDEOREC "Video recording will not be built") |
252 find_package_or_disable_msg(LIBAV NOVIDEOREC "Video recording will not be built") |
239 |
253 |
240 #physfs helper library |
254 #physfs helper library |