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)
|
|
|
|
|
2020-03-21 20:39:01 +01:00
|
|
|
# Several plugin options
|
|
|
|
option(BUILTIN_RUNTIMES "Include the MinGW runtime into the binary itself." ON)
|
2020-08-19 15:51:57 +02:00
|
|
|
option(LTO_ENABLED "Enable link time optimizations (takes a long time to compile!)." OFF)
|
2020-03-21 20:39:01 +01:00
|
|
|
option(FORCE_32BIT_BIN "Create a 32-bit executable binary if the compiler defaults to 64-bit." OFF)
|
2020-03-22 17:57:00 +01:00
|
|
|
option(ENABLE_MYSQL "Enable the MySQL library." OFF)
|
2020-05-01 19:41:00 +02:00
|
|
|
option(ENABLE_API21 "Build for 2.1 API." OFF)
|
2020-03-21 20:39:01 +01:00
|
|
|
|
|
|
|
# Default to c++14 standard
|
|
|
|
if(CMAKE_VERSION VERSION_LESS "3.1")
|
2020-05-10 11:19:46 +02:00
|
|
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
2020-04-17 14:25:58 +02:00
|
|
|
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
|
2020-03-21 20:39:01 +01:00
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
# Apparently the above does not work with cmake from on debian 8
|
2020-04-20 03:46:05 +02:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
|
2020-03-21 20:39:01 +01:00
|
|
|
# Try the standard method as well
|
|
|
|
set(CMAKE_CXX_STANDARD 14)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
endif()
|
|
|
|
|
2020-04-30 20:34:10 +02:00
|
|
|
# Determine if build mode
|
|
|
|
if(CMAKE_BUILD_TYPE MATCHES Debug)
|
|
|
|
add_compile_options(-g)
|
|
|
|
endif()
|
2020-03-21 20:39:01 +01:00
|
|
|
|
2020-08-19 14:33:41 +02:00
|
|
|
# Include MINGW runtime into the binary
|
2020-05-10 11:19:46 +02:00
|
|
|
if(GCC OR MINGW)
|
2020-03-21 20:39:01 +01:00
|
|
|
if(BUILTIN_RUNTIMES)
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2020-08-19 15:49:45 +02:00
|
|
|
# Enable LTO
|
|
|
|
if (NOT LTO_ENABLED)
|
|
|
|
message("Link time optimizations are disabled")
|
|
|
|
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "MINGW")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto")
|
|
|
|
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
|
|
|
if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "GNU")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto")
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
set(LTO_ENABLED OFF)
|
|
|
|
message("Link time optimizations not supported")
|
|
|
|
endif ()
|
|
|
|
|
2020-03-21 20:39:01 +01:00
|
|
|
# Enable position independent code
|
2020-05-10 11:19:46 +02:00
|
|
|
if(UNIX)
|
2020-03-21 20:39:01 +01:00
|
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
|
|
endif()
|
2020-05-28 20:27:44 +02:00
|
|
|
|
2020-03-21 21:58:50 +01:00
|
|
|
# Include SDK library
|
|
|
|
add_subdirectory(sdk)
|
2020-05-28 19:59:29 +02:00
|
|
|
# Include Module library
|
|
|
|
add_subdirectory(module)
|