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

Set CMake policy CMP0074 to NEW #2671

Merged
merged 1 commit into from
Dec 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Update CMake policy 74
  • Loading branch information
SergioRAgostinho committed Dec 1, 2018
commit d79c494492f847da756b54cb618f4128c1944db1
7 changes: 3 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)

if(POLICY CMP0074)
# TODO:
# 1. Find*.cmake modules need to be individually verified.
# 2. PCLConfig.cmake needs to be changed.
cmake_policy(SET CMP0074 OLD)
# 1. Remove with 3.12.4.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the version in which the policy came into effect. So it means that when we set the minimum version of cmake to 3.12, this will no longer be needed.

Given your question I assume it's a good idea to rewrite that comment.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But if the policy is not set CMake will default to OLD?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me write a couple of cases to clarify:

  • Case 1:
    • Policy: Not Set
    • CMake minimum required version: 3.1
    • CMake version used: 3.1
    • Results: You get the OLD behavior. CMake 3.1 doesn't even know about this policy because it was only created in version 3.12 it he behaves with the OLD behavior.
  • Case 2:
    • Policy: Not Set
    • CMake minimum required version: 3.1
    • CMake version used: 3.12
    • Results: You get the OLD behavior by default and a warning saying to explicitly set the bhavior. CMake 3.12 wants you to know that things changed.
  • Case 3:
    • Policy: Not Set
    • CMake minimum required version: 3.12
    • CMake version used: 3.12
    • Results: You get the new behavior by default.
  • Case 4:
    • Policy: Explicitly set to NEW
    • CMake minimum required version: 3.1
    • CMake version used: 3.1
    • Results: CMake 3.1 doesn't even know about this policy and ignores it. It still behaves in the OLD behavior.
  • Case 5:
    • Policy: Explicitly set to NEW
    • CMake minimum required version: 3.1
    • CMake version used: 3.12
    • Results: You get the NEW behavior. You're in a situation in which you're compliant with CMake versions from the minimum required one all the way to 3.12+
  • Case 6:
    • Policy: Explicitly set to NEW
    • CMake minimum required version: 3.12
    • CMake version used: 3.12
    • Results: You get the new behavior by default but now you're explicitly setting it although it isn't required.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the detailed list, I wasn't aware that case 3 behaves this way. Although it's the most logical thing to do. And from CMake docs:

The cmake_minimum_required() command does more than report an error if a too-old version of CMake is used to build a project. It also sets all policies introduced in that CMake version or earlier to NEW behavior.

# 2. Remove search paths with *_ROOT since they will be automatically checked
cmake_policy(SET CMP0074 NEW)
endif()

set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "possible configurations" FORCE)
Expand Down
2 changes: 1 addition & 1 deletion PCLConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if(POLICY CMP0074)
# 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(PUSH)
cmake_policy(SET CMP0074 OLD)
cmake_policy(SET CMP0074 NEW)
endif()

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/Modules")
Expand Down