Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
D
dune-common
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 69
    • Issues 69
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 45
    • Merge Requests 45
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Core Modules
  • dune-common
  • Issues
  • #217

Closed
Open
Opened Aug 26, 2020 by Lukas Riedel@lukas.riedelDeveloper

dune_require_cxx_standard() not working on current macOS with AppleClang

System Specs

  • macOS: 10.15.5 (Catalina)
  • AppleClang: 11.0.0
  • CMake: 3.18.2

Problem Description

On recent versions of macOS, dune_require_cxx_standard() is not working and a fallback C++ standard below the standard specified in the command is used.

In our particular problem, we set

dune_require_cxx_standard(MODULE "dorie" VERSION 17)

However, we end up with both a -std=c++17 and a -std=gnu++11 flag in the list of CXX compiler flags. The compiler then uses the lowest standard in the list and cannot compile our code (which is intended for C++17).

Workaround

The problem could be remedied by either

  1. Setting the CXX_STANDARD and CXX_STANDARD_REQUIRED property of the targets explicitly:

    target_set_property(${target} PROPERTIES
        # Set standard to C++17
        CXX_STANDARD 17
         # Avoid "fallback" to lower standards if the compiler does not support the requested one
        CXX_STANDARD_REQUIRED TRUE
    )

    OR...

  2. Setting the C++ standard as target compile feature (preferred solution):

    target_compile_features(${target} PUBLIC cxx_std_17)

Possible Cause

CMake is actually skipping the compiler check. It might therefore not know the supported standard versions by AppleClang v11 or incorrectly set the flags checked in the code of dune_require_cxx_standard(). This might be an issue on CMake side. From the CMake output:

-- The CXX compiler identification is AppleClang 11.0.0.11000033
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Checking for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done

Conclusion

Workaround 1) demonstrates that dune_require_cxx_standard() is somehow failing its purpose on a system with the given specs.

Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: core/dune-common#217