mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 00:37:15 +01:00
Experimenting with LTO.
This commit is contained in:
parent
4e5aa5a292
commit
5eabcab3a5
@ -6,6 +6,7 @@ set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
|
||||
|
||||
# Several plugin options
|
||||
option(BUILTIN_RUNTIMES "Include the MinGW runtime into the binary itself." ON)
|
||||
option(LTO_ENABLED "Enable link time optimizations (takes a long time to compile!)." ON)
|
||||
option(FORCE_32BIT_BIN "Create a 32-bit executable binary if the compiler defaults to 64-bit." OFF)
|
||||
option(ENABLE_MYSQL "Enable the MySQL library." OFF)
|
||||
option(ENABLE_API21 "Build for 2.1 API." OFF)
|
||||
@ -35,6 +36,20 @@ if(GCC OR MINGW)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# 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 ()
|
||||
|
||||
# Enable position independent code
|
||||
if(UNIX)
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
@ -81,6 +81,10 @@ if(GCC OR MINGW)
|
||||
endif()
|
||||
# Link to libraries
|
||||
target_link_libraries(SqModule SqModSDK SimpleINI HashLib B64Lib AES256Lib WhirlpoolLib TinyDir PUGIXML SQLite MaxmindDB SimpleSocket)
|
||||
# Enable LTO
|
||||
if (LTO_ENABLED)
|
||||
target_link_libraries(SqModule -flto)
|
||||
endif()
|
||||
# Link to mysql client library
|
||||
if(ENABLE_MYSQL)
|
||||
# Include the implementation
|
||||
|
4
module/Vendor/AES256/CMakeLists.txt
vendored
4
module/Vendor/AES256/CMakeLists.txt
vendored
@ -3,3 +3,7 @@ add_library(AES256Lib STATIC include/aes256.h aes256.cpp)
|
||||
# Configure include folders
|
||||
target_include_directories(AES256Lib PRIVATE ${CMAKE_CURRENT_LIST_DIR})
|
||||
target_include_directories(AES256Lib PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include)
|
||||
# Enable LTO
|
||||
if (LTO_ENABLED)
|
||||
target_link_libraries(AES256Lib PRIVATE -flto)
|
||||
endif()
|
4
module/Vendor/B64/CMakeLists.txt
vendored
4
module/Vendor/B64/CMakeLists.txt
vendored
@ -3,3 +3,7 @@ add_library(B64Lib STATIC include/b64.h decode.c encode.c)
|
||||
# Configure include folders
|
||||
target_include_directories(B64Lib PRIVATE ${CMAKE_CURRENT_LIST_DIR})
|
||||
target_include_directories(B64Lib PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include)
|
||||
# Enable LTO
|
||||
if (LTO_ENABLED)
|
||||
target_link_libraries(B64Lib PRIVATE -flto)
|
||||
endif()
|
4
module/Vendor/Hash/CMakeLists.txt
vendored
4
module/Vendor/Hash/CMakeLists.txt
vendored
@ -17,3 +17,7 @@ target_include_directories(HashLib PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include)
|
||||
if (MINGW)
|
||||
target_include_directories(HashLib PRIVATE ${CMAKE_CURRENT_LIST_DIR}/mingwinc)
|
||||
endif(MINGW)
|
||||
# Enable LTO
|
||||
if (LTO_ENABLED)
|
||||
target_link_libraries(HashLib PRIVATE -flto)
|
||||
endif()
|
4
module/Vendor/MaxmindDB/CMakeLists.txt
vendored
4
module/Vendor/MaxmindDB/CMakeLists.txt
vendored
@ -44,3 +44,7 @@ target_include_directories(MaxmindDB PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include)
|
||||
if(GCC OR MINGW)
|
||||
target_compile_options(MaxmindDB PRIVATE -Wno-unused -Wno-incompatible-pointer-types)
|
||||
endif()
|
||||
# Enable LTO
|
||||
if (LTO_ENABLED)
|
||||
target_link_libraries(MaxmindDB PRIVATE -flto)
|
||||
endif()
|
7
module/Vendor/PUGIXML/CMakeLists.txt
vendored
7
module/Vendor/PUGIXML/CMakeLists.txt
vendored
@ -3,4 +3,9 @@ add_library(PUGIXML STATIC include/pugiconfig.hpp include/pugixml.hpp pugixml.cp
|
||||
# Configure include folders
|
||||
target_include_directories(PUGIXML PRIVATE ${CMAKE_CURRENT_LIST_DIR})
|
||||
target_include_directories(PUGIXML PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include)
|
||||
|
||||
# Configure macro options
|
||||
target_compile_definitions(PUGIXML PRIVATE PUGIXML_NO_EXCEPTIONS=1)
|
||||
# Enable LTO
|
||||
if (LTO_ENABLED)
|
||||
target_link_libraries(PUGIXML PRIVATE -flto)
|
||||
endif()
|
4
module/Vendor/SQLite/CMakeLists.txt
vendored
4
module/Vendor/SQLite/CMakeLists.txt
vendored
@ -5,3 +5,7 @@ target_include_directories(SQLite PRIVATE ${CMAKE_CURRENT_LIST_DIR})
|
||||
target_include_directories(SQLite PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include)
|
||||
# Configure macro options
|
||||
target_compile_definitions(SQLite PRIVATE _WIN32_WINNT=0x0601 SQLITE_ENABLE_FTS3=1 SQLITE_ENABLE_FTS4=1 SQLITE_ENABLE_FTS5=1 SQLITE_ENABLE_JSON1=1 SQLITE_ENABLE_RTREE=1 SQLITE_ENABLE_GEOPOLY=1)
|
||||
# Enable LTO
|
||||
if (LTO_ENABLED)
|
||||
target_link_libraries(SQLite PRIVATE -flto)
|
||||
endif()
|
||||
|
4
module/Vendor/SimpleIni/CMakeLists.txt
vendored
4
module/Vendor/SimpleIni/CMakeLists.txt
vendored
@ -7,3 +7,7 @@ add_library(SimpleINI STATIC
|
||||
# Configure include folders
|
||||
target_include_directories(SimpleINI PRIVATE ${CMAKE_CURRENT_LIST_DIR})
|
||||
target_include_directories(SimpleINI PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include)
|
||||
# Enable LTO
|
||||
if (LTO_ENABLED)
|
||||
target_link_libraries(SimpleINI PRIVATE -flto)
|
||||
endif()
|
6
module/Vendor/SimpleSocket/CMakeLists.txt
vendored
6
module/Vendor/SimpleSocket/CMakeLists.txt
vendored
@ -11,7 +11,11 @@ target_include_directories(SimpleSocket PRIVATE ${CMAKE_CURRENT_LIST_DIR})
|
||||
target_include_directories(SimpleSocket PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include)
|
||||
# Configure macro options
|
||||
target_compile_definitions(SimpleSocket PRIVATE _WIN32_WINNT=0x0601)
|
||||
# OS and compiler checks.
|
||||
# Enable LTO
|
||||
if (LTO_ENABLED)
|
||||
target_link_libraries(SimpleSocket PRIVATE -flto)
|
||||
endif()
|
||||
# OS and compiler checks.
|
||||
if(WIN32)
|
||||
target_link_libraries(SimpleSocket PUBLIC Ws2_32)
|
||||
endif()
|
||||
|
4
module/Vendor/TinyDir/CMakeLists.txt
vendored
4
module/Vendor/TinyDir/CMakeLists.txt
vendored
@ -3,3 +3,7 @@ add_library(TinyDir STATIC include/tinydir.h tinydir.c)
|
||||
# Library includes
|
||||
target_include_directories(TinyDir PRIVATE ${CMAKE_CURRENT_LIST_DIR})
|
||||
target_include_directories(TinyDir PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include)
|
||||
# Enable LTO
|
||||
if (LTO_ENABLED)
|
||||
target_link_libraries(TinyDir PRIVATE -flto)
|
||||
endif()
|
4
module/Vendor/Whirlpool/CMakeLists.txt
vendored
4
module/Vendor/Whirlpool/CMakeLists.txt
vendored
@ -9,3 +9,7 @@ add_library(WhirlpoolLib STATIC
|
||||
# Configure include folders
|
||||
target_include_directories(WhirlpoolLib PRIVATE ${CMAKE_CURRENT_LIST_DIR})
|
||||
target_include_directories(WhirlpoolLib PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include)
|
||||
# Enable LTO
|
||||
if (LTO_ENABLED)
|
||||
target_link_libraries(WhirlpoolLib PRIVATE -flto)
|
||||
endif()
|
||||
|
2
sdk
2
sdk
@ -1 +1 @@
|
||||
Subproject commit 4d187b72b35b1ae1557772d25129d7ab6bcbd1aa
|
||||
Subproject commit dd04405ff22391aeb102d64176e8123c5d0f6cae
|
Loading…
Reference in New Issue
Block a user