Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

{cmake} Add option "E57_RELEASE_LTO" to control link-time optimization for release builds #254

Merged
merged 1 commit into from
Aug 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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