1 cmake_minimum_required(VERSION 2.6)
5 INCLUDE(CheckIncludeFiles)
6 INCLUDE(CheckLibraryExists)
8 # Add custom SemiDebug build mode
9 set(CMAKE_CXX_FLAGS_SEMIDEBUG "-O1 -g -Wall" CACHE STRING
10 "Flags used by the C++ compiler during semidebug builds."
13 set(CMAKE_C_FLAGS_SEMIDEBUG "-O1 -g -Wall -pedantic" CACHE STRING
14 "Flags used by the C compiler during semidebug builds."
18 CMAKE_CXX_FLAGS_SEMIDEBUG
19 CMAKE_C_FLAGS_SEMIDEBUG
21 set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
22 "Choose the type of build. Options are: None Debug SemiDebug RelWithDebInfo MinSizeRel."
27 # Set some random things default to not being visible in the GUI
28 mark_as_advanced(EXECUTABLE_OUTPUT_PATH LIBRARY_OUTPUT_PATH)
31 if(NOT (BUILD_CLIENT OR BUILD_SERVER))
32 message(WARNING "Neither BUILD_CLIENT nor BUILD_SERVER is set! Setting BUILD_SERVER=true")
33 set(BUILD_SERVER TRUE)
37 option(ENABLE_CURL "Enable cURL support for fetching media" TRUE)
43 message(STATUS "cURL support enabled.")
47 mark_as_advanced(CLEAR CURL_LIBRARY CURL_INCLUDE_DIR)
52 message(WARNING "cURL is required to load the server list")
55 message(WARNING "cURL is required to announce to the server list")
60 option(ENABLE_GETTEXT "Use GetText for internationalization" TRUE)
61 set(USE_GETTEXT FALSE)
64 find_package(GettextLib)
67 message(STATUS "GetText library: ${GETTEXT_LIBRARY}")
68 message(STATUS "GetText DLL: ${GETTEXT_DLL}")
69 message(STATUS "GetText iconv DLL: ${GETTEXT_ICONV_DLL}")
72 message(STATUS "GetText enabled; locales found: ${GETTEXT_AVAILABLE_LOCALES}")
73 endif(GETTEXTLIB_FOUND)
75 mark_as_advanced(GETTEXT_ICONV_DLL GETTEXT_INCLUDE_DIR GETTEXT_LIBRARY GETTEXT_MSGFMT)
76 message(STATUS "GetText disabled.")
80 option(ENABLE_SOUND "Enable sound" TRUE)
83 if(BUILD_CLIENT AND ENABLE_SOUND)
88 message(STATUS "Sound enabled, but OpenAL not found!")
89 mark_as_advanced(CLEAR OPENAL_LIBRARY OPENAL_INCLUDE_DIR)
92 message(STATUS "Sound enabled, but Vorbis libraries not found!")
93 mark_as_advanced(CLEAR OGG_INCLUDE_DIR VORBIS_INCLUDE_DIR OGG_LIBRARY VORBIS_LIBRARY VORBISFILE_LIBRARY)
95 if(OPENAL_FOUND AND VORBIS_FOUND)
97 message(STATUS "Sound enabled.")
99 message(FATAL_ERROR "Sound enabled, but cannot be used.\n"
100 "To continue, either fill in the required paths or disable sound. (-DENABLE_SOUND=0)")
105 option(ENABLE_GLES "Use OpenGL ES instead of OpenGL" FALSE)
106 mark_as_advanced(ENABLE_GLES)
109 find_package(OpenGLES2 REQUIRED)
111 # transitive dependency from Irrlicht (see longer explanation below)
113 set(OPENGL_GL_PREFERENCE "LEGACY" CACHE STRING
114 "See CMake Policy CMP0072 for reference. GLVND is broken on some nvidia setups")
115 set(OpenGL_GL_PREFERENCE ${OPENGL_GL_PREFERENCE})
117 find_package(OpenGL REQUIRED)
123 option(ENABLE_FREETYPE "Enable FreeType2 (TrueType fonts and basic unicode support)" TRUE)
124 set(USE_FREETYPE FALSE)
128 ## Note: FindFreetype.cmake seems to have been fixed in recent versions of
129 ## CMake. If issues persist, re-enable this workaround specificially for the
130 ## failing platforms.
133 # include(FindPkgConfig)
134 # if(PKG_CONFIG_FOUND)
135 # pkg_check_modules(FREETYPE QUIET freetype2)
137 # SET(FREETYPE_PKGCONFIG_FOUND TRUE)
138 # SET(FREETYPE_LIBRARY ${FREETYPE_LIBRARIES})
139 # # Because CMake is idiotic
140 # string(REPLACE ";" " " FREETYPE_CFLAGS_STR ${FREETYPE_CFLAGS})
141 # string(REPLACE ";" " " FREETYPE_LDFLAGS_STR ${FREETYPE_LDFLAGS})
142 # endif(FREETYPE_FOUND)
143 # endif(PKG_CONFIG_FOUND)
145 # if(NOT FREETYPE_FOUND)
146 # find_package(Freetype)
148 find_package(Freetype)
150 message(STATUS "Freetype enabled.")
151 set(USE_FREETYPE TRUE)
153 endif(ENABLE_FREETYPE)
155 option(ENABLE_CURSES "Enable ncurses console" TRUE)
156 set(USE_CURSES FALSE)
159 find_package(Ncursesw)
162 message(STATUS "ncurses console enabled.")
163 include_directories(${CURSES_INCLUDE_DIRS})
165 message(STATUS "ncurses not found!")
169 option(ENABLE_POSTGRESQL "Enable PostgreSQL backend" TRUE)
170 set(USE_POSTGRESQL FALSE)
172 if(ENABLE_POSTGRESQL)
173 find_package("PostgreSQL")
176 set(USE_POSTGRESQL TRUE)
177 message(STATUS "PostgreSQL backend enabled")
178 # This variable is case sensitive, don't try to change it to POSTGRESQL_INCLUDE_DIR
179 message(STATUS "PostgreSQL includes: ${PostgreSQL_INCLUDE_DIRS}")
180 include_directories(${PostgreSQL_INCLUDE_DIRS})
182 message(STATUS "PostgreSQL not found!")
184 endif(ENABLE_POSTGRESQL)
186 option(ENABLE_LEVELDB "Enable LevelDB backend" TRUE)
187 set(USE_LEVELDB FALSE)
190 find_library(LEVELDB_LIBRARY NAMES leveldb libleveldb)
191 find_path(LEVELDB_INCLUDE_DIR db.h PATH_SUFFIXES leveldb)
192 if(LEVELDB_LIBRARY AND LEVELDB_INCLUDE_DIR)
193 set(USE_LEVELDB TRUE)
194 message(STATUS "LevelDB backend enabled.")
195 include_directories(${LEVELDB_INCLUDE_DIR})
197 message(STATUS "LevelDB not found!")
199 endif(ENABLE_LEVELDB)
202 OPTION(ENABLE_REDIS "Enable Redis backend" TRUE)
206 find_library(REDIS_LIBRARY hiredis)
207 find_path(REDIS_INCLUDE_DIR hiredis.h PATH_SUFFIXES hiredis)
208 if(REDIS_LIBRARY AND REDIS_INCLUDE_DIR)
210 message(STATUS "Redis backend enabled.")
211 include_directories(${REDIS_INCLUDE_DIR})
212 else(REDIS_LIBRARY AND REDIS_INCLUDE_DIR)
213 message(STATUS "Redis not found!")
214 endif(REDIS_LIBRARY AND REDIS_INCLUDE_DIR)
218 find_package(SQLite3 REQUIRED)
220 OPTION(ENABLE_PROMETHEUS "Enable prometheus client support" FALSE)
221 set(USE_PROMETHEUS FALSE)
223 if(ENABLE_PROMETHEUS)
224 find_path(PROMETHEUS_CPP_INCLUDE_DIR NAMES prometheus/counter.h)
225 find_library(PROMETHEUS_PULL_LIBRARY NAMES prometheus-cpp-pull)
226 find_library(PROMETHEUS_CORE_LIBRARY NAMES prometheus-cpp-core)
227 if(PROMETHEUS_CPP_INCLUDE_DIR AND PROMETHEUS_PULL_LIBRARY AND PROMETHEUS_CORE_LIBRARY)
228 set(PROMETHEUS_LIBRARIES ${PROMETHEUS_PULL_LIBRARY} ${PROMETHEUS_CORE_LIBRARY})
229 set(USE_PROMETHEUS TRUE)
230 include_directories(${PROMETHEUS_CPP_INCLUDE_DIR})
231 endif(PROMETHEUS_CPP_INCLUDE_DIR AND PROMETHEUS_PULL_LIBRARY AND PROMETHEUS_CORE_LIBRARY)
232 endif(ENABLE_PROMETHEUS)
235 message(STATUS "Prometheus client enabled.")
237 message(STATUS "Prometheus client disabled.")
238 endif(USE_PROMETHEUS)
240 OPTION(ENABLE_SPATIAL "Enable SpatialIndex AreaStore backend" TRUE)
241 set(USE_SPATIAL FALSE)
244 find_library(SPATIAL_LIBRARY spatialindex)
245 find_path(SPATIAL_INCLUDE_DIR spatialindex/SpatialIndex.h)
246 if(SPATIAL_LIBRARY AND SPATIAL_INCLUDE_DIR)
247 set(USE_SPATIAL TRUE)
248 message(STATUS "SpatialIndex AreaStore backend enabled.")
249 include_directories(${SPATIAL_INCLUDE_DIR})
250 else(SPATIAL_LIBRARY AND SPATIAL_INCLUDE_DIR)
251 message(STATUS "SpatialIndex not found!")
252 endif(SPATIAL_LIBRARY AND SPATIAL_INCLUDE_DIR)
253 endif(ENABLE_SPATIAL)
257 set(USE_GPROF FALSE CACHE BOOL "Use -pg flag for g++")
260 # Haiku endian support
262 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_BSD_SOURCE")
263 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_BSD_SOURCE")
267 add_definitions(-DUSE_CMAKE_CONFIG_H)
271 if(MSVC) # MSVC Specifics
272 set(PLATFORM_LIBS dbghelp.lib ${PLATFORM_LIBS})
273 # Surpress some useless warnings
274 add_definitions ( /D "_CRT_SECURE_NO_DEPRECATE" /W1 )
276 add_definitions(/D "_USE_MATH_DEFINES")
277 # Dont define min/max macros in minwindef.h
278 add_definitions(/D "NOMINMAX")
279 else() # Probably MinGW = GCC
280 set(PLATFORM_LIBS "")
282 set(PLATFORM_LIBS ws2_32.lib version.lib shlwapi.lib ${PLATFORM_LIBS})
285 find_path(ZLIB_INCLUDE_DIR "zlib.h" DOC "Zlib include directory")
286 find_library(ZLIB_LIBRARIES "zlib" DOC "Path to zlib library")
288 # Dll's are automatically copied to the output directory by vcpkg when VCPKG_APPLOCAL_DEPS=ON
289 if(NOT VCPKG_APPLOCAL_DEPS)
290 find_file(ZLIB_DLL NAMES "zlib.dll" "zlib1.dll" DOC "Path to zlib.dll for installation (optional)")
292 set(OPENAL_DLL "" CACHE FILEPATH "Path to OpenAL32.dll for installation (optional)")
293 set(OGG_DLL "" CACHE FILEPATH "Path to libogg.dll for installation (optional)")
294 set(VORBIS_DLL "" CACHE FILEPATH "Path to libvorbis.dll for installation (optional)")
295 set(VORBISFILE_DLL "" CACHE FILEPATH "Path to libvorbisfile.dll for installation (optional)")
298 set(LUA_DLL "" CACHE FILEPATH "Path to luajit-5.1.dll for installation (optional)")
305 if(NOT HAIKU AND NOT APPLE)
306 find_package(X11 REQUIRED)
307 endif(NOT HAIKU AND NOT APPLE)
310 # The following dependencies are transitive dependencies from Irrlicht.
311 # Minetest itself does not use them, but we link them so that statically
312 # linking Irrlicht works.
313 if(NOT HAIKU AND NOT APPLE)
314 # This way Xxf86vm is found on OpenBSD too
315 find_library(XXF86VM_LIBRARY Xxf86vm)
316 mark_as_advanced(XXF86VM_LIBRARY)
317 set(CLIENT_PLATFORM_LIBS ${CLIENT_PLATFORM_LIBS} ${XXF86VM_LIBRARY})
318 endif(NOT HAIKU AND NOT APPLE)
320 find_package(JPEG REQUIRED)
321 find_package(BZip2 REQUIRED)
322 find_package(PNG REQUIRED)
324 find_library(CARBON_LIB Carbon REQUIRED)
325 find_library(COCOA_LIB Cocoa REQUIRED)
326 find_library(IOKIT_LIB IOKit REQUIRED)
332 SET(CLIENT_PLATFORM_LIBS ${CLIENT_PLATFORM_LIBS} ${CARBON_LIB} ${COCOA_LIB} ${IOKIT_LIB})
337 find_package(ZLIB REQUIRED)
338 set(PLATFORM_LIBS -lpthread ${CMAKE_DL_LIBS})
340 set(PLATFORM_LIBS "-framework CoreFoundation" ${PLATFORM_LIBS})
342 check_library_exists(rt clock_gettime "" HAVE_LIBRT)
344 set(PLATFORM_LIBS -lrt ${PLATFORM_LIBS})
348 # Prefer local iconv if installed
349 find_library(ICONV_LIBRARY iconv)
350 mark_as_advanced(ICONV_LIBRARY)
352 set(PLATFORM_LIBS ${PLATFORM_LIBS} ${ICONV_LIBRARY})
355 set(PLATFORM_LIBS ${PLATFORM_LIBS} intl network)
360 check_include_files(endian.h HAVE_ENDIAN_H)
363 "${PROJECT_SOURCE_DIR}/cmake_config.h.in"
364 "${PROJECT_BINARY_DIR}/cmake_config.h"
368 # Add a target that always rebuilds cmake_config_githash.h
369 add_custom_target(GenerateVersion
370 COMMAND ${CMAKE_COMMAND}
371 -D "GENERATE_VERSION_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}"
372 -D "GENERATE_VERSION_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}"
373 -D "VERSION_STRING=${VERSION_STRING}"
374 -D "DEVELOPMENT_BUILD=${DEVELOPMENT_BUILD}"
375 -P "${CMAKE_SOURCE_DIR}/cmake/Modules/GenerateVersion.cmake"
376 WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
379 add_subdirectory(threading)
380 add_subdirectory(content)
381 add_subdirectory(database)
382 add_subdirectory(gui)
383 add_subdirectory(mapgen)
384 add_subdirectory(network)
385 add_subdirectory(script)
386 add_subdirectory(unittest)
387 add_subdirectory(util)
388 add_subdirectory(irrlicht_changes)
389 add_subdirectory(server)
408 face_position_cache.cpp
416 itemstackmetadata.cpp
421 map_settings_manager.cpp
433 object_properties.cpp
443 rollback_interface.cpp
446 serverenvironment.cpp
450 terminal_chat_console.cpp
459 ${common_network_SRCS}
461 ${common_SCRIPT_SRCS}
466 set(common_SRCS ${common_SRCS} ${UNITTEST_SRCS})
470 # This gives us the icon and file version information
472 set(WINRESOURCE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/../misc/winresource.rc")
473 set(MINETEST_EXE_MANIFEST_FILE "${CMAKE_CURRENT_SOURCE_DIR}/../misc/minetest.exe.manifest")
475 if(NOT CMAKE_RC_COMPILER)
476 set(CMAKE_RC_COMPILER "windres.exe")
478 ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/winresource_rc.o
479 COMMAND ${CMAKE_RC_COMPILER} -I${CMAKE_CURRENT_SOURCE_DIR} -I${CMAKE_CURRENT_BINARY_DIR}
480 -i${WINRESOURCE_FILE}
481 -o ${CMAKE_CURRENT_BINARY_DIR}/winresource_rc.o
482 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
483 DEPENDS ${WINRESOURCE_FILE} ${MINETEST_EXE_MANIFEST_FILE})
484 SET(extra_windows_SRCS ${CMAKE_CURRENT_BINARY_DIR}/winresource_rc.o)
485 else(MINGW) # Probably MSVC
486 set(extra_windows_SRCS ${WINRESOURCE_FILE} ${MINETEST_EXE_MANIFEST_FILE})
493 add_subdirectory(client)
500 ${client_network_SRCS}
501 ${client_irrlicht_changes_SRCS}
502 ${client_SCRIPT_SRCS}
506 set(client_SRCS ${client_SRCS} ${UNITTEST_CLIENT_SRCS})
509 list(SORT client_SRCS)
515 list(SORT server_SRCS)
517 # Avoid source_group on broken CMake version.
518 # see issue #7074 #7075
519 if (CMAKE_VERSION VERSION_GREATER 3.8.1)
520 source_group(TREE ${PROJECT_SOURCE_DIR} PREFIX "Source Files" FILES ${client_SRCS})
521 source_group(TREE ${PROJECT_SOURCE_DIR} PREFIX "Source Files" FILES ${server_SRCS})
525 ${PROJECT_BINARY_DIR}
526 ${PROJECT_SOURCE_DIR}
527 ${IRRLICHT_INCLUDE_DIR}
530 ${SOUND_INCLUDE_DIRS}
531 ${SQLITE3_INCLUDE_DIR}
536 ${PROJECT_SOURCE_DIR}/script
540 include_directories(${GETTEXT_INCLUDE_DIR})
544 include_directories(${FREETYPE_INCLUDE_DIRS})
548 include_directories(${CURL_INCLUDE_DIR})
552 set(EXECUTABLE_OUTPUT_PATH "${CMAKE_SOURCE_DIR}/bin")
556 add_executable(${PROJECT_NAME} ${client_SRCS} ${extra_windows_SRCS})
557 add_dependencies(${PROJECT_NAME} GenerateVersion)
572 ${CLIENT_PLATFORM_LIBS}
574 target_link_libraries(
578 target_link_libraries(
580 ${OPENGLES2_LIBRARIES}
584 target_link_libraries(
590 target_link_libraries(
596 target_link_libraries(
602 if(FREETYPE_PKGCONFIG_FOUND)
603 set_target_properties(${PROJECT_NAME}
605 COMPILE_FLAGS "${FREETYPE_CFLAGS_STR}"
608 target_link_libraries(
614 target_link_libraries(${PROJECT_NAME} ${CURSES_LIBRARIES})
617 target_link_libraries(${PROJECT_NAME} ${PostgreSQL_LIBRARIES})
620 target_link_libraries(${PROJECT_NAME} ${LEVELDB_LIBRARY})
623 target_link_libraries(${PROJECT_NAME} ${REDIS_LIBRARY})
626 target_link_libraries(${PROJECT_NAME} ${PROMETHEUS_LIBRARIES})
629 target_link_libraries(${PROJECT_NAME} ${SPATIAL_LIBRARY})
635 add_executable(${PROJECT_NAME}server ${server_SRCS} ${extra_windows_SRCS})
636 add_dependencies(${PROJECT_NAME}server GenerateVersion)
637 target_link_libraries(
638 ${PROJECT_NAME}server
646 set_target_properties(${PROJECT_NAME}server PROPERTIES
647 COMPILE_DEFINITIONS "SERVER")
649 target_link_libraries(${PROJECT_NAME}server ${GETTEXT_LIBRARY})
652 target_link_libraries(${PROJECT_NAME}server ${CURSES_LIBRARIES})
655 target_link_libraries(${PROJECT_NAME}server ${PostgreSQL_LIBRARIES})
658 target_link_libraries(${PROJECT_NAME}server ${LEVELDB_LIBRARY})
661 target_link_libraries(${PROJECT_NAME}server ${REDIS_LIBRARY})
664 target_link_libraries(${PROJECT_NAME}server ${PROMETHEUS_LIBRARIES})
667 target_link_libraries(${PROJECT_NAME}server ${SPATIAL_LIBRARY})
670 target_link_libraries(
671 ${PROJECT_NAME}server
677 # Blacklisted locales that don't work.
679 set(GETTEXT_BLACKLISTED_LOCALES
687 option(APPLY_LOCALE_BLACKLIST "Use a blacklist to avoid broken locales" TRUE)
689 if (GETTEXTLIB_FOUND AND APPLY_LOCALE_BLACKLIST)
690 set(GETTEXT_USED_LOCALES "")
691 foreach(LOCALE ${GETTEXT_AVAILABLE_LOCALES})
692 if (NOT ";${GETTEXT_BLACKLISTED_LOCALES};" MATCHES ";${LOCALE};")
693 list(APPEND GETTEXT_USED_LOCALES ${LOCALE})
696 message(STATUS "Locale blacklist applied; Locales used: ${GETTEXT_USED_LOCALES}")
699 # Set some optimizations and tweaks
701 include(CheckCSourceCompiles)
705 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D WIN32_LEAN_AND_MEAN")
706 # EHa enables SEH exceptions (used for catching segfaults)
707 set(CMAKE_CXX_FLAGS_RELEASE "/EHa /Ox /MD /GS- /Zi /fp:fast /D NDEBUG /D _HAS_ITERATOR_DEBUGGING=0")
708 if(CMAKE_SIZEOF_VOID_P EQUAL 4)
709 set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /arch:SSE")
712 set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/INCREMENTAL:NO /DEBUG /OPT:REF /OPT:ICF /SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup")
714 set(CMAKE_CXX_FLAGS_SEMIDEBUG "/MDd /Zi /Ob0 /O1 /RTC1")
716 # Debug build doesn't catch exceptions by itself
717 # Add some optimizations because otherwise it's VERY slow
718 set(CMAKE_CXX_FLAGS_DEBUG "/MDd /Zi /Ob0 /Od /RTC1")
720 # Flags for C files (sqlite)
721 # /MD = dynamically link to MSVCRxxx.dll
722 set(CMAKE_C_FLAGS_RELEASE "/O2 /Ob2 /MD")
724 # Flags that cannot be shared between cl and clang-cl
725 # https://clang.llvm.org/docs/UsersManual.html#clang-cl
726 if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
727 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-ld=lld")
729 # Disable pragma-pack warning
730 set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wno-pragma-pack")
732 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
733 set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /TP /FD /GL")
734 set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG")
737 # GCC or compatible compilers such as Clang
738 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
740 set(RELEASE_WARNING_FLAGS "-Wall")
742 set(RELEASE_WARNING_FLAGS "")
744 if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
745 set(WARNING_FLAGS "${WARNING_FLAGS} -Wsign-compare")
748 if(APPLE AND USE_LUAJIT)
749 # required per http://luajit.org/install.html
750 SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pagezero_size 10000 -image_base 100000000")
751 elseif(UNIX AND USE_LUAJIT)
752 check_c_source_compiles("#ifndef __aarch64__\n#error\n#endif\nint main(){}" IS_AARCH64)
754 # Move text segment below LuaJIT's 47-bit limit (see issue #9367)
755 SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-Ttext-segment=0x200000000")
760 set(OTHER_FLAGS "${OTHER_FLAGS} -mthreads -fexceptions")
761 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWIN32_LEAN_AND_MEAN")
764 # Use a safe subset of flags to speed up math calculations:
765 # - we don't need errno or math exceptions
766 # - we don't deal with Inf/NaN or signed zero
767 set(MATH_FLAGS "-fno-math-errno -fno-trapping-math -ffinite-math-only -fno-signed-zeros")
769 set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG ${RELEASE_WARNING_FLAGS} ${WARNING_FLAGS} ${OTHER_FLAGS} -Wall -pipe -funroll-loops")
770 if(CMAKE_SYSTEM_NAME MATCHES "(Darwin|BSD|DragonFly)")
771 set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Os")
773 set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -fomit-frame-pointer")
774 if(CMAKE_SYSTEM_NAME STREQUAL "Linux"
775 AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang"
776 AND CMAKE_CXX_COMPILER_VERSION MATCHES "^9\\.")
777 # Clang 9 has broken -ffast-math on glibc
779 set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${MATH_FLAGS}")
781 endif(CMAKE_SYSTEM_NAME MATCHES "(Darwin|BSD|DragonFly)")
782 set(CMAKE_CXX_FLAGS_SEMIDEBUG "-g -O1 -Wall ${WARNING_FLAGS} ${OTHER_FLAGS}")
783 set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall ${WARNING_FLAGS} ${OTHER_FLAGS}")
786 set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pg")
790 set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -mwindows")
798 if(VCPKG_APPLOCAL_DEPS)
799 # Collect the dll's from the output path
800 install(DIRECTORY ${EXECUTABLE_OUTPUT_PATH}/Release/
801 DESTINATION ${BINDIR}
802 CONFIGURATIONS Release
803 FILES_MATCHING PATTERN "*.dll")
804 install(DIRECTORY ${EXECUTABLE_OUTPUT_PATH}/Debug/
805 DESTINATION ${BINDIR}
807 FILES_MATCHING PATTERN "*.dll")
808 install(DIRECTORY ${EXECUTABLE_OUTPUT_PATH}/RelWithDebInfo/
809 DESTINATION ${BINDIR}
810 CONFIGURATIONS RelWithDebInfo
811 FILES_MATCHING PATTERN "*.dll")
812 install(DIRECTORY ${EXECUTABLE_OUTPUT_PATH}/MinSizeRel/
813 DESTINATION ${BINDIR}
814 CONFIGURATIONS MinSizeRel
815 FILES_MATCHING PATTERN "*.dll")
817 # Use the old-style way to install dll's
820 install(FILES ${OPENAL_DLL} DESTINATION ${BINDIR})
823 install(FILES ${OGG_DLL} DESTINATION ${BINDIR})
826 install(FILES ${VORBIS_DLL} DESTINATION ${BINDIR})
829 install(FILES ${VORBISFILE_DLL} DESTINATION ${BINDIR})
833 install(FILES ${CURL_DLL} DESTINATION ${BINDIR})
836 install(FILES ${ZLIB_DLL} DESTINATION ${BINDIR})
839 install(FILES ${FREETYPE_DLL} DESTINATION ${BINDIR})
842 install(FILES ${SQLITE3_DLL} DESTINATION ${BINDIR})
845 install(FILES ${LEVELDB_DLL} DESTINATION ${BINDIR})
848 install(FILES ${LUA_DLL} DESTINATION ${BINDIR})
854 install(TARGETS ${PROJECT_NAME}
855 RUNTIME DESTINATION ${BINDIR}
856 LIBRARY DESTINATION ${BINDIR}
857 ARCHIVE DESTINATION ${BINDIR}
863 set(BU_CHMOD_BUNDLE_ITEMS ON)
864 include(BundleUtilities)
865 fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/${BUNDLE_PATH}\" \"\" \"\${CMAKE_INSTALL_PREFIX}/${BINDIR}\")
870 foreach(LOCALE ${GETTEXT_USED_LOCALES})
871 set_mo_paths(MO_BUILD_PATH MO_DEST_PATH ${LOCALE})
872 set(MO_BUILD_PATH "${MO_BUILD_PATH}/${PROJECT_NAME}.mo")
873 install(FILES ${MO_BUILD_PATH} DESTINATION ${MO_DEST_PATH})
878 install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../fonts" DESTINATION "${SHAREDIR}"
879 FILES_MATCHING PATTERN "*.ttf" PATTERN "*.txt")
881 install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../fonts" DESTINATION "${SHAREDIR}"
882 FILES_MATCHING PATTERN "*.png" PATTERN "*.xml")
886 if(NOT VCPKG_APPLOCAL_DEPS)
887 if(DEFINED IRRLICHT_DLL)
888 install(FILES ${IRRLICHT_DLL} DESTINATION ${BINDIR})
891 if(DEFINED GETTEXT_DLL)
892 install(FILES ${GETTEXT_DLL} DESTINATION ${BINDIR})
894 if(DEFINED GETTEXT_ICONV_DLL)
895 install(FILES ${GETTEXT_ICONV_DLL} DESTINATION ${BINDIR})
903 install(TARGETS ${PROJECT_NAME}server DESTINATION ${BINDIR})
909 foreach(LOCALE ${GETTEXT_USED_LOCALES})
910 set(PO_FILE_PATH "${GETTEXT_PO_PATH}/${LOCALE}/${PROJECT_NAME}.po")
911 set_mo_paths(MO_BUILD_PATH MO_DEST_PATH ${LOCALE})
912 set(MO_FILE_PATH "${MO_BUILD_PATH}/${PROJECT_NAME}.mo")
914 add_custom_command(OUTPUT ${MO_BUILD_PATH}
915 COMMAND ${CMAKE_COMMAND} -E make_directory ${MO_BUILD_PATH}
916 COMMENT "mo-update [${LOCALE}]: Creating locale directory.")
919 OUTPUT ${MO_FILE_PATH}
920 COMMAND ${GETTEXT_MSGFMT} -o ${MO_FILE_PATH} ${PO_FILE_PATH}
921 DEPENDS ${MO_BUILD_PATH} ${PO_FILE_PATH}
922 WORKING_DIRECTORY "${GETTEXT_PO_PATH}/${LOCALE}"
923 COMMENT "mo-update [${LOCALE}]: Creating mo file."
926 set(MO_FILES ${MO_FILES} ${MO_FILE_PATH})
929 add_custom_target(translations ALL COMMENT "mo update" DEPENDS ${MO_FILES})