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 interface compile features to cxx_std_14 on PCL targets #2697

Merged

Conversation

taketwo
Copy link
Member

@taketwo taketwo commented Dec 9, 2018

As proposed in #2690 (comment).

@jasjuang please have a look at the change in PCLConfig. We have two branches depending on CMake version. For the newer version we use qualify compile options with $<COMPILE_LANGUAGE:CXX> to solve some problems you encountered with CUDA targets. Do we need similar qualification for the new compile features?

@taketwo
Copy link
Member Author

taketwo commented Dec 9, 2018

Bad news, cxx_std_14 compile feature was introduced only in CMake 3.8.0.

@SergioRAgostinho
Copy link
Member

It will be ok when we drop support for xenial. I think all add a tag to flag things which can be merged by then.

@taketwo
Copy link
Member Author

taketwo commented Dec 9, 2018

We should find a workaround. I don't want to keep this PR on hold till we drop Xenial 😅

Even though cxx_std_14 is lacking from old CMake, there are plenty of other compile features (which stand for particular standard items, like auto or constexpr). Perhaps we can use some (or several) C++14 features as a proxy for cxx_std_14.

@SergioRAgostinho
Copy link
Member

What if we check the source code for cmake to see if we find the actual list for cxx_std_14?

@SergioRAgostinho
Copy link
Member

SergioRAgostinho commented Dec 9, 2018

There's no list per se. It is populated on the go during the configuration stage. I believe they set the standard flag and try to compile a number of files with specific features from their full list. Whatever passes. We'll need to populate things manually from this list

#define FOR_EACH_CXX_FEATURE(F)                                               \
  F(cxx_std_98)                                                               \
  F(cxx_std_11)                                                               \
  F(cxx_std_14)                                                               \
  F(cxx_std_17)                                                               \
  F(cxx_std_20)                                                               \
  F(cxx_aggregate_default_initializers)                                       \
  F(cxx_alias_templates)                                                      \
  F(cxx_alignas)                                                              \
  F(cxx_alignof)                                                              \
  F(cxx_attributes)                                                           \
  F(cxx_attribute_deprecated)                                                 \
  F(cxx_auto_type)                                                            \
  F(cxx_binary_literals)                                                      \
  F(cxx_constexpr)                                                            \
  F(cxx_contextual_conversions)                                               \
  F(cxx_decltype)                                                             \
  F(cxx_decltype_auto)                                                        \
  F(cxx_decltype_incomplete_return_types)                                     \
  F(cxx_default_function_template_args)                                       \
  F(cxx_defaulted_functions)                                                  \
  F(cxx_defaulted_move_initializers)                                          \
  F(cxx_delegating_constructors)                                              \
  F(cxx_deleted_functions)                                                    \
  F(cxx_digit_separators)                                                     \
  F(cxx_enum_forward_declarations)                                            \
  F(cxx_explicit_conversions)                                                 \
  F(cxx_extended_friend_declarations)                                         \
  F(cxx_extern_templates)                                                     \
  F(cxx_final)                                                                \
  F(cxx_func_identifier)                                                      \
  F(cxx_generalized_initializers)                                             \
  F(cxx_generic_lambdas)                                                      \
  F(cxx_inheriting_constructors)                                              \
  F(cxx_inline_namespaces)                                                    \
  F(cxx_lambdas)                                                              \
  F(cxx_lambda_init_captures)                                                 \
  F(cxx_local_type_template_args)                                             \
  F(cxx_long_long_type)                                                       \
  F(cxx_noexcept)                                                             \
  F(cxx_nonstatic_member_init)                                                \
  F(cxx_nullptr)                                                              \
  F(cxx_override)                                                             \
  F(cxx_range_for)                                                            \
  F(cxx_raw_string_literals)                                                  \
  F(cxx_reference_qualified_functions)                                        \
  F(cxx_relaxed_constexpr)                                                    \
  F(cxx_return_type_deduction)                                                \
  F(cxx_right_angle_brackets)                                                 \
  F(cxx_rvalue_references)                                                    \
  F(cxx_sizeof_member)                                                        \
  F(cxx_static_assert)                                                        \
  F(cxx_strong_enums)                                                         \
  F(cxx_template_template_parameters)                                         \
  F(cxx_thread_local)                                                         \
  F(cxx_trailing_return_types)                                                \
  F(cxx_unicode_literals)                                                     \
  F(cxx_uniform_initialization)                                               \
  F(cxx_unrestricted_unions)                                                  \
  F(cxx_user_literals)                                                        \
  F(cxx_variable_templates)                                                   \
  F(cxx_variadic_macros)                                                      \
  F(cxx_variadic_templates)

More info about each over here
The features known to this version of CMake are:

cxx_std_98
Compiler mode is aware of C++ 98.

cxx_std_11
Compiler mode is aware of C++ 11.

cxx_std_14
Compiler mode is aware of C++ 14.

cxx_std_17
Compiler mode is aware of C++ 17.

cxx_std_20
Compiler mode is aware of C++ 20.

cxx_aggregate_default_initializers
Aggregate default initializers, as defined in N3605_.

.. _N3605: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3605.html

cxx_alias_templates
Template aliases, as defined in N2258_.

.. _N2258: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2258.pdf

cxx_alignas
Alignment control alignas, as defined in N2341_.

.. _N2341: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2341.pdf

cxx_alignof
Alignment control alignof, as defined in N2341_.

.. _N2341: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2341.pdf

cxx_attributes
Generic attributes, as defined in N2761_.

.. _N2761: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2761.pdf

cxx_attribute_deprecated
[[deprecated]] attribute, as defined in N3760_.

.. _N3760: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3760.html

cxx_auto_type
Automatic type deduction, as defined in N1984_.

.. _N1984: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1984.pdf

cxx_binary_literals
Binary literals, as defined in N3472_.

.. _N3472: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3472.pdf

cxx_constexpr
Constant expressions, as defined in N2235_.

.. _N2235: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2235.pdf

cxx_contextual_conversions
Contextual conversions, as defined in N3323_.

.. _N3323: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3323.pdf

cxx_decltype_incomplete_return_types
Decltype on incomplete return types, as defined in N3276_.

.. _N3276 : http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3276.pdf

cxx_decltype
Decltype, as defined in N2343_.

.. _N2343: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2343.pdf

cxx_decltype_auto
decltype(auto) semantics, as defined in N3638_.

.. _N3638: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3638.html

cxx_default_function_template_args
Default template arguments for function templates, as defined in DR226_

.. _DR226: http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#226

cxx_defaulted_functions
Defaulted functions, as defined in N2346_.

.. _N2346: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2346.htm

cxx_defaulted_move_initializers
Defaulted move initializers, as defined in N3053_.

.. _N3053: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3053.html

cxx_delegating_constructors
Delegating constructors, as defined in N1986_.

.. _N1986: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1986.pdf

cxx_deleted_functions
Deleted functions, as defined in N2346_.

.. _N2346: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2346.htm

cxx_digit_separators
Digit separators, as defined in N3781_.

.. _N3781: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3781.pdf

cxx_enum_forward_declarations
Enum forward declarations, as defined in N2764_.

.. _N2764: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2764.pdf

cxx_explicit_conversions
Explicit conversion operators, as defined in N2437_.

.. _N2437: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2437.pdf

cxx_extended_friend_declarations
Extended friend declarations, as defined in N1791_.

.. _N1791: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1791.pdf

cxx_extern_templates
Extern templates, as defined in N1987_.

.. _N1987: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1987.htm

cxx_final
Override control final keyword, as defined in N2928_, N3206_ and N3272_.

.. _N2928: http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2009/n2928.htm
.. _N3206: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3206.htm
.. _N3272: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3272.htm

cxx_func_identifier
Predefined __func__ identifier, as defined in N2340_.

.. _N2340: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2340.htm

cxx_generalized_initializers
Initializer lists, as defined in N2672_.

.. _N2672: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2672.htm

cxx_generic_lambdas
Generic lambdas, as defined in N3649_.

.. _N3649: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3649.html

cxx_inheriting_constructors
Inheriting constructors, as defined in N2540_.

.. _N2540: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2540.htm

cxx_inline_namespaces
Inline namespaces, as defined in N2535_.

.. _N2535: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2535.htm

cxx_lambdas
Lambda functions, as defined in N2927_.

.. _N2927: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2927.pdf

cxx_lambda_init_captures
Initialized lambda captures, as defined in N3648_.

.. _N3648: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3648.html

cxx_local_type_template_args
Local and unnamed types as template arguments, as defined in N2657_.

.. _N2657: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2657.htm

cxx_long_long_type
long long type, as defined in N1811_.

.. _N1811: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1811.pdf

cxx_noexcept
Exception specifications, as defined in N3050_.

.. _N3050: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3050.html

cxx_nonstatic_member_init
Non-static data member initialization, as defined in N2756_.

.. _N2756: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2756.htm

cxx_nullptr
Null pointer, as defined in N2431_.

.. _N2431: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2431.pdf

cxx_override
Override control override keyword, as defined in N2928_, N3206_
and N3272_.

.. _N2928: http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2009/n2928.htm
.. _N3206: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3206.htm
.. _N3272: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3272.htm

cxx_range_for
Range-based for, as defined in N2930_.

.. _N2930: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2930.html

cxx_raw_string_literals
Raw string literals, as defined in N2442_.

.. _N2442: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2442.htm

cxx_reference_qualified_functions
Reference qualified functions, as defined in N2439_.

.. _N2439: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2439.htm

cxx_relaxed_constexpr
Relaxed constexpr, as defined in N3652_.

.. _N3652: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3652.html

cxx_return_type_deduction
Return type deduction on normal functions, as defined in N3386_.

.. _N3386: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3386.html

cxx_right_angle_brackets
Right angle bracket parsing, as defined in N1757_.

.. _N1757: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1757.html

cxx_rvalue_references
R-value references, as defined in N2118_.

.. _N2118: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2118.html

cxx_sizeof_member
Size of non-static data members, as defined in N2253_.

.. _N2253: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2253.html

cxx_static_assert
Static assert, as defined in N1720_.

.. _N1720: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1720.html

cxx_strong_enums
Strongly typed enums, as defined in N2347_.

.. _N2347: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2347.pdf

cxx_thread_local
Thread-local variables, as defined in N2659_.

.. _N2659: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2659.htm

cxx_trailing_return_types
Automatic function return type, as defined in N2541_.

.. _N2541: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2541.htm

cxx_unicode_literals
Unicode string literals, as defined in N2442_.

.. _N2442: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2442.htm

cxx_uniform_initialization
Uniform initialization, as defined in N2640_.

.. _N2640: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2640.pdf

cxx_unrestricted_unions
Unrestricted unions, as defined in N2544_.

.. _N2544: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2544.pdf

cxx_user_literals
User-defined literals, as defined in N2765_.

.. _N2765: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2765.pdf

cxx_variable_templates
Variable templates, as defined in N3651_.

.. _N3651: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3651.pdf

cxx_variadic_macros
Variadic macros, as defined in N1653_.

.. _N1653: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1653.htm

cxx_variadic_templates
Variadic templates, as defined in N2242_.

.. _N2242: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2242.pdf

cxx_template_template_parameters
Template template parameters, as defined in ISO/IEC 14882:1998.

@taketwo
Copy link
Member Author

taketwo commented Dec 9, 2018

I can confirm that with CMake 3.5.1 and GCC 5.5.0 adding the following line

target_compile_features(target_name PUBLIC "cxx_attribute_deprecated")

results in -std=gnu++14 flag being added. So for now I propose to update this PR with a special case for old CMake where cxx_attribute_deprecated is used instead of cxx_std_14. Will do so after receiving feedback from @jasjuang.

@jasjuang
Copy link
Contributor

Looks great to me. And there's no need to add $<COMPILE_LANGUAGE:CXX> because NVCC can recognize it.

For CMake older than 3.8 fall back to using cxx_attribute_deprecated
since the former did not exist yet.
Copy link
Member

@SergioRAgostinho SergioRAgostinho left a comment

Choose a reason for hiding this comment

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

Something is going on with the Ubuntu build. Either the CMake version check is not working as expected or the cxx_std_14 is being added implicitly with cxx_attribute_deprecated.

@@ -192,6 +192,7 @@ endmacro()
# ARGN The source files for the library.
macro(PCL_ADD_LIBRARY _name _component)
add_library(${_name} ${PCL_LIB_TYPE} ${ARGN})
target_compile_features(${_name} PUBLIC ${PCL_CXX_COMPILE_FEATURES})
Copy link
Member

Choose a reason for hiding this comment

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

Are we required to add them here when we're explicitly requesting C++14 in the root CMakeLists.txt?

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 probably not necessary.

@taketwo
Copy link
Member Author

taketwo commented Dec 10, 2018

Something is going on with the Ubuntu build.

Which one? So far I don't see any problems. The "Tutorials" pipeline is broken, but corresponding pipeline YAML file does not exist in this branch, so it's ok.

@SergioRAgostinho
Copy link
Member

I have the impression I reviewed an old version of the code, just moments before you pushed your latest commit. In the meantime the windows x64 build failed with

2018-12-10T22:21:32.2919439Z "D:\a\build\ALL_BUILD.vcxproj" (default target) (1) ->
2018-12-10T22:21:32.2919493Z "D:\a\build\surface\pcl_surface.vcxproj" (default target) (19) ->
2018-12-10T22:21:32.2919544Z (Link target) -> 
2018-12-10T22:21:32.2919652Z   C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(720,5): error MSB6006: "link.exe" exited with code 1. [D:\a\build\surface\pcl_surface.vcxproj]
2018-12-10T22:21:32.2919695Z 
2018-12-10T22:21:32.2919739Z     135 Warning(s)
2018-12-10T22:21:32.2919784Z     1 Error(s)
2018-12-10T22:21:32.2925429Z 
2018-12-10T22:21:32.2925541Z Time Elapsed 01:37:45.63

@UnaNancyOwen is this PR generating any issues for you?

@taketwo
Copy link
Member Author

taketwo commented Dec 11, 2018

That was a spurious error, I'm sure I've seen it before. Would be nice to understand why it happens and how to minimize the occurrence rate though.

I've restarted the pipeline and it's alright now, so we are ready to merge I'd say.

@SergioRAgostinho SergioRAgostinho merged commit 60f2b29 into PointCloudLibrary:master Dec 11, 2018
@taketwo taketwo deleted the set-compile-features branch December 11, 2018 13:11
@taketwo taketwo changed the title Set interface compile features to cxx_std_14 on PCL targets Set interface compile features to cxx_std_14 on PCL targets Jan 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants