From fea7e971128fb72d91c62af6600d5467aec11748 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Sat, 25 May 2019 20:47:39 +0300 Subject: [PATCH] Fix an issue with hardcoded C stadard version when generating project for CLion IDE // Resolve #2527 --- HISTORY.rst | 1 + .../ide/tpls/clion/CMakeListsPrivate.txt.tpl | 23 +++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 8fe10b5e..2b10f752 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -42,6 +42,7 @@ PlatformIO 3.0 ~~~~~~~~~~~~~~~~~~ * Support custom CMake configuration for CLion IDE using ``CMakeListsUser.txt`` file +* Fixed an issue with hardcoded C stadard version when generating project for CLion IDE (`issue #2527 `_) * Fixed "systemd-udevd" warnings in `99-platformio-udev.rules `__ (`issue #2442 `_) * Fixed an issue when ``-U`` in ``build_flags`` does not remove macro previously defined via ``-D`` flag (`issue #2508 `_) * Fixed an issue for Project Generator when include path search order is inconsistent to what passed to the compiler (`issue #2509 `_) diff --git a/platformio/ide/tpls/clion/CMakeListsPrivate.txt.tpl b/platformio/ide/tpls/clion/CMakeListsPrivate.txt.tpl index 0f7c053e..b3d84a75 100644 --- a/platformio/ide/tpls/clion/CMakeListsPrivate.txt.tpl +++ b/platformio/ide/tpls/clion/CMakeListsPrivate.txt.tpl @@ -1,7 +1,12 @@ -# !!! WARNING !!! -# PLEASE DO NOT MODIFY THIS FILE! -# USE https://docs.platformio.org/page/projectconf/section_env_build.html#build-flags +# !!! WARNING !!! AUTO-GENERATED FILE, PLEASE DO NOT MODIFY IT AND USE +# https://docs.platformio.org/page/projectconf/section_env_build.html#build-flags +# +# If you need to override existing CMake configuration or add extra, +# please create `CMakeListsUser.txt` in the root of project. +# The `CMakeListsUser.txt` will not be overwritten by PlatformIO. +% import re +% % def _normalize_path(path): % if project_dir in path: % path = path.replace(project_dir, "${CMAKE_CURRENT_LIST_DIR}") @@ -21,9 +26,17 @@ SET(CMAKE_C_COMPILER "{{ _normalize_path(cc_path) }}") SET(CMAKE_CXX_COMPILER "{{ _normalize_path(cxx_path) }}") SET(CMAKE_CXX_FLAGS_DISTRIBUTION "{{cxx_flags}}") SET(CMAKE_C_FLAGS_DISTRIBUTION "{{cc_flags}}") -set(CMAKE_CXX_STANDARD 11) -% import re +% STD_RE = re.compile(r"\-std=[a-z\+]+(\d+)") +% cc_stds = STD_RE.findall(cc_flags) +% cxx_stds = STD_RE.findall(cxx_flags) +% if cc_stds: +SET(CMAKE_C_STANDARD {{ cc_stds[-1] }}) +% end +% if cxx_stds: +set(CMAKE_CXX_STANDARD {{ cxx_stds[-1] }}) +% end + % for define in defines: add_definitions(-D'{{!re.sub(r"([\"\(\)#])", r"\\\1", define)}}') % end