[CMake] UNC-path issue in lists used in set and get_filename_component
Markus Schwarzenberg
schwarzb at ipms.fraunhofer.de
Fri Nov 14 05:07:39 EST 2008
Hello,
i'm using cmake (2.6.2/WIN32) and running into problems with UNC-paths used
in the set variant
set(<variable> <value> CACHE <type> <docstring> )
when <value> is a list (of paths) and <type> is FILEPATH. In this case,
the (essential) double slashes // at the beginning of UNC path list
components get truncated to single slashes, resulting in invalid paths.
The same problem exists with
get_filename_component(<variable> <value> PATH)
Please consider the following test case:
set (TESTRUN_VAR1 "//server/dir1/file1.txt" "//server/dir1/file2.txt" CACHE STRING "TESTRUN_VAR1")
message("1: TESTRUN_VAR1 = ${TESTRUN_VAR1}" )
set (TESTRUN_VAR2 "//server/dir1/file1.txt" "//server/dir1/file2.txt" CACHE FILEPATH "TESTRUN_VAR2")
message("2: TESTRUN_VAR2 = ${TESTRUN_VAR2}" )
set (TESTRUN_VAR3 "//server/dir1/file1.txt" "//server/dir1/file2.txt" )
message("3: TESTRUN_VAR3 = ${TESTRUN_VAR3}" )
set (TESTRUN_VAR4 "//server/dir1/file1.txt" CACHE FILEPATH "TESTRUN_VAR4")
message("4: TESTRUN_VAR4 = ${TESTRUN_VAR4}" )
get_filename_component(__OUT "${TESTRUN_VAR1}" PATH)
message("5: get_filename_component (TESTRUN_VAR1 PATH) = ${__OUT}")
get_filename_component(__OUT "${TESTRUN_VAR4}" PATH)
message("6: get_filename_component (TESTRUN_VAR4 PATH) = ${__OUT}")
Output:
1: TESTRUN_VAR1 = //server/dir1/file1.txt;//server/dir1/file2.txt
2: TESTRUN_VAR2 = /server/dir1/file1.txt;/server/dir1/file2.txt
3: TESTRUN_VAR3 = //server/dir1/file1.txt;//server/dir1/file2.txt
4: TESTRUN_VAR4 = //server/dir1/file1.txt
5: get_filename_component (TESTRUN_VAR1 PATH) = /server/dir1/file1.txt;/server/dir1
6: get_filename_component (TESTRUN_VAR4 PATH) = //server/dir1
Conclusions:
1: set works correctly when CACHE STRING is used instead of CACHE FILEPATH
2: set is wrong when CACHE FILEPATH is used
3: set works correctly whithout using CACHE ...
4: set works correctly with CACHE FILEPATH when <value> is NOT a list
5: get_filename_component( ... PATH) is wrong when <value> is a list
6: get_filename_component( ... PATH) works correctly when <value> is a NOT list
These issues are of practical relevance for example in Find_Package(Boost).
resulting in illegal paths when Boost is located using an UNC-Path.
Is this a known issue, shall i file a bug report, or is the usage of
lists in the above examples wrong ...?
--
Markus Schwarzenberg
More information about the CMake
mailing list