Hello, according to the doc for CMake 3.14, target_sources() interprets relative source file paths as being relative to the current source directory, i.e. it should prepend CMAKE_CURRENT_SOURCE_DIR to the relative paths given by the user. However, this is not the case if the target and the sources are defined in the same directory. I attached a simple example to reproduce the issue. The structure of the example is as follows:
- cmake-bug/
- CMakeLists.txt
- main.cpp
- foo/
- CMakeLists.txt
- foo.H
- foo.cpp
- bar/
- CMakeLists.txt
- bar.H
- bar.cpp
Target "main.exe" is defined in the top-level CMakeLists.txt, while its
headers and sources are located in the the top-level directory
and in the sub-directories 'foo' and 'bar'.
After target_sources is used to include all the headers and sources, I
retrieve the "SOURCES" property for `main.exe`: all the sources and headers
but `main.cpp` are given the correct (absolute) path.
Is this the intended behavior? If so, why should a source file located in
the same directory where the target is defined be treated any differently?
Thanks,
Michele
cmake-bug.tar.gz
Description: application/gzip
-- 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: https://cmake.org/mailman/listinfo/cmake
