]> git.lizzy.rs Git - minetest.git/commitdiff
Other minor CMake improvements
authorsfan5 <sfan5@live.de>
Mon, 26 Sep 2022 15:02:49 +0000 (17:02 +0200)
committersfan5 <sfan5@live.de>
Thu, 13 Oct 2022 21:02:11 +0000 (23:02 +0200)
CMakeLists.txt
lib/bitop/CMakeLists.txt
src/CMakeLists.txt

index 2681f82591c63d0ec9aa453ee1ce7ca9903ae357..d4ecda37ba40510d9761eb54637dd685aff449e8 100644 (file)
@@ -136,6 +136,17 @@ if(BUILD_CLIENT AND TARGET IrrlichtMt::IrrlichtMt)
        endif()
 endif()
 
+if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+       if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "${GCC_MINIMUM_VERSION}")
+               message(FATAL_ERROR "Insufficient gcc version, found ${CMAKE_CXX_COMPILER_VERSION}. "
+                       "Version ${GCC_MINIMUM_VERSION} or higher is required.")
+       endif()
+elseif(CMAKE_CXX_COMPILER_ID MATCHES "(Apple)?Clang")
+       if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "${CLANG_MINIMUM_VERSION}")
+               message(FATAL_ERROR "Insufficient clang version, found ${CMAKE_CXX_COMPILER_VERSION}. "
+                       "Version ${CLANG_MINIMUM_VERSION} or higher is required.")
+       endif()
+endif()
 
 # Installation
 
@@ -278,23 +289,9 @@ find_package(GMP REQUIRED)
 find_package(Json REQUIRED)
 find_package(Lua REQUIRED)
 if(NOT USE_LUAJIT)
-       set(LUA_BIT_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/bitop)
-       set(LUA_BIT_LIBRARY bitop)
        add_subdirectory(lib/bitop)
 endif()
 
-if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
-       if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "${GCC_MINIMUM_VERSION}")
-               message(FATAL_ERROR "Insufficient gcc version, found ${CMAKE_CXX_COMPILER_VERSION}. "
-                       "Version ${GCC_MINIMUM_VERSION} or higher is required.")
-       endif()
-elseif(CMAKE_CXX_COMPILER_ID MATCHES "(Apple)?Clang")
-       if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "${CLANG_MINIMUM_VERSION}")
-               message(FATAL_ERROR "Insufficient clang version, found ${CMAKE_CXX_COMPILER_VERSION}. "
-                       "Version ${CLANG_MINIMUM_VERSION} or higher is required.")
-       endif()
-endif()
-
 if(BUILD_BENCHMARKS)
        add_subdirectory(lib/catch2)
 endif()
@@ -303,7 +300,6 @@ endif()
 # Be sure to add all relevant definitions above this
 add_subdirectory(src)
 
-
 # CPack
 
 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A free open-source voxel game engine with easy modding and game creation.")
index 80b62744690d00e8db8539d4df9dacb46dd62256..2aec86f274f8bc6b8958ef69c292d5282bfc3174 100644 (file)
@@ -1,4 +1,5 @@
 add_library(bitop STATIC bit.cpp)
-target_link_libraries(bitop)
+target_include_directories(bitop PRIVATE ${LUA_INCLUDE_DIR})
 
-include_directories(${LUA_INCLUDE_DIR})
+set(LUA_BIT_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} PARENT_SCOPE)
+set(LUA_BIT_LIBRARY bitop PARENT_SCOPE)
index 1f1e987f79566f2416b35e699c8e3116dfec080f..64aef356ace3472c55c8c21a2bf0d8cbd5e87ddc 100644 (file)
@@ -241,6 +241,10 @@ endif()
 # Use cmake_config.h
 add_definitions(-DUSE_CMAKE_CONFIG_H)
 
+set(THREADS_PREFER_PTHREAD_FLAG ON)
+find_package(Threads REQUIRED)
+set(PLATFORM_LIBS Threads::Threads)
+
 if(WIN32)
        # Windows
        if(MSVC) # MSVC Specifics
@@ -251,8 +255,6 @@ if(WIN32)
                add_definitions(/D "_USE_MATH_DEFINES")
                # Dont define min/max macros in minwindef.h
                add_definitions(/D "NOMINMAX")
-       else() # Probably MinGW = GCC
-               set(PLATFORM_LIBS "")
        endif()
        set(PLATFORM_LIBS ws2_32.lib version.lib shlwapi.lib winmm.lib ${PLATFORM_LIBS})
 
@@ -282,7 +284,7 @@ else()
                endif(NOT HAIKU AND NOT APPLE)
        endif()
 
-       set(PLATFORM_LIBS -lpthread ${CMAKE_DL_LIBS})
+       set(PLATFORM_LIBS ${PLATFORM_LIBS} ${CMAKE_DL_LIBS})
        if(APPLE)
                set(PLATFORM_LIBS "-framework CoreFoundation" ${PLATFORM_LIBS})
        else()