Skip to content

Commit

Permalink
Fix CMake IPO Control
Browse files Browse the repository at this point in the history
`pybind11::lto` is only defined if `CMAKE_INTERPROCEDURAL_OPTIMIZATION`
is not set in `pybind11Common.cmake`. Package managers like Spack
use the latter.
  • Loading branch information
ax3l committed Jul 16, 2024
1 parent a5c3d39 commit 7062015
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,13 @@ pyamrex_set_default_install_dirs()

# Options and Variants ########################################################
#
set(_pyAMReX_IPO_DEFAULT ON)
if(DEFINED CMAKE_INTERPROCEDURAL_OPTIMIZATION)
set(_pyAMReX_IPO_DEFAULT ${CMAKE_INTERPROCEDURAL_OPTIMIZATION})
endif()
option(pyAMReX_IPO
"Compile with interprocedural optimization (IPO) / link-time optimization (LTO)"
ON
${_pyAMReX_IPO_DEFAULT}
)
option(pyAMReX_INSTALL
"Enable install targets for pyAMReX"
Expand Down Expand Up @@ -134,7 +138,7 @@ foreach(D IN LISTS AMReX_SPACEDIM)
# link dependencies
target_link_libraries(pyAMReX_${D}d PUBLIC AMReX::amrex_${D}d)
target_link_libraries(pyAMReX_${D}d PRIVATE pybind11::module pybind11::windows_extras)
if(pyAMReX_IPO)
if(pyAMReX_IPO AND NOT DEFINED CMAKE_INTERPROCEDURAL_OPTIMIZATION)
target_link_libraries(pyAMReX_${D}d PRIVATE pybind11::lto)
endif()

Expand Down

0 comments on commit 7062015

Please sign in to comment.