@@ -5,8 +5,8 @@ Adds the following targets::
55 pybind11::pybind11 - link to headers and pybind11
66 pybind11::module - Adds module links
77 pybind11::embed - Adds embed links
8- pybind11::lto - Link time optimizations (manual selection )
9- pybind11::thin_lto - Link time optimizations (manual selection )
8+ pybind11::lto - Link time optimizations (only if CMAKE_INTERPROCEDURAL_OPTIMIZATION is not set )
9+ pybind11::thin_lto - Link time optimizations (only if CMAKE_INTERPROCEDURAL_OPTIMIZATION is not set )
1010 pybind11::python_link_helper - Adds link to Python libraries
1111 pybind11::windows_extras - MSVC bigobj and mp for building multithreaded
1212 pybind11::opt_size - avoid optimizations that increase code size
@@ -20,7 +20,7 @@ Adds the following functions::
2020
2121# CMake 3.10 has an include_guard command, but we can't use that yet
2222# include_guard(global) (pre-CMake 3.10)
23- if (TARGET pybind11::lto )
23+ if (TARGET pybind11::pybind11 )
2424 return ()
2525endif ()
2626
@@ -372,11 +372,13 @@ function(_pybind11_generate_lto target prefer_thin_lto)
372372 endif ()
373373endfunction ()
374374
375- add_library (pybind11::lto IMPORTED INTERFACE ${optional_global} )
376- _pybind11_generate_lto(pybind11::lto FALSE )
375+ if (NOT DEFINED CMAKE_INTERPROCEDURAL_OPTIMIZATION)
376+ add_library (pybind11::lto IMPORTED INTERFACE ${optional_global} )
377+ _pybind11_generate_lto(pybind11::lto FALSE )
377378
378- add_library (pybind11::thin_lto IMPORTED INTERFACE ${optional_global} )
379- _pybind11_generate_lto(pybind11::thin_lto TRUE )
379+ add_library (pybind11::thin_lto IMPORTED INTERFACE ${optional_global} )
380+ _pybind11_generate_lto(pybind11::thin_lto TRUE )
381+ endif ()
380382
381383# ---------------------- pybind11_strip -----------------------------
382384
0 commit comments