[cmake-developers] [CMake 0015113]: <TARGET_BASE> is generated wrong in case of up-leading path

Mantis Bug Tracker mantis at public.kitware.com
Wed Aug 27 10:26:26 EDT 2014


The following issue has been SUBMITTED. 
====================================================================== 
http://public.kitware.com/Bug/view.php?id=15113 
====================================================================== 
Reported By:                raspy
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   15113
Category:                   CMake
Reproducibility:            always
Severity:                   minor
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2014-08-27 10:26 EDT
Last Modified:              2014-08-27 10:26 EDT
====================================================================== 
Summary:                    <TARGET_BASE> is generated wrong in case of
up-leading path
Description: 
We use <TARGET_BASE> in platform configuration to instruct linker to create map
file named the same way as target with different extension:

set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER> --run_linker
--output_file=<TARGET> --map_file=<TARGET_BASE>.map <CMAKE_C_LINK_FLAGS>
<LINK_FLAGS> <OBJECTS> <LINK_LIBRARIES>")

However, if <TARGET> is created in upper directory, <TARGET_BASE> is terminated
on the last dot, which happens to be part of directory, i.e.:

Linking C executable ../../out/binary
cd /path/to/source && /path/to/cmake-3.0.0-Linux-i386/bin/cmake -E
cmake_link_script CMakeFiles/binary.dir/link.txt --verbose=1
/path/to/cl6x  --run_linker --output_file=../../out/binary --map_file=../..map
CMakeFiles/binary.dir/tools/dictionary.c.obj  --search_path=/path/to/lib


Steps to Reproduce: 
Simple reproduction on Linux with gcc:

$ cat CMakeLists.txt
set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER> -o <TARGET>
-Wl,-Map,<TARGET_BASE>.map <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS>
<LINK_LIBRARIES>")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out)
add_subdirectory(subdirectory)

$ cat subdirectory/CMakeLists.txt
add_executable(hello hello.c)

$ cat subdirectory/hello.c
#include <stdint.h>

int main(int argc, char *argv[])
{
    return 0;
}

Result:
cd /path/to/cmake-test/subdirectory && /usr/bin/cc    -o
CMakeFiles/hello.dir/hello.o   -c /path/to/cmake-test/subdirectory/hello.c
Linking C executable ../out/hello
cd /path/to/cmake-test/subdirectory && /path/to/cmake-3.0.0-Linux-i386/bin/cmake
-E cmake_link_script CMakeFiles/hello.dir/link.txt --verbose=1
/usr/bin/cc  -o ../out/hello -Wl,-Map,..map    CMakeFiles/hello.dir/hello.o
-rdynamic

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

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2014-08-27 10:26 raspy          New Issue                                    
======================================================================



More information about the cmake-developers mailing list