[CMake] Object libraries and relative paths in Ninja
Daniel Eiband
daniel.eiband at brainlab.com
Thu Oct 4 13:11:23 EDT 2018
Hi,
For a simple test I've got the following directory structure:
|- build
|- project
| |- CMakeLists.txt
| |- Main.cpp
|- CMakeLists.txt
|- Test.cpp
project/CMakeLists.txt has the following content:
cmake_minimum_required(VERSION 3.12)
project(Reproducer LANGUAGES CXX)
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/.." "${CMAKE_CURRENT_BINARY_DIR}/..")
add_executable(Reproducer)
target_sources(Reproducer PRIVATE Main.cpp)
target_link_libraries(Reproducer PRIVATE ReproducerLibrary)
And CMakeLists.txt has the following content:
add_library(ReproducerLibrary OBJECT)
target_sources(ReproducerLibrary PRIVATE Test.cpp)
When I now run the commands:
cd build
cmake.exe -G Ninja ..\..\project
cmake.exe --build .
Then I get the error:
ninja: error: '<absolute-path>/ReproducerLibrary.dir/Test.cpp.obj', needed by 'Reproducer.exe', missing and no known rule to make it
I noticed, that the build.ninja the build rule for Test.cpp.obj has a relative path, whereas the link dependency to Test.cpp.obj is an absolute path.
Is this a known issue?
Regards,
Daniel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20181004/7179cb67/attachment.html>
More information about the CMake
mailing list