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
-- 

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

Reply via email to