-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
Remove push/pop in PCLConfig #2726
Comments
Implementing this will hopefully fix #3062. |
From what I can tell, if we simply remove the push/pop policy our PCLConfig.cmake will start producing warnings in consumer projects. As a test I did the following:
PROJECT(pcl-config-test)
CMAKE_MINIMUM_REQUIRED(VERSION 3.5)
find_package(PCL)
message("PCL_INCLUDE_DIRS: ${PCL_INCLUDE_DIRS}")
message("PCL_LIBRARIES: ${PCL_LIBRARIES}") Here's the current output without the push/pop approach (Click to expand)
and with (Click to expand)
It is doing it's job of suppressing the warning related to |
I've found the issue. Entering a CMake function or macro effectively creates a new policy stack (well not really, but when in comes to push/pop it's equivalent). Here's a minimal failing example. PROJECT(pcl-config-test)
CMAKE_MINIMUM_REQUIRED(VERSION 3.5)
cmake_policy(PUSH)
macro(my_macro)
cmake_policy(POP)
return()
endmacro()
my_macro()
cmake_policy(POP) This means we cannot |
Turns out you were right, but I'm not sure if for the right reasons. After a tip from the CMake mailing list and rereading the docs.
Test: CMakeLists.txt project(pcl-config-test)
cmake_minimum_required(VERSION 3.5)
cmake_policy(SET CMP0074 OLD)
cmake_policy(GET CMP0074 POLICY_STATUS)
message(STATUS "POLICY_STATUS: ${POLICY_STATUS}")
find_package(PCL)
cmake_policy(GET CMP0074 POLICY_STATUS)
message(STATUS "POLICY_STATUS: ${POLICY_STATUS}") My mock PCLConfig.cmake if(POLICY CMP0074)
# TODO: update *_ROOT variables to be PCL_*_ROOT or equivalent.
# CMP0074 directly affects how Find* modules work and *_ROOT variables. Since
# this is a config file that will be consumed by parent projects with (likely)
# NEW behavior, we need to push a policy stack.
cmake_policy(SET CMP0074 NEW)
endif()
cmake_policy(GET CMP0074 POLICY_STATUS)
message(STATUS "POLICY_STATUS: ${POLICY_STATUS}") The output
Push/pop free! PR following up. |
Thanks for doing the research, I'm glad you've come back out of this rabbit hole alive 😆 |
We can get rid of the
push
/pop
, especially if we are setting policy 74.Originally posted by @claudiofantacci in #2454 (comment)
The text was updated successfully, but these errors were encountered: