Skip to content

Commit

Permalink
Add LTO (#28)
Browse files Browse the repository at this point in the history
Perform LTO on the build and strip using the strip command
rather than passing -s.
  • Loading branch information
chrisstaite authored Jan 13, 2025
1 parent 64476ea commit 0490b4a
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.9)

project(DoTe CXX)

Expand Down Expand Up @@ -130,14 +130,25 @@ else()
endif()
target_link_libraries(dote_static ${OPENSSL_LIBRARIES} dl)

# Strip release
set(CMAKE_EXE_LINKER_FLAGS_RELEASE
"${CMAKE_EXE_LINKER_FLAGS_RELEASE} -s")

# Set up the binary application
add_executable(dote ${BinarySources})
target_link_libraries(dote dote_static)

# Strip release
add_custom_command(
TARGET dote POST_BUILD
DEPENDS dote
COMMAND $<$<CONFIG:release>:${CMAKE_STRIP}>
ARGS $<TARGET_FILE:dote>
)

# Enable LTO
include(CheckIPOSupported)
check_ipo_supported(RESULT result)
if (result)
set_property(TARGET dote PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()

# Import Google test and GoogleMock
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/GMock.cmake)

Expand Down

0 comments on commit 0490b4a

Please sign in to comment.