diff --git a/HISTORY.rst b/HISTORY.rst index 4a4bd78f..a96d6374 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -19,6 +19,7 @@ PlatformIO Core 5 - Fixed an issue with the NetBeans project generator when the path to PlatformIO contains a space (`issue #4096 `_) - Fixed an issue when the system environment variable does not override a project configuration option (`issue #4125 `_) - Fixed an issue when referencing ``*_dir`` option from a custom project configuration environment (`issue #4110 `_) +- Fixed an issue with the CLion template that generated a broken CMake file if user's home directory contained an unescaped backslash (`issue #4071 `_) 5.2.3 (2021-11-05) ~~~~~~~~~~~~~~~~~~ diff --git a/platformio/project/tpls/clion/CMakeListsPrivate.txt.tpl b/platformio/project/tpls/clion/CMakeListsPrivate.txt.tpl index a7a04ec2..82a4b3a6 100644 --- a/platformio/project/tpls/clion/CMakeListsPrivate.txt.tpl +++ b/platformio/project/tpls/clion/CMakeListsPrivate.txt.tpl @@ -8,15 +8,14 @@ % import os % import re % -% from platformio.compat import WINDOWS -% from platformio.project.helpers import (load_project_ide_data) +% from platformio.project.helpers import load_project_ide_data % % def _normalize_path(path): % if project_dir in path: % path = path.replace(project_dir, "${CMAKE_CURRENT_LIST_DIR}") % elif user_home_dir in path: % if "windows" in systype: -% path = path.replace(user_home_dir, "$ENV{HOMEDRIVE}$ENV{HOMEPATH}") +% path = path.replace(user_home_dir, "${ENV_HOME_PATH}") % else: % path = path.replace(user_home_dir, "$ENV{HOME}") % end @@ -63,6 +62,11 @@ SET(CMAKE_CXX_COMPILER "{{ _normalize_path(cxx_path) }}") SET(CMAKE_CXX_FLAGS "{{ _normalize_path(to_unix_path(cxx_flags)) }}") SET(CMAKE_C_FLAGS "{{ _normalize_path(to_unix_path(cc_flags)) }}") +# Convert "Home Directory" that may contain unescaped backslashes on Windows +% if "windows" in systype: +file(TO_CMAKE_PATH $ENV{HOMEDRIVE}$ENV{HOMEPATH} ENV_HOME_PATH) +% end + % STD_RE = re.compile(r"\-std=[a-z\+]+(\w+)") % cc_stds = STD_RE.findall(cc_flags) % cxx_stds = STD_RE.findall(cxx_flags)