[CMake] Framework installation problems with ninja
Shoaib Meenai
smeenai at fb.com
Wed Jun 27 20:16:44 EDT 2018
Let's say I have a simple CMakeLists.txt:
cmake_minimum_required(VERSION 3.11)
project(foo C)
add_subdirectory(foo)
foo/CMakeLists.txt looks like:
add_library(foo SHARED foo.c)
set_target_properties(foo
PROPERTIES
FRAMEWORK ON
FRAMEWORK_VERSION A)
install(TARGETS foo
FRAMEWORK DESTINATION Frameworks)
add_custom_target(install-foo
DEPENDS foo
COMMAND echo "Installing")
An actual useful install-foo target would do something along the lines of `cmake -P cmake_install.cmake`, but we don't need that to demonstrate the issue. foo.c is also irrelevant; it could even be empty.
With CMake 3.11.4 and when using the Ninja generator, my custom install-foo target ends up transitively depending on "foo/foo.framework/foo", which doesn't exist and causes a build error. There is a "foo.framework/foo" target, which is just a phony target depending on "foo/foo.framework/Versions/A/foo" (which is the actual library), and I suspect that's the actual desired dependency, but instead, the subdirectory is being incorrectly prepended to the dependency name.
This works correctly when using the Makefile generator instead of the Ninja generator. It works with the Ninja generator if my framework target is in the top-level CMakeLists.txt instead of a subdirectory, but that's not a viable workaround for my use case.
Am I doing something wrong, or is this a bug with CMake's Ninja generator? If it's the latter, any thoughts on how to work around it? I suppose I could try to manually create the "foo/foo.framework/foo" target, but that seems kinda gross.
Thanks,
Shoaib Meenai
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180628/7380e3b5/attachment-0001.html>
More information about the CMake
mailing list