-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Closed
Labels
Description
Your Environment
- Operating System and version: Kubuntu 18.04
- Compiler: gcc 8.2
- PCL Version: 1.8 latest master
Context
I'm trying to use C++17 in code that is also using PCL.
Expected Behavior
In CMake add_compile_options(-std=c++17 -Wall -Wextra) should add C++17 for all targets in the script.
Current Behavior
C++17 is disabled when linking to PCL (target_link_libraries), preventing from using C++17.
I'm not sure why, but commenting the PCL_LIBRARIES in the CMake script then allows to use C++17. Of course then you can't call any PCL function or it will result in a linking error.
Code to Reproduce
CMakeLists.txt
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
project(test_pcl)
add_compile_options(-std=c++17 -Wall -Wextra)
find_package(PCL 1.9.1.99 REQUIRED)
include_directories(
${PCL_INCLUDE_DIRS}
)
add_executable(
test_pcl
test_pcl.cpp
)
target_link_libraries(
test_pcl
stdc++fs # filesystem
${PCL_LIBRARIES} # Comment and C++17 will be enabled
)test_pcl.cpp
#include <filesystem>
#include <iostream>
#include <string>
using std::cout;
using std::endl;
int
main(int, char **)
{
cout << "Test PCL" << endl;
#if __cplusplus >= 201703L
cout << "C++ >= 201703L" << endl;
const std::string dir("/");
for (auto p : std::filesystem::directory_iterator(dir))
cout << p.path() << endl;
#else
cout << "C++ < 201703L" << endl;
#endif
return 0;
}Program output:
Test PCL
C++ < 201703LI have tried forcing per target compile options too with no result:
target_compile_options(
test_pcl
PUBLIC
-std=c++17 -Wall -Wextra
)
Reactions are currently unavailable