diff --git a/cmake/build/core.cmake b/cmake/build/core.cmake index d16fe028..0056c36c 100644 --- a/cmake/build/core.cmake +++ b/cmake/build/core.cmake @@ -21,10 +21,16 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic-errors") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g2") +if(${CMAKE_CXX_COMPILER_ID} STREQUAL GNU) + set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -fdata-sections -ffunction-sections") + set(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL} -Wl,--gc-sections,--icf=safe") +endif() + # Check compiler if(${CMAKE_CXX_COMPILER_ID} STREQUAL Clang) if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.4.0") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a24d149e..4e650e28 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -141,6 +141,7 @@ make_executable(${PROJECT_NAME} SOURCES target_link_libraries(${PROJECT_NAME} Threads::Threads) target_compile_options(${PROJECT_NAME} PUBLIC + $<$:$<$:-flto>> ${X11_Xft_DEFINITIONS} ${X11_XCB_DEFINITIONS} ${XCB_DEFINITIONS}) @@ -150,6 +151,8 @@ target_compile_options(${PROJECT_NAME} PUBLIC if(BUILD_IPC_MSG) make_executable(${PROJECT_NAME}-msg SOURCES ipc.cpp utils/file.cpp) + target_compile_options(${PROJECT_NAME}-msg PUBLIC + $<$:$<$:-flto>>) endif() # }}}