FindPython INTERPROCEDURAL_OPTIMIZATION warning
In CMake (tested 3.18.0 and 3.18.1), this warning pops up, without a clear way to suppress it:
-- The CXX compiler identification is AppleClang 126.96.36.19930032 -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Found Python: /Users/henryschreiner/git/software/pybind11/venv/bin/python3 (found version "3.8.5") found components: Interpreter Development Development.Module Development.Embed -- Configuring done CMake Warning (dev) at /usr/local/Cellar/cmake/3.18.1/share/cmake/Modules/FindPython/Support.cmake:3120 (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 'MyExample'. Call Stack (most recent call first): /usr/local/Cellar/cmake/3.18.1/share/cmake/Modules/FindPython.cmake:444 (__Python_add_library) CMakeLists.txt:8 (Python_add_library) This warning is for project developers. Use -Wno-dev to suppress it. -- Generating done -- Build files have been written to: /Users/henryschreiner/git/software/pybind11/tmp
It looks like
Modules/FindPython/Support.cmake sets policy level 3.7 (but FindPython was new in 3.12?), causing this to be thrown in some cases. I don't really understand why this line could be complaining, actually, since it seems like the target is brand new at this point. Simply changing the policy level in Support causes the warning to go away.
Note that I am setting the property later, not using the
CMAKE_ variable, and I still get this. MWE:
cmake_minimum_required(VERSION 3.18) project(MyProject LANGUAGES CXX) find_package(Python COMPONENTS Interpreter Development) file(TOUCH a.cpp b.cpp) Python_add_library(MyExample a.cpp b.cpp) set_target_properties(MyExample PROPERTIES INTERPROCEDURAL_OPTIMIZATION ON)