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

please remove target_compile_features from INTERFACE #42

Open
ObiWahn opened this issue Nov 4, 2017 · 3 comments
Open

please remove target_compile_features from INTERFACE #42

ObiWahn opened this issue Nov 4, 2017 · 3 comments
Assignees

Comments

@ObiWahn
Copy link

ObiWahn commented Nov 4, 2017

The automatically appended --std=gnu++11 overrides the --std=c++1z of my project. It is a shame that cmake does not support unfinished standards.

@ObiWahn
Copy link
Author

ObiWahn commented Nov 5, 2017

I did a bit research on this:

  • since cmake 3.8 c++17 is supported
  • target_compile_features(mylib INTERFACE cxx_std_17) in the including target should fix the problem
  • set(CMAKE_CXX_STDANDARD 17) in the including project fixes the problem
  • the patch below could work for most people using CMake below v3.8
list(FIND "${CMAKE_CXX_FLAGS}" "-std=c++1z" use1z)
list(FIND "${CMAKE_CXX_FLAGS}" "-std=c++17" use17)
if(use1z LESS 0 AND use17 LESS 0)
# CMAKE_CXX_STANDARD 17 - is availalbe with cmake 3.8
# if the including project defines the correct standard
# this check should not be required

# mpl requires a number of features to compile, this will automatically set the c++ standard version
# to support those features. The c++ version is not explicitly set, so that cmake can figure
# things out by itself
target_compile_features(kvasir_mpl INTERFACE
        cxx_variadic_templates
        cxx_constexpr
        cxx_alias_templates
        cxx_auto_type
        cxx_long_long_type
        cxx_right_angle_brackets
        cxx_static_assert
        cxx_uniform_initialization
        cxx_user_literals
        ${CPP_EXTRA_FEATURES})
endif()

@chieltbest chieltbest self-assigned this Nov 5, 2017
@chieltbest
Copy link
Contributor

I agree that we should probably conditionally remove the compile features as I have had problems with it as well, however I wonder if it wouldn't be better to search for "-std=" instead, as that would also include other versions.
Just checking the opinion on this as it might create some problems instead that I don't know of.

@ObiWahn
Copy link
Author

ObiWahn commented Nov 5, 2017

I would try to upgrade to 3.8. For versions below setting the flag is the only way to get c++17 support, from my perspective it is the only valid usage of the flag (-std=...) as part of CMAKE_CXX_FLAGS. That is why I did not consider other possible combinations. The "gnu" versions of the flags should probably be checked as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants