[cmake-developers] [CMake 0011973]: double-slashes in paths breaks dependency resolution

Mantis Bug Tracker mantis at public.kitware.com
Tue Mar 15 15:32:33 EDT 2011


The following issue has been SUBMITTED. 
====================================================================== 
http://public.kitware.com/Bug/view.php?id=11973 
====================================================================== 
Reported By:                Aaron Simmons
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   11973
Category:                   (No Category)
Reproducibility:            always
Severity:                   major
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2011-03-15 15:32 EDT
Last Modified:              2011-03-15 15:32 EDT
====================================================================== 
Summary:                    double-slashes in paths breaks dependency resolution
Description: 
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.



Steps to Reproduce: 
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.



Additional Information: 
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.

====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2011-03-15 15:32 Aaron Simmons  New Issue                                    
======================================================================




More information about the cmake-developers mailing list