Skip to content

Commit

Permalink
{cmake} Add option "E57_RELEASE_LTO" to control link-time optimizatio…
Browse files Browse the repository at this point in the history
…n for release builds (#254)

CMake forces "thin" LTO (see https://gitlab.kitware.com/cmake/cmake/-/issues/23136)
which is a problem if compiling statically for distribution (e.g. in a package manager).
Generally you will only want to turn this off for distributing static release builds.
  • Loading branch information
asmaloney committed Aug 11, 2023
1 parent 63a6164 commit 72908b9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ option( E57_WRITE_CRAZY_PACKET_MODE "Compile library to enable reader-stressing
# Other compile options
option( E57_VISIBILITY_HIDDEN "Compile library with hidden symbol visibility" ON )

# Link-time optiomization
# CMake forces "thin" LTO (see https://gitlab.kitware.com/cmake/cmake/-/issues/23136)
# which is a problem if compiling statically for distribution (e.g. in a package manager).
# Generally you will only want to turn this off for distributing static release builds.
option( E57_RELEASE_LTO "Compile release library with link-time optimization" ON )

#########################################################################################

set( REVISION_ID "${PROJECT_NAME}-${PROJECT_VERSION}-${${PROJECT_NAME}_BUILD_TAG}" )
Expand Down Expand Up @@ -132,7 +138,7 @@ set_target_properties( E57Format
CXX_EXTENSIONS NO
EXPORT_COMPILE_COMMANDS ON
POSITION_INDEPENDENT_CODE ON
INTERPROCEDURAL_OPTIMIZATION ON
INTERPROCEDURAL_OPTIMIZATION ${E57_RELEASE_LTO}
INTERPROCEDURAL_OPTIMIZATION_DEBUG OFF
)

Expand Down

0 comments on commit 72908b9

Please sign in to comment.