MantisBT - CMake
View Issue Details
0010994CMakeCMakepublic2010-07-15 04:582013-10-07 10:09
Patrick Spendrin 
Brad King 
normalmajoralways
closedfixed 
Windows
CMake-2-8 
 
0010994: Windows: find_* commands can find paths with no drive letter
when using substituted drives on windows, cmake should treat them like real drives. this doesn't happen in the attached testcase.

Our setup:
- substitute any directory with the cmd command subst.
- have a cmake file within that directory, but not within the root directory of that drive. This cmake file tries to find out its location using CMAKE_CURRENT_LIST_FILE and get_filename_component(PATH) to get the parent directory of a directory. When reaching the root directory, just a (back)slash is given instead of the complete drive letter + colon.

To reproduce, please try out the attached zip archive and simply run the runtest.bat batch file. The cmake file in question is in the test subdirectory.

This happens on all windows systems.
No tags attached.
related to 0011153closed  cmake out of source build writes build files at source dirs 
related to 0010072closed Brad King invalid binary path if makefile in root directory 
zip cmake_current_list_file-bug.zip (1,240) 2010-07-15 04:58
https://public.kitware.com/Bug/file/3245/cmake_current_list_file-bug.zip
zip cmake-bug.zip (1,243) 2010-07-15 08:30
https://public.kitware.com/Bug/file/3246/cmake-bug.zip
diff cmake-stat-drives.diff (531) 2010-07-15 12:20
https://public.kitware.com/Bug/file/3247/cmake-stat-drives.diff
diff cmake-root-relative.diff (601) 2010-07-15 15:37
https://public.kitware.com/Bug/file/3250/cmake-root-relative.diff
Issue History
2010-07-15 04:58Patrick SpendrinNew Issue
2010-07-15 04:58Patrick SpendrinFile Added: cmake_current_list_file-bug.zip
2010-07-15 08:30Patrick SpendrinFile Added: cmake-bug.zip
2010-07-15 08:33Patrick SpendrinNote Added: 0021396
2010-07-15 12:20Patrick SpendrinFile Added: cmake-stat-drives.diff
2010-07-15 15:37Patrick SpendrinFile Added: cmake-root-relative.diff
2010-07-15 15:43Patrick SpendrinNote Added: 0021403
2011-01-05 19:25David ColeAssigned To => David Cole
2011-01-05 19:25David ColeStatusnew => assigned
2011-01-05 19:26David ColeRelationship addedrelated to 0011153
2011-10-25 22:25David ColeStatusassigned => backlog
2011-10-25 22:26David ColeAssigned ToDavid Cole =>
2013-03-08 08:04Brad KingRelationship addedrelated to 0010072
2013-04-24 20:26ChrisNote Added: 0032936
2013-04-24 21:32ChrisNote Edited: 0032936bug_revision_view_page.php?bugnote_id=32936#r1132
2013-04-24 23:36ChrisNote Added: 0032939
2013-04-25 09:22Brad KingNote Added: 0032940
2013-04-25 09:22Brad KingAssigned To => Brad King
2013-04-25 09:22Brad KingStatusbacklog => assigned
2013-04-25 09:22Brad KingPlatform => Windows
2013-04-25 09:22Brad KingSummaryget_filename_component ignores substituted drives => Windows: find_* commands can find paths with no drive letter
2013-04-25 09:27Brad KingNote Added: 0032941
2013-04-25 09:32Brad KingNote Added: 0032942
2013-04-29 10:20Brad KingNote Added: 0032957
2013-04-29 10:21Brad KingStatusassigned => resolved
2013-04-29 10:21Brad KingResolutionopen => fixed
2013-10-07 10:09Robert MaynardNote Added: 0034039
2013-10-07 10:09Robert MaynardStatusresolved => closed

Notes
(0021396)
Patrick Spendrin   
2010-07-15 08:33   
ok, skip the first description, here comes the real issue:
when including the file with include() there will not be any problems, when the file is included via find_package() (also see cmake-bug.zip) then the result will be a single slash instead of the correct Z:/.

To reproduce, please unpack cmake-bug.zip and call runtest.bat in that directory (I hope you don't have Z: as a drive already given, in that case simply change the drive letter.)
(0021403)
Patrick Spendrin   
2010-07-15 15:43   
ok, the two patches do the following:
The cmake-stat-drives.diff enables stat on simple drive letters (e.g. C:, Z:, etc.) - this will fail otherwise and thus adding Z: to CMAKE_SYSTEM_PREFIX_PATH in share/cmake-2.8/Modules/Platform/WindowsPaths.cmake will not result in the expected result.
The cmake-root-relative.diff will handle the case where / is given as the only path - in that case, the relative path base will be chosen. This part is restricted to non-cygwin windows, which should not result in any conflicts.
(0032936)
Chris   
2013-04-24 20:26   
(edited on: 2013-04-24 21:32)
This problem is still occurring.

Is there anything I can do to help find a fix. It is making it impossible for me to compile kde on windows

EDIT:

The test case supplied does not fail for me. I guess my problem is similar but not identical.

I will update if any other information is found.

(0032939)
Chris   
2013-04-24 23:36   
Update

While the simple test case does not fail for me. it does show the error occurring

the following is generated when running the script

Z:\build>cmake ..\
-- Building for: Visual Studio 10
-- final import prefix is :- <<Z:/>>
-- final import prefix is :- <</>>
-- Configuring done
-- Generating done
-- Build files have been written to: Z:/build

you can see the drive mysteriously changes from <<Z:/>> to <</>>

the first import prefix is inside include(${CMAKE_CURRENT_SOURCE_DIR}/lib/strigitest/StrigitestConfig.cmake)
the second import prefix is inside find_package(Strigitest REQUIRED)

find_package appears to drop the drive when converting from \ to /

This is also being discussed at
http://permalink.gmane.org/gmane.comp.programming.tools.cmake.devel/6711 [^]
(0032940)
Brad King   
2013-04-25 09:22   
This commit should fix it:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f9eee7f1 [^]

See commit message for explanation.
(0032941)
Brad King   
2013-04-25 09:27   
For reference, here is the context of the discussion linked in 0010994:0032939:

 http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/4374/focus=6693 [^]
(0032942)
Brad King   
2013-04-25 09:32   
With the fix in 0010994:0032940 the cmake-bug.zip example is no longer expected to find the package because nothing tells find_package to look in prefix CMAKE_CURRENT_SOURCE_DIR. Adding

 list(APPEND CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR})

to the example should tell find_package to look there. However, it still fails due to SystemTools::FileIsDirectory failing drive root paths like "z:/". The patch cmake-stat-drives.diff proposed here fixes that so I'm sending it to KWSys upstream:

 http://review.source.kitware.com/#/c/11031/ [^]

and will merge it back into CMake when ready.
(0032957)
Brad King   
2013-04-29 10:20   
Re 0010994:0032942: Fix for FileIsDirectory in KWSys imported to CMake here:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=327c982f [^]
(0034039)
Robert Maynard   
2013-10-07 10:09   
Closing resolved issues that have not been updated in more than 4 months.