1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 00:37:15 +01:00
SqMod/CMakeLists.txt

116 lines
4.6 KiB
CMake
Raw Normal View History

2021-02-01 00:27:35 +01:00
cmake_minimum_required(VERSION 3.7)
project(SqMod)
# This plug-in only works on 64-bit
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
message(FATAL_ERROR "SqMod does not support 32-but platforms anymore.")
endif()
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
# Several plugin options
2020-05-01 19:41:00 +02:00
option(ENABLE_API21 "Build for 2.1 API." OFF)
option(ENABLE_DISCORD "Enable built-in Discord support" ON)
2021-09-10 19:19:25 +02:00
option(ENABLE_DISCORD_VOICE "Enable voice support in Discord library" OFF)
2021-03-26 23:18:51 +01:00
option(ENABLE_OFFICIAL "Enable compatibility with official legacy plug-in" ON)
#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)
2021-02-01 00:49:03 +01:00
option(COPY_DEPENDENCIES "Copy deppendent DLLs into the deps folder." OFF)
2021-01-31 22:04:36 +01:00
endif()
2021-02-01 00:49:03 +01:00
# C++14 is mandatory
set(CPP_STD_NUMBER 14)
include(CheckCXXCompilerFlag)
# C++ standard availability check
2021-02-01 00:49:03 +01:00
if(${CMAKE_CXX_COMPILER_ID} MATCHES "(GNU)+")
# Specific flags
set(CPP_STD_COMPILER_FLAG "-std=c++14")
# Don't even bother with previous version
2021-02-05 14:08:41 +01:00
if(CPP_STD_NUMBER LESS 20 AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0)
2021-02-01 00:49:03 +01:00
check_cxx_compiler_flag(-std=c++20 HAVE_FLAG_STD_CXX20)
check_cxx_compiler_flag(-std=c++2a HAVE_FLAG_STD_CXX2A)
if(HAVE_FLAG_STD_CXX20 OR HAVE_FLAG_STD_CXX2A)
# We can use C++20
set(CPP_STD_NUMBER 20)
# Specific flags
if (HAVE_FLAG_STD_CXX2A AND NOT HAVE_FLAG_STD_CXX20)
set(CPP_STD_COMPILER_FLAG "-std=c++2a")
else()
set(CPP_STD_COMPILER_FLAG "-std=c++20")
endif()
# Need these workarounds for older CMake
if(${CMAKE_VERSION} VERSION_LESS "3.8.0")
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10.0)
set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "-std=c++20")
set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION "-std=gnu++20")
elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0)
set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "-std=c++2a")
set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION "-std=gnu++2a")
endif()
endif()
endif()
endif()
# Don't even bother with previous version
if(CPP_STD_NUMBER LESS 17 AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0)
check_cxx_compiler_flag(-std=c++17 HAVE_FLAG_STD_CXX17)
check_cxx_compiler_flag(-std=c++1z HAVE_FLAG_STD_CXX1Z)
if(HAVE_FLAG_STD_CXX17 OR HAVE_FLAG_STD_CXX1Z)
# We can use C++17
set(CPP_STD_NUMBER 17)
# Specific flags
if (HAVE_FLAG_STD_CXX1Z AND NOT HAVE_FLAG_STD_CXX17)
set(CPP_STD_COMPILER_FLAG "-std=c++1z")
else()
set(CPP_STD_COMPILER_FLAG "-std=c++17")
endif()
# Need these workarounds for older CMake
if(${CMAKE_VERSION} VERSION_LESS "3.8.0")
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0)
set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-std=c++17")
set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std=gnu++17")
elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.1)
set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-std=c++1z")
set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std=gnu++1z")
endif()
endif()
endif()
endif()
else()
2021-02-01 00:49:03 +01:00
# C++14 is mandatory
set(CPP_STD_NUMBER 14)
endif()
message(STATUS "SqMod: Using C++${CPP_STD_NUMBER} standard.")
# Default to the identified standard
if(CMAKE_VERSION VERSION_LESS "3.1")
2021-02-01 00:51:38 +01:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CPP_STD_COMPILER_FLAG}")
else()
2021-02-01 00:49:03 +01:00
# Apparently the above does not work with cmake from on debian 8
2021-02-01 00:51:38 +01:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CPP_STD_COMPILER_FLAG}")
2021-02-01 00:49:03 +01:00
# F* you too Debian. What can I say.
if(CMAKE_VERSION VERSION_LESS "3.8.0" AND CPP_STD_NUMBER LESS 17)
# Try the standard method as well
set(CMAKE_CXX_STANDARD ${CPP_STD_NUMBER})
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()
endif()
2021-09-06 18:14:09 +02:00
# Strip binary
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -s -g")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s -g")
# Enable position independent code
2021-01-31 17:48:31 +01:00
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
2021-02-01 00:49:03 +01:00
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
2020-05-28 20:27:44 +02:00
# Include vendor libraries
add_subdirectory(vendor)
# Include Module library
add_subdirectory(module)