@@ -5,9 +5,18 @@ project(binlog_json_parser)
55set (CMAKE_CXX_STANDARD 23)
66set (CMAKE_CXX_STANDARD_REQUIRED ON )
77
8+ include (CheckIPOSupported)
9+ check_ipo_supported(RESULT IPO_SUPPORTED OUTPUT IPO_OUTPUT)
10+
11+ if (IPO_SUPPORTED)
12+ set (CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE )
13+ message (STATUS "Interprocedural optimization (IPO/LTO) enabled globally." )
14+ else ()
15+ message (STATUS "IPO/LTO is not supported: ${IPO_OUTPUT} " )
16+ endif ()
17+
818# Check if the build type is Release
919if (CMAKE_BUILD_TYPE STREQUAL "Release" )
10-
1120 # Set optimization level to -O3 for release builds
1221 if (NOT CMAKE_CXX_FLAGS_RELEASE MATCHES "-O" )
1322 set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3" )
@@ -32,24 +41,9 @@ if(CMAKE_BUILD_TYPE STREQUAL "Release")
3241 message (WARNING "The -march option will not be set because the system is not x86 or x64." )
3342 endif ()
3443
35- # Check for LTO support
36- include (CheckCXXCompilerFlag)
37-
38- check_cxx_compiler_flag("-flto" COMPILER_SUPPORTS_LTO)
39-
40- if (COMPILER_SUPPORTS_LTO)
41- message (STATUS "Link Time Optimization (LTO) is supported by the compiler." )
42- set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto" )
43- set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto" )
44- set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -flto" )
45- else ()
46- message (WARNING "Link Time Optimization (LTO) is not supported by the compiler." )
47- endif ()
48-
4944 # Export compile flags to a file
5045 file (WRITE "${CMAKE_BINARY_DIR} /compile_flags.txt" "CXXFLAGS: ${CMAKE_CXX_FLAGS_RELEASE} \n " )
5146 file (APPEND "${CMAKE_BINARY_DIR} /compile_flags.txt" "LINKER_FLAGS: ${CMAKE_EXE_LINKER_FLAGS} \n " )
52-
5347endif ()
5448
5549add_library (mysqljsonparse SHARED mysqljsonparse.cpp mysql_json_parser.cpp)
0 commit comments