MantisBT - CMake
View Issue Details
0011973CMake(No Category)public2011-03-15 15:322011-06-17 18:40
Aaron Simmons 
Brad King 
normalmajoralways
closedfixed 
MacOS X10.6
CMake 2.8.4 
CMake 2.8.5CMake 2.8.5 
0011973: double-slashes in paths breaks dependency resolution
Concatenating paths often leads to double-slashes. Most software seems to be able to deal with this, including CMake (2.8.3 and previous). However, CMake 2.8.4 can't handle it.

1) Here is an example CMakeLists.txt:
            cmake_minimum_required(VERSION 2.8.4)
            project(test)

            set(dir_to ${CMAKE_BINARY_DIR}/files/) # note the trailing sash

            set(myfile_from ${CMAKE_CURRENT_SOURCE_DIR}/myfile.txt)
            set(myfile_to ${dir_to}/myfile.txt)
            get_filename_component( parent_to ${myfile_to} PATH )

            message("${myfile_from} => ${myfile_to}")

            ADD_CUSTOM_COMMAND(
              OUTPUT ${myfile_to}
              COMMAND ${CMAKE_COMMAND} -E make_directory ${dir_to}
              COMMAND ${CMAKE_COMMAND} -E copy ${myfile_from} ${myfile_to}
              DEPENDS ${myfile_from}
             )
            add_custom_target(copyit DEPENDS ${myfile_to})

2) Run it:
asimmons-mac:.build asimmons$ rm -rf *; cmake ..; make copyit
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Checking whether C compiler has -isysroot
-- Checking whether C compiler has -isysroot - yes
-- Checking whether C compiler supports OSX deployment target flag
-- Checking whether C compiler supports OSX deployment target flag - yes
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Checking whether CXX compiler has -isysroot
-- Checking whether CXX compiler has -isysroot - yes
-- Checking whether CXX compiler supports OSX deployment target flag
-- Checking whether CXX compiler supports OSX deployment target flag - yes
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
/Users/asimmons/Development/test/cmake/myfile.txt => /Users/asimmons/Development/test/cmake/.build/files//myfile.txt
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/asimmons/Development/test/cmake/.build
Scanning dependencies of target copyit
make[3]: *** No rule to make target `files/myfile.txt', needed by `CMakeFiles/copyit'. Stop.
make[2]: *** [CMakeFiles/copyit.dir/all] Error 2
make[1]: *** [CMakeFiles/copyit.dir/rule] Error 2
make: *** [copyit] Error 2

3) Removing the trailing slash from line 4 will workaround the problem.

Notice that the error output (*** No rule to make target `files/myfile.txt') has removed the double-slash. It seems like part of CMake can deal with the double-slash, but others can't.

Since previous CMake verions (2.8.3-) could deal with double-slashes, I assume that this is a bug. If its deliberate, I urge you to consider the pain involved in constantly checking path concatenations for double slashes. At least provide some kind of "path concat" function.
No tags attached.
related to 0010485closed Brad King add_custom_command searches literally for file name targets 
Issue History
2011-03-15 15:32Aaron SimmonsNew Issue
2011-03-29 18:09Brad KingRelationship addedrelated to 0010485
2011-03-29 18:09Brad KingAssigned To => Brad King
2011-03-29 18:09Brad KingStatusnew => assigned
2011-03-29 18:11Brad KingNote Added: 0025958
2011-03-29 18:20Brad KingNote Added: 0025959
2011-03-30 10:05Brad KingNote Added: 0025968
2011-03-30 10:05Brad KingStatusassigned => closed
2011-03-30 10:05Brad KingResolutionopen => fixed
2011-06-17 18:40David ColeFixed in Version => CMake 2.8.5
2011-06-17 18:40David ColeTarget Version => CMake 2.8.5

Notes
(0025958)
Brad King   
2011-03-29 18:11   
This regression appeared in this commit:

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

meant to fix similar issue 0010485.
(0025959)
Brad King   
2011-03-29 18:20   
As linked in 0011973:0025958 the OUTPUTS of add_custom_command are now slash-normalized to match the behavior of add_executable and add_library. The same must now be done for the DEPENDS of add_custom_(target|command).
(0025968)
Brad King   
2011-03-30 10:05   
Fixed and test added:

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