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

Enable C++ 14 flags #2690

Merged
merged 2 commits into from
Dec 7, 2018
Merged

Conversation

SergioRAgostinho
Copy link
Member

@SergioRAgostinho SergioRAgostinho commented Dec 6, 2018

This pull request enables C++14 flag for the library, effectively making a C++14 supporting compiler an official requirement. If desired, the user may request to build the library with even newer standard by passing e.g. -DCMAKE_CXX_STANDARD=17 option to CMake.

Note that the flag is not exported to PCLConfig.cmake. This means that downstream projects linking against PCL have to explicitly set the flag. This is done to support e.g. using PCL built with C++14 together with downstream projects built with C++17.

@taketwo
Copy link
Member

taketwo commented Dec 6, 2018

We had one more item on the "switching on c++14" list:

It turned out this may be problematic on MSVC: #2382 (comment). However, I think it will still be helpful if we have such thing working for at least Ubuntu/macOS.

@taketwo
Copy link
Member

taketwo commented Dec 7, 2018

Thanks Sérgio. I have updated the PR summary to describe what's going on in more detail.

@taketwo taketwo merged commit 157ad25 into PointCloudLibrary:master Dec 7, 2018
@SergioRAgostinho SergioRAgostinho added the changelog: new feature Meta-information for changelog generation label Dec 7, 2018
@SunBlack
Copy link
Contributor

SunBlack commented Dec 7, 2018

Maybe we should force VS 2015 as minimum requirement - depends on which C++ features you want to use.

@taketwo
Copy link
Member

taketwo commented Dec 7, 2018

Aren't we implicitly forcing this by setting CMAKE_CXX_STANDARD_REQUIRED to ON?

@SunBlack
Copy link
Contributor

SunBlack commented Dec 7, 2018

Never tried if this checks works, but we have implemented this just in root CMakeLists of PCL and not in PCLConfig.cmake. For installed PCL, check in pcl_config.h.in was introduced - but MSVC version check is excluded there. We could check for _MSC_VER < 1900 (see here), but with this check we don't know if it is 15.3 and below or higher (this check would be nice for e.g. #2694). But better than nothing.

@taketwo
Copy link
Member

taketwo commented Dec 7, 2018

I see your point. I don't really have an opinion here though, I'm not a Windows user. Maybe we wait some time and see how many people show up and file issues. If there are only few, perhaps we don't need this check.

@jasjuang
Copy link
Contributor

jasjuang commented Dec 7, 2018

I am a bit late to the party. In order to not having downstream projects linking against PCL having to explicitly set the c++14 flag, it's a better idea to use something like

target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_14)

so when the downstream target link against pcl targets the c++14 flags will be propagated along with it.

Edit: In the case where the downstream is using c++17, it won't cause any problems, the c++14 flags from pcl targets will be superseded by c++17 flags without a problem.

@SergioRAgostinho
Copy link
Member Author

So the idea would be declare that in PCLConfig.cmake somewhere around here
https://github.com/PointCloudLibrary/pcl/blob/master/PCLConfig.cmake.in#L588-L627
when we declare the imported targets.

@jasjuang
Copy link
Contributor

jasjuang commented Dec 8, 2018

Manually setting it in PCLConfig.cmake will work too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: new feature Meta-information for changelog generation module: cmake
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants