-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Add c++20 compile option #6391
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
Add c++20 compile option #6391
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,19 +5,21 @@ cmake_minimum_required(VERSION 3.16.3 FATAL_ERROR) | |||||||||||||||||||||
| set(CMAKE_CXX_STANDARD 17 CACHE STRING "The target C++ standard. PCL requires C++14 or higher.") | ||||||||||||||||||||||
| set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||||||||||||||||||||||
| set(CMAKE_CXX_EXTENSIONS OFF) | ||||||||||||||||||||||
| if("${CMAKE_CXX_STANDARD}" GREATER_EQUAL 17) | ||||||||||||||||||||||
| set(PCL_CXX_COMPILE_FEATURES cxx_std_17) | ||||||||||||||||||||||
| if("${CMAKE_CXX_STANDARD}" GREATER_EQUAL 20) | ||||||||||||||||||||||
| set(PCL__cplusplus 202002L) | ||||||||||||||||||||||
| set(PCL_REQUIRES_MSC_VER 1928) | ||||||||||||||||||||||
| elseif("${CMAKE_CXX_STANDARD}" EQUAL 17) | ||||||||||||||||||||||
| set(PCL__cplusplus 201703L) | ||||||||||||||||||||||
| set(PCL_REQUIRES_MSC_VER 1912) | ||||||||||||||||||||||
| elseif("${CMAKE_CXX_STANDARD}" EQUAL 14) | ||||||||||||||||||||||
| set(PCL_CXX_COMPILE_FEATURES cxx_std_14) | ||||||||||||||||||||||
| set(PCL__cplusplus 201402L) | ||||||||||||||||||||||
| set(PCL_REQUIRES_MSC_VER 1900) | ||||||||||||||||||||||
| else() | ||||||||||||||||||||||
| message(FATAL_ERROR "Unknown or unsupported C++ standard specified") | ||||||||||||||||||||||
| endif() | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| set(CMAKE_CUDA_STANDARD 17 CACHE STRING "The target CUDA/C++ standard. PCL requires CUDA/C++ 14 or higher.") | ||||||||||||||||||||||
| set(PCL_CXX_COMPILE_FEATURES cxx_std_${CMAKE_CXX_STANDARD}) | ||||||||||||||||||||||
|
||||||||||||||||||||||
| set(PCL_CXX_COMPILE_FEATURES cxx_std_${CMAKE_CXX_STANDARD}) | |
| set(PCL_CXX_COMPILE_FEATURES cxx_std_${CMAKE_CXX_STANDARD}) | |
| # Warn users if they attempted to set CMAKE_CUDA_STANDARD independently; it is | |
| # intentionally synchronized with CMAKE_CXX_STANDARD in this project. | |
| if(DEFINED CMAKE_CUDA_STANDARD AND NOT CMAKE_CUDA_STANDARD STREQUAL "${CMAKE_CXX_STANDARD}") | |
| message(WARNING | |
| "CMAKE_CUDA_STANDARD is synchronized with CMAKE_CXX_STANDARD in this project. " | |
| "The provided CMAKE_CUDA_STANDARD ('${CMAKE_CUDA_STANDARD}') will be ignored in " | |
| "favor of CMAKE_CXX_STANDARD='${CMAKE_CXX_STANDARD}'.") | |
| endif() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one we could consider adding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition
GREATER_EQUAL 20will match C++ standards beyond C++20 (such as C++23, C++26, etc.), but sets C++20-specific values forPCL__cplusplus(202002L) andPCL_REQUIRES_MSC_VER(1928). This creates an inconsistency: if a user sets CMAKE_CXX_STANDARD to 23, line 21 would setPCL_CXX_COMPILE_FEATUREStocxx_std_23, butPCL__cpluspluswould remain at the C++20 value (202002L). This could cause incorrect compiler version checks in pcl_config.h.in. Consider either changing toEQUAL 20with additional conditions for newer standards, or update the values to be appropriate for the highest standard being checked.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one we can just leave as is. PCL__cplusplus is only used to check for a minimum requirement.