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

CMakeListsPrivate.txt gets hardcoded `set(CMAKE_CXX_STANDARD 11)` #2527

Closed
SurealCereal opened this issue May 20, 2019 · 1 comment

Comments

2 participants
@SurealCereal
Copy link

commented May 20, 2019

What kind of issue is this?

  • PlatformIO Core.

Configuration

Operating system: Ubuntu 19.04 x64
PlatformIO Version (platformio --version): 3.6.7

Description of problem

The generated CMakeListsPrivate.txt seems to have a "hard-coded" value from platformio/ide/tpls/clion/CMakeLists.txt.tpl. The line set(CMAKE_CXX_STANDARD 11) is added even if platformio.ini contains a C++ version override, say via build_flags=-std=c++14

The next problem occurs if I fix the hard-coded value to set(CMAKE_CXX_STANDARD 14) - the fix will be reset the next time the CMakeListsPrivate.txt is generated.

I am using PlatformIO inside CLion where it works well. File Watchers triggering CMakeList generation seems like a very elegant solution imo :^)

Steps to Reproduce

  1. Create a project using instructions here: https://docs.platformio.org/en/latest/ide/clion.html#integration
  2. Use the included platformio.ini config or similar
  3. Re-index/regenerate CMake files.
  4. Add some C++ 2014 code
  5. Build the project.

Actual Results

CMakeListsPrivate.txt contains set(CMAKE_CXX_STANDARD 11)

Project fails to build

Expected Results

CMakeListsPrivate.txt should contain set(CMAKE_CXX_STANDARD 14)
Project should build successfully.

If problems with PlatformIO Build System:

The content of platformio.ini:

[env:zeroUSB]
platform = atmelsam
board = zeroUSB
framework = arduino
upload_port = /dev/ttyACM0
build_unflags =
    -std=gnu++98
    -std=gnu++11
    -std=c++11
build_flags =
    -std=c++14

Source file to reproduce issue:

// Example C++ 2014 code that fails to compile due to C++ 2011 being set.
template <typename E>
constexpr auto ordinal(E e) noexcept {
    return static_cast<std::underlying_type_t<E>>(e);
}

Additional info

It seems this issue was raised here: #873 which resulted in the hard-coded set(CMAKE_CXX_STANDARD 11) being added to the template. I can update the template on my filesystem, but then it may be overridden in a PlatformIO update, and I have projects that have different language levels; C++ 11, 14, 17.

@ivankravets ivankravets added this to the 4.0 milestone May 21, 2019

@ivankravets ivankravets added this to In progress in PlatformIO 4.0 May 24, 2019

@ivankravets ivankravets modified the milestones: 4.0, 3.6.8 May 25, 2019

@ivankravets ivankravets removed this from In progress in PlatformIO 4.0 May 25, 2019

@ivankravets

This comment has been minimized.

Copy link
Member

commented May 25, 2019

Please re-test with $ pio upgrade --dev.

The next problem occurs if I fix the hard-coded value to set(CMAKE_CXX_STANDARD 14) - the fix will be reset the next time the CMakeListsPrivate.txt is generated.

Fixed in 7beb332

ivankravets added a commit that referenced this issue May 25, 2019

@ivankravets ivankravets modified the milestones: 3.6.8, 4.0 May 27, 2019

@ivankravets ivankravets added this to Done in PlatformIO 4.0 May 27, 2019

@ivankravets ivankravets added this to Done in PlatformIO 4.0 May 29, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.