View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0015113CMakeCMakepublic2014-08-27 10:262016-06-10 14:31
Reporterraspy 
Assigned ToKitware Robot 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionmoved 
Platformx86_64OSRedHat Enterprise LinuxOS Version6.4
Product VersionCMake 3.0 
Target VersionFixed in Version 
Summary0015113: <TARGET_BASE> is generated wrong in case of up-leading path
DescriptionWe 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 ReproduceSimple 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
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0036684)
Brad King (manager)
2014-08-27 10:52

TARGET_BASE is not documented for public use. It is an old implementation detail left over from an older approach to .dll/.lib handling on Windows. It won't work at all with the Ninja generator due to differences in the way the command lines get generated. Also there is no official support for application code modifying make rule variables like CMAKE_C_LINK_EXECUTABLE.

One alternative is to use the LINK_FLAGS target property to add the needed flags to each target that needs this.

Another option is to raise discussion on the cmake-developers mailing list and propose an interface to add first-class support for linker map files to CMake.
(0036685)
raspy (reporter)
2014-08-28 04:32

Well, <TARGET_BASE> is explicitly mentioned in CMakeCInformation.cmake:

# variables supplied by the generator at use time
# <TARGET>
# <TARGET_BASE> the target without the suffix
# <OBJECTS>
# <OBJECT>
# <LINK_LIBRARIES>
# <FLAGS>
# <LINK_FLAGS>

I agree that it would be the best if CMake has built-in support for creating linker maps upon linking targets (and for cleaning them as well).
(0042614)
Kitware Robot (administrator)
2016-06-10 14:29

Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.

 Issue History
Date Modified Username Field Change
2014-08-27 10:26 raspy New Issue
2014-08-27 10:52 Brad King Note Added: 0036684
2014-08-28 04:32 raspy Note Added: 0036685
2016-06-10 14:29 Kitware Robot Note Added: 0042614
2016-06-10 14:29 Kitware Robot Status new => resolved
2016-06-10 14:29 Kitware Robot Resolution open => moved
2016-06-10 14:29 Kitware Robot Assigned To => Kitware Robot
2016-06-10 14:31 Kitware Robot Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team