X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2FCMakeLists.txt;h=b8ce69f1d71880fc1d74fccd426afd861093d070;hb=78273027bf4bbee7488c76c6d65f85381ec7c0ba;hp=0ebbd628ce79bb9612e6d573aa1ad3c8237cf7a0;hpb=5146086a64d5eeb480948d612a008a2ec81455d4;p=minetest.git diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0ebbd628c..b8ce69f1d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,7 +6,7 @@ INCLUDE(CheckIncludeFiles) INCLUDE(CheckLibraryExists) # Add custom SemiDebug build mode -set(CMAKE_CXX_FLAGS_SEMIDEBUG "-O1 -g -Wall -Wabi" CACHE STRING +set(CMAKE_CXX_FLAGS_SEMIDEBUG "-O1 -g -Wall" CACHE STRING "Flags used by the C++ compiler during semidebug builds." FORCE ) @@ -62,7 +62,7 @@ set(USE_GETTEXT FALSE) if(ENABLE_GETTEXT) find_package(GettextLib) - if(GETTEXT_FOUND) + if(GETTEXTLIB_FOUND) if(WIN32) message(STATUS "GetText library: ${GETTEXT_LIBRARY}") message(STATUS "GetText DLL: ${GETTEXT_DLL}") @@ -70,7 +70,7 @@ if(ENABLE_GETTEXT) endif() set(USE_GETTEXT TRUE) message(STATUS "GetText enabled; locales found: ${GETTEXT_AVAILABLE_LOCALES}") - endif(GETTEXT_FOUND) + endif(GETTEXTLIB_FOUND) else() mark_as_advanced(GETTEXT_ICONV_DLL GETTEXT_INCLUDE_DIR GETTEXT_LIBRARY GETTEXT_MSGFMT) message(STATUS "GetText disabled.") @@ -217,6 +217,26 @@ endif(ENABLE_REDIS) find_package(SQLite3 REQUIRED) +OPTION(ENABLE_PROMETHEUS "Enable prometheus client support" FALSE) +set(USE_PROMETHEUS FALSE) + +if(ENABLE_PROMETHEUS) + find_path(PROMETHEUS_CPP_INCLUDE_DIR NAMES prometheus/counter.h) + find_library(PROMETHEUS_PULL_LIBRARY NAMES prometheus-cpp-pull) + find_library(PROMETHEUS_CORE_LIBRARY NAMES prometheus-cpp-core) + if(PROMETHEUS_CPP_INCLUDE_DIR AND PROMETHEUS_PULL_LIBRARY AND PROMETHEUS_CORE_LIBRARY) + set(PROMETHEUS_LIBRARIES ${PROMETHEUS_PULL_LIBRARY} ${PROMETHEUS_CORE_LIBRARY}) + set(USE_PROMETHEUS TRUE) + include_directories(${PROMETHEUS_CPP_INCLUDE_DIR}) + endif(PROMETHEUS_CPP_INCLUDE_DIR AND PROMETHEUS_PULL_LIBRARY AND PROMETHEUS_CORE_LIBRARY) +endif(ENABLE_PROMETHEUS) + +if(USE_PROMETHEUS) + message(STATUS "Prometheus client enabled.") +else(USE_PROMETHEUS) + message(STATUS "Prometheus client disabled.") +endif(USE_PROMETHEUS) + OPTION(ENABLE_SPATIAL "Enable SpatialIndex AreaStore backend" TRUE) set(USE_SPATIAL FALSE) @@ -331,6 +351,10 @@ else() if (ICONV_LIBRARY) set(PLATFORM_LIBS ${PLATFORM_LIBS} ${ICONV_LIBRARY}) endif() + if (HAIKU) + set(PLATFORM_LIBS ${PLATFORM_LIBS} intl network) + endif() + endif() check_include_files(endian.h HAVE_ENDIAN_H) @@ -407,6 +431,7 @@ set(common_SRCS noise.cpp objdef.cpp object_properties.cpp + particles.cpp pathfinder.cpp player.cpp porting.cpp @@ -423,6 +448,7 @@ set(common_SRCS settings.cpp staticobject.cpp terminal_chat_console.cpp + texture_override.cpp tileanimation.cpp tool.cpp translation.cpp @@ -434,9 +460,12 @@ set(common_SRCS ${JTHREAD_SRCS} ${common_SCRIPT_SRCS} ${UTIL_SRCS} - ${UNITTEST_SRCS} ) +if(BUILD_UNITTESTS) + set(common_SRCS ${common_SRCS} ${UNITTEST_SRCS}) +endif() + # This gives us the icon and file version information if(WIN32) @@ -451,7 +480,7 @@ if(WIN32) -i${WINRESOURCE_FILE} -o ${CMAKE_CURRENT_BINARY_DIR}/winresource_rc.o WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - DEPENDS ${WINRESOURCE_FILE}) + DEPENDS ${WINRESOURCE_FILE} ${MINETEST_EXE_MANIFEST_FILE}) SET(extra_windows_SRCS ${CMAKE_CURRENT_BINARY_DIR}/winresource_rc.o) else(MINGW) # Probably MSVC set(extra_windows_SRCS ${WINRESOURCE_FILE} ${MINETEST_EXE_MANIFEST_FILE}) @@ -471,8 +500,12 @@ set(client_SRCS ${client_network_SRCS} ${client_irrlicht_changes_SRCS} ${client_SCRIPT_SRCS} - ${UNITTEST_CLIENT_SRCS} ) + +if(BUILD_UNITTESTS) + set(client_SRCS ${client_SRCS} ${UNITTEST_CLIENT_SRCS}) +endif() + list(SORT client_SRCS) # Server sources @@ -589,6 +622,9 @@ if(BUILD_CLIENT) if (USE_REDIS) target_link_libraries(${PROJECT_NAME} ${REDIS_LIBRARY}) endif() + if (USE_PROMETHEUS) + target_link_libraries(${PROJECT_NAME} ${PROMETHEUS_LIBRARIES}) + endif() if (USE_SPATIAL) target_link_libraries(${PROJECT_NAME} ${SPATIAL_LIBRARY}) endif() @@ -624,6 +660,9 @@ if(BUILD_SERVER) if (USE_REDIS) target_link_libraries(${PROJECT_NAME}server ${REDIS_LIBRARY}) endif() + if (USE_PROMETHEUS) + target_link_libraries(${PROJECT_NAME}server ${PROMETHEUS_LIBRARIES}) + endif() if (USE_SPATIAL) target_link_libraries(${PROJECT_NAME}server ${SPATIAL_LIBRARY}) endif() @@ -638,15 +677,16 @@ endif(BUILD_SERVER) # Blacklisted locales that don't work. # see issue #4638 set(GETTEXT_BLACKLISTED_LOCALES - be + ar he - ko ky + ms_Arab + th ) option(APPLY_LOCALE_BLACKLIST "Use a blacklist to avoid broken locales" TRUE) -if (GETTEXT_FOUND AND APPLY_LOCALE_BLACKLIST) +if (GETTEXTLIB_FOUND AND APPLY_LOCALE_BLACKLIST) set(GETTEXT_USED_LOCALES "") foreach(LOCALE ${GETTEXT_AVAILABLE_LOCALES}) if (NOT ";${GETTEXT_BLACKLISTED_LOCALES};" MATCHES ";${LOCALE};") @@ -662,18 +702,14 @@ include(CheckCSourceCompiles) if(MSVC) # Visual Studio - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D WIN32_LEAN_AND_MEAN /MP") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D WIN32_LEAN_AND_MEAN") # EHa enables SEH exceptions (used for catching segfaults) - set(CMAKE_CXX_FLAGS_RELEASE "/EHa /Ox /GL /FD /MD /GS- /Zi /fp:fast /D NDEBUG /D _HAS_ITERATOR_DEBUGGING=0 /TP") + set(CMAKE_CXX_FLAGS_RELEASE "/EHa /Ox /MD /GS- /Zi /fp:fast /D NDEBUG /D _HAS_ITERATOR_DEBUGGING=0") if(CMAKE_SIZEOF_VOID_P EQUAL 4) set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /arch:SSE") endif() - #set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/LTCG /NODEFAULTLIB:\"libcmtd.lib\" /NODEFAULTLIB:\"libcmt.lib\"") - set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/LTCG /INCREMENTAL:NO /DEBUG /OPT:REF /OPT:ICF") - - - set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup") + set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/INCREMENTAL:NO /DEBUG /OPT:REF /OPT:ICF /SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup") set(CMAKE_CXX_FLAGS_SEMIDEBUG "/MDd /Zi /Ob0 /O1 /RTC1") @@ -684,6 +720,19 @@ if(MSVC) # Flags for C files (sqlite) # /MD = dynamically link to MSVCRxxx.dll set(CMAKE_C_FLAGS_RELEASE "/O2 /Ob2 /MD") + + # Flags that cannot be shared between cl and clang-cl + # https://clang.llvm.org/docs/UsersManual.html#clang-cl + if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-ld=lld") + + # Disable pragma-pack warning + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wno-pragma-pack") + else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /TP /FD /GL") + set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG") + endif() else() # GCC or compatible compilers such as Clang set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") @@ -712,6 +761,11 @@ else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWIN32_LEAN_AND_MEAN") endif() + # Use a safe subset of flags to speed up math calculations: + # - we don't need errno or math exceptions + # - we don't deal with Inf/NaN or signed zero + set(MATH_FLAGS "-fno-math-errno -fno-trapping-math -ffinite-math-only -fno-signed-zeros") + set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG ${RELEASE_WARNING_FLAGS} ${WARNING_FLAGS} ${OTHER_FLAGS} -Wall -pipe -funroll-loops") if(CMAKE_SYSTEM_NAME MATCHES "(Darwin|BSD|DragonFly)") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Os") @@ -722,11 +776,11 @@ else() AND CMAKE_CXX_COMPILER_VERSION MATCHES "^9\\.") # Clang 9 has broken -ffast-math on glibc else() - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ffast-math") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${MATH_FLAGS}") endif() endif(CMAKE_SYSTEM_NAME MATCHES "(Darwin|BSD|DragonFly)") - set(CMAKE_CXX_FLAGS_SEMIDEBUG "-g -O1 -Wall -Wabi ${WARNING_FLAGS} ${OTHER_FLAGS}") - set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall -Wabi ${WARNING_FLAGS} ${OTHER_FLAGS}") + set(CMAKE_CXX_FLAGS_SEMIDEBUG "-g -O1 -Wall ${WARNING_FLAGS} ${OTHER_FLAGS}") + set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall ${WARNING_FLAGS} ${OTHER_FLAGS}") if(USE_GPROF) set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pg")