build: handle Windows paths during the creation of the lock

This commit is contained in:
Gabriel Ferreira
2022-05-05 16:48:30 -03:00
parent ab7334a287
commit d4cf96cfd0

View File

@@ -54,12 +54,27 @@ function(write_lock)
endforeach()
string(APPEND lock_contents "]\n")
string(REPLACE ":" "', '" PATH_LIST $ENV{PATH})
string(
APPEND
lock_contents
"NS3_MODULE_PATH = ['${PATH_LIST}', '${CMAKE_OUTPUT_DIRECTORY}', '${CMAKE_LIBRARY_OUTPUT_DIRECTORY}']\n"
# Windows variables are separated with ; which CMake also uses to separate
# list items
set(PATH_LIST
"$ENV{PATH};${CMAKE_OUTPUT_DIRECTORY};${CMAKE_LIBRARY_OUTPUT_DIRECTORY}"
)
if(WIN32)
# Windows to unix path conversions can be quite messy, so we replace forward
# slash with double backward slash
string(REPLACE "/" "\\" PATH_LIST "${PATH_LIST}")
# And to print it out, we need to escape these backward slashes with more
# backward slashes
string(REPLACE "\\" "\\\\" PATH_LIST "${PATH_LIST}")
else()
# Unix variables are separated with :
string(REPLACE ":" ";" PATH_LIST "${PATH_LIST}")
endif()
# After getting all entries with their correct paths we replace the ; item
# separator into a Python list of strings written to the lock file
string(REPLACE ";" "', '" PATH_LIST "${PATH_LIST}")
string(APPEND lock_contents "NS3_MODULE_PATH = ['${PATH_LIST}']\n")
cache_cmake_flag(ENABLE_REALTIME "ENABLE_REAL_TIME" lock_contents)
cache_cmake_flag(ENABLE_EXAMPLES "ENABLE_EXAMPLES" lock_contents)