mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-09 04:38:30 +09:00
[Fix] (CMakeLists): detect and enable LTO through CMake
This commit is contained in:
+8
-3
@@ -5,12 +5,17 @@ project("MobileGL")
|
||||
option(MOBILEGL_FORCE_RELEASE_OPT "Enable Release optimization flags in Debug build" OFF)
|
||||
|
||||
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug" OR MOBILEGL_FORCE_RELEASE_OPT)
|
||||
include(CheckIPOSupported)
|
||||
check_ipo_supported(RESULT LTOSupported OUTPUT LTOError)
|
||||
if (LTOSupported)
|
||||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
|
||||
endif()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang")
|
||||
add_compile_options(-O3 -ffunction-sections -fdata-sections -flto=thin)
|
||||
add_link_options(-flto=thin -Wl,--gc-sections)
|
||||
add_compile_options(-O3 -ffunction-sections -fdata-sections)
|
||||
add_link_options(-Wl,--gc-sections)
|
||||
elseif (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||
add_compile_options(/O2 /GL)
|
||||
add_link_options(/LTCG)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user