PiperOrigin-RevId: 950629900 Change-Id: If4b3755f0e8653efbd9e6a4134140dd96b1f743d
This commit is contained in:
committed by
Copybara-Service
parent
3990305373
commit
6f487086a5
@@ -108,13 +108,16 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Enable interprocedural optimization (LTO) by default for non-Debug builds, but
|
||||
# only when the caller has not made an explicit choice. Checking the value (rather
|
||||
# than whether it is DEFINED) meant an explicit `-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=OFF`
|
||||
# was silently overridden back to ON, e.g. in CI where LTO is disabled to cut
|
||||
# build time.
|
||||
if(NOT DEFINED CMAKE_INTERPROCEDURAL_OPTIMIZATION AND (CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug"))
|
||||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
|
||||
# Provide a user-facing option to control Link-Time Optimization (LTO/IPO).
|
||||
# When ON (the default), LTO is enabled for non-Debug builds unless the caller
|
||||
# has already set CMAKE_INTERPROCEDURAL_OPTIMIZATION explicitly.
|
||||
# Users can disable LTO entirely with -DMUJOCO_ENABLE_LTO=OFF.
|
||||
option(MUJOCO_ENABLE_LTO "Enable Link-Time Optimization (LTO) for non-Debug builds." ON)
|
||||
|
||||
if(MUJOCO_ENABLE_LTO)
|
||||
if(NOT DEFINED CMAKE_INTERPROCEDURAL_OPTIMIZATION AND (CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug"))
|
||||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include(MujocoHarden)
|
||||
|
||||
Reference in New Issue
Block a user