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

link time optimization disabled due to OLD behaviour of CMake policy 0069 #1903

Closed
Xeverous opened this issue Sep 1, 2019 · 1 comment · Fixed by #2338
Closed

link time optimization disabled due to OLD behaviour of CMake policy 0069 #1903

Xeverous opened this issue Sep 1, 2019 · 1 comment · Fixed by #2338

Comments

@Xeverous
Copy link

Xeverous commented Sep 1, 2019

Pybind11 requires CMake of version 2.8.12 or newer. Because this is lower than 3.9, it sets the OLD behaviour of the policy 0069.

https://cmake.org/cmake/help/latest/policy/CMP0069.html#policy:CMP0069

With the OLD behaviour, LTO is not applied and this is warning displayed during the build:

-- Configuring done
CMake Warning (dev) at [...]/pybind11/tools/pybind11Tools.cmake:131 (add_library):
  Policy CMP0069 is not set: INTERPROCEDURAL_OPTIMIZATION is enforced when
  enabled.  Run "cmake --help-policy CMP0069" for policy details.  Use the
  cmake_policy command to set the policy and suppress this warning.

  INTERPROCEDURAL_OPTIMIZATION property will be ignored for target [...]

Pybind11 explicitly states in the documentation that it needs LTO to make good binary code so I think this is important.

I think this would be a good solution:

if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.9)
  cmake_policy(SET CMP0069 NEW)
endif()
@bstaletic
Copy link
Collaborator

This sounds reasonable. Do you mind making a pull request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants