Skip to content

Commit 2f8ea81

Browse files
committed
fix: cmake_easy_setup made X-platform
1 parent 0e9c4ba commit 2f8ea81

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

Diff for: cmake/scripts/cmake_easy_setup.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ def get_log(fname) :
6363

6464
userhome = pathlib.Path.home()
6565
if userlibs.is_relative_to(userhome) :
66-
userlibs = "$ENV{HOME}/" + str(userlibs.relative_to(userhome))
66+
userlibs = "~/" + str(userlibs.relative_to(userhome))
6767
if corepath.is_relative_to(userhome) :
68-
corepath = "$ENV{HOME}/" + str(corepath.relative_to(userhome))
68+
corepath = "~/" + str(corepath.relative_to(userhome))
6969

7070
if shargs.sketch :
7171
SOURCEFILE_EXTS = (".c", ".cpp", ".S", ".ino")
@@ -90,8 +90,8 @@ def get_log(fname) :
9090

9191
with open(shargs.output or shargs.sketch/"CMakeLists.txt", "w") as out :
9292
out.write(cmake_template.render(
93-
corepath=corepath,
94-
userlibs=userlibs,
93+
corepath=str(corepath).replace("\\", "\\\\"), # escape backslashes for CMake
94+
userlibs=str(userlibs).replace("\\", "\\\\"),
9595
libs=libs,
9696
scriptfile=scriptname,
9797
tgtname=tgtname,

Diff for: cmake/templates/easy_cmake.cmake

+6-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@ cmake_minimum_required(VERSION 3.21)
77
# STEP 1: set up bases of environment
88
# -----------------------------------------------------------------------------
99

10-
set(CORE_PATH "{{corepath}}")
11-
set(USER_LIBS "{{userlibs}}")
10+
file(REAL_PATH "{{corepath}}" CORE_PATH EXPAND_TILDE)
11+
file(TO_CMAKE_PATH "{{"${CORE_PATH}"}}" CORE_PATH)
12+
13+
file(REAL_PATH "{{userlibs}}" USER_LIBS EXPAND_TILDE)
14+
file(TO_CMAKE_PATH "{{"${USER_LIBS}"}}" USER_LIBS)
15+
1216
set(BOARDNAME "{{boardname or "@board_name_here@"}}")
1317

1418
list(APPEND CMAKE_MODULE_PATH {{"${CORE_PATH}"}}/cmake)

0 commit comments

Comments
 (0)