2020-03-21 20:39:01 +01:00
|
|
|
cmake_minimum_required(VERSION 3.0.2)
|
|
|
|
project(SqMod)
|
|
|
|
|
2020-03-22 19:53:52 +01:00
|
|
|
# Tell CMake where to find our scripts
|
|
|
|
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
|
2021-01-30 18:40:40 +01:00
|
|
|
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/vendor/POCO/cmake)
|
2020-03-22 19:53:52 +01:00
|
|
|
|
2020-03-21 20:39:01 +01:00
|
|
|
# Several plugin options
|
2020-05-01 19:41:00 +02:00
|
|
|
option(ENABLE_API21 "Build for 2.1 API." OFF)
|
2021-01-31 18:36:23 +01:00
|
|
|
option(FORCE_32BIT_BIN "Create a 32-bit executable binary if the compiler defaults to 64-bit." OFF)
|
2021-01-31 22:04:36 +01:00
|
|
|
# This option should only be available in certain conditions
|
|
|
|
if(WIN32 AND MINGW)
|
|
|
|
option(COPY_DEPENDENCIES "Copy deppendent DLLs into the deps folder." OFF)
|
|
|
|
endif()
|
2020-03-21 20:39:01 +01:00
|
|
|
|
2021-01-27 06:27:48 +01:00
|
|
|
include(CheckCXXCompilerFlag)
|
|
|
|
# C++ standard availability check
|
2021-01-30 07:51:39 +01:00
|
|
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|
|
|
check_cxx_compiler_flag(-std=c++20 HAVE_FLAG_STD_CXX20)
|
|
|
|
if(HAVE_FLAG_STD_CXX20)
|
|
|
|
# We can use C++20
|
|
|
|
set(CPP_STD_NUMBER 20)
|
|
|
|
else()
|
|
|
|
check_cxx_compiler_flag(-std=c++17 HAVE_FLAG_STD_CXX17)
|
|
|
|
if(HAVE_FLAG_STD_CXX17)
|
|
|
|
# We can use C++17
|
|
|
|
set(CPP_STD_NUMBER 17)
|
|
|
|
else()
|
|
|
|
# C++14 is mandatory
|
|
|
|
set(CPP_STD_NUMBER 14)
|
|
|
|
endif()
|
|
|
|
endif()
|
2021-01-27 06:27:48 +01:00
|
|
|
else()
|
2021-01-30 07:51:39 +01:00
|
|
|
# C++14 is mandatory
|
|
|
|
set(CPP_STD_NUMBER 14)
|
2021-01-27 06:27:48 +01:00
|
|
|
endif()
|
|
|
|
|
2021-01-30 07:51:39 +01:00
|
|
|
message(STATUS "SqMod: Using C++${CPP_STD_NUMBER} standard.")
|
2021-01-27 06:27:48 +01:00
|
|
|
|
|
|
|
# Default to the identified standard
|
2020-03-21 20:39:01 +01:00
|
|
|
if(CMAKE_VERSION VERSION_LESS "3.1")
|
2020-05-10 11:19:46 +02:00
|
|
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
2021-01-27 06:27:48 +01:00
|
|
|
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++${CPP_STD_NUMBER}")
|
2020-03-21 20:39:01 +01:00
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
# Apparently the above does not work with cmake from on debian 8
|
2021-01-30 07:51:39 +01:00
|
|
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++${CPP_STD_NUMBER}")
|
|
|
|
endif()
|
2020-03-21 20:39:01 +01:00
|
|
|
# Try the standard method as well
|
2021-01-27 06:27:48 +01:00
|
|
|
set(CMAKE_CXX_STANDARD ${CPP_STD_NUMBER})
|
2020-03-21 20:39:01 +01:00
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
endif()
|
|
|
|
|
2020-04-30 20:34:10 +02:00
|
|
|
# Determine if build mode
|
2021-01-31 17:48:31 +01:00
|
|
|
if(${CMAKE_BUILD_TYPE} MATCHES "(Debug)+")
|
2020-04-30 20:34:10 +02:00
|
|
|
add_compile_options(-g)
|
|
|
|
endif()
|
2020-03-21 20:39:01 +01:00
|
|
|
|
|
|
|
# Enable position independent code
|
2021-01-31 17:48:31 +01:00
|
|
|
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
2020-03-21 20:39:01 +01:00
|
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
|
|
endif()
|
2020-05-28 20:27:44 +02:00
|
|
|
|
2021-01-30 07:51:39 +01:00
|
|
|
# Include vendor libraries
|
|
|
|
add_subdirectory(vendor)
|
2020-05-28 19:59:29 +02:00
|
|
|
# Include Module library
|
2021-01-30 07:51:39 +01:00
|
|
|
add_subdirectory(module)
|