Hi,
Consider the following example make file (it assumes a foo.txt and
foo.cc -- can be both empty) are present:
cmake_minimum_required(VERSION 2.8.12)
add_library(lib_example STATIC "foo.cc" "foo.txt")
get_target_property(sources lib_example SOURCES)
foreach(source ${sources})
MESSAGE("${source}")
endforeach()
When using CMake 2.8.12, you'll see:
build$ cmake ..
foo.cc
/home/berteun/tmp/cmake/foo.txt
Note that it displays the full path for foo.txt! With later CMake
versions (3.1 and up is my suspicion), it will display:
build$ cmake ..
foo.cc
foo.txt
I tried looking trough the release notes, and I've found that
add_library gained support for generator expressions in 3.1, but I
haven't found any explicit mention that would explain this behaviour.
Does anyone know why it changed? And secondly, is there a way to get
the 2.8 behaviour back?
To be precise, I'd like to get accumulate the various .txt from
different targets (including targets the current target depends on);
in CMake 2.8 this was doable by collecting the dependencies, iterating
over these targets and making a list of the .txt files; these would
contain the full path. From 3.1 onwards, this is not the case; so if
you do a get_filename_component on them requesting the absolue path,
you won't get the actual path anymore, you'll get a path that is a
combination of the current targets source directory and the filename.
So the more general question is, is there a canonical way to get the
full path to a source file by looking at the SOURCES of a target? It
seems that for some filetypes this happened to work by accident in
CMake 2.8 and 3.0?
Thanks,
-Berteun
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
information on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake