Other minor CMake improvements

This commit is contained in:
sfan5 2022-09-26 17:02:49 +02:00
parent e8ee4cb40d
commit f680d10259
3 changed files with 19 additions and 20 deletions

@ -136,6 +136,17 @@ if(BUILD_CLIENT AND TARGET IrrlichtMt::IrrlichtMt)
endif() endif()
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 # Installation
@ -278,23 +289,9 @@ find_package(GMP REQUIRED)
find_package(Json REQUIRED) find_package(Json REQUIRED)
find_package(Lua REQUIRED) find_package(Lua REQUIRED)
if(NOT USE_LUAJIT) if(NOT USE_LUAJIT)
set(LUA_BIT_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/bitop)
set(LUA_BIT_LIBRARY bitop)
add_subdirectory(lib/bitop) add_subdirectory(lib/bitop)
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()
if(BUILD_BENCHMARKS) if(BUILD_BENCHMARKS)
add_subdirectory(lib/catch2) add_subdirectory(lib/catch2)
endif() endif()
@ -303,7 +300,6 @@ endif()
# Be sure to add all relevant definitions above this # Be sure to add all relevant definitions above this
add_subdirectory(src) add_subdirectory(src)
# CPack # CPack
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A free open-source voxel game engine with easy modding and game creation.") set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A free open-source voxel game engine with easy modding and game creation.")

@ -1,4 +1,5 @@
add_library(bitop STATIC bit.cpp) 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)

@ -241,6 +241,10 @@ endif()
# Use cmake_config.h # Use cmake_config.h
add_definitions(-DUSE_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) if(WIN32)
# Windows # Windows
if(MSVC) # MSVC Specifics if(MSVC) # MSVC Specifics
@ -251,8 +255,6 @@ if(WIN32)
add_definitions(/D "_USE_MATH_DEFINES") add_definitions(/D "_USE_MATH_DEFINES")
# Dont define min/max macros in minwindef.h # Dont define min/max macros in minwindef.h
add_definitions(/D "NOMINMAX") add_definitions(/D "NOMINMAX")
else() # Probably MinGW = GCC
set(PLATFORM_LIBS "")
endif() endif()
set(PLATFORM_LIBS ws2_32.lib version.lib shlwapi.lib winmm.lib ${PLATFORM_LIBS}) 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(NOT HAIKU AND NOT APPLE)
endif() endif()
set(PLATFORM_LIBS -lpthread ${CMAKE_DL_LIBS}) set(PLATFORM_LIBS ${PLATFORM_LIBS} ${CMAKE_DL_LIBS})
if(APPLE) if(APPLE)
set(PLATFORM_LIBS "-framework CoreFoundation" ${PLATFORM_LIBS}) set(PLATFORM_LIBS "-framework CoreFoundation" ${PLATFORM_LIBS})
else() else()