Xcode: Linking to framework targets is not correct
Please see below minimal example,
cmake_minimum_required(VERSION 3.20)
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
add_library(sampleframework sample.cpp sample.h)
set_target_properties(sampleframework PROPERTIES FRAMEWORK TRUE PUBLIC_HEADER
sample.h)
add_executable(sampleapp main.cpp)
target_link_libraries(sampleapp sampleframework)
If I generate a Makefile based project, e.g. cmake ..
, make VERBOSE=1
, this will be correct because when compiling sampleapp
, there will be -F/Users/Jason/sample/build/lib
in it.
However, if I generate a Xcode based project, e.g. cmake -G Xcode ..
, cmake --build .
, this will result in compilation error when compiling sampleapp
, because somehow CMake generates -F/Users/Jason/sample/build/bin/Debug
but the framework is in the lib folder not the bin folder, I think this is a bug because CMake should generate -F/Users/Jason/sample/build/lib/Debug
just like how it was able to generate correctly in Makefile based project.
I am on CMake 3.24.2.