Skip to content

Commit e81a271

Browse files
nordicjmstephanosio
authored andcommitted
cmake: Use /tmp path on linux/mac
This switches to use /tmp as a temporary path on linux and mac since normal users do not generally have write permission to the system location where zephyr SDK files are located, which would otherwise prevent them from registering it. Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
1 parent 6b32f32 commit e81a271

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

cmake/zephyr_sdk_export.cmake

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,19 @@
1212
# Register the Zephyr-sdk package by running `cmake -P zephyr_sdk_export.cmake`
1313
# in this directory.
1414

15+
if(WIN32)
16+
set(MD5_PATH ${CMAKE_CURRENT_LIST_DIR})
17+
else()
18+
set(MD5_PATH "/tmp")
19+
endif()
20+
1521
set(MD5_INFILE "current_path.txt")
1622

1723
# We write CMAKE_CURRENT_LIST_DIR into MD5_INFILE, as the content of that file
1824
# will be used for MD5 calculation. This means we effectively get the MD5 of
1925
# CMAKE_CURRENT_LIST_DIR which must be used for CMake user package registry.
20-
file(WRITE ${CMAKE_CURRENT_LIST_DIR}/${MD5_INFILE} ${CMAKE_CURRENT_LIST_DIR})
21-
execute_process(COMMAND ${CMAKE_COMMAND} -E md5sum ${CMAKE_CURRENT_LIST_DIR}/${MD5_INFILE}
26+
file(WRITE ${MD5_PATH}/${MD5_INFILE} ${CMAKE_CURRENT_LIST_DIR})
27+
execute_process(COMMAND ${CMAKE_COMMAND} -E md5sum ${MD5_PATH}/${MD5_INFILE}
2228
OUTPUT_VARIABLE MD5_SUM
2329
)
2430
string(SUBSTRING ${MD5_SUM} 0 32 MD5_SUM)
@@ -40,4 +46,4 @@ else()
4046
message("~/.cmake/packages/Zephyr-sdk\n")
4147
endif()
4248

43-
file(REMOVE ${CMAKE_CURRENT_LIST_DIR}/${MD5_INFILE})
49+
file(REMOVE ${MD5_PATH}/${MD5_INFILE})

0 commit comments

Comments
 (0)