On 08/05/2017 07:58 PM, Craig Scott wrote: > target_link_libraries(foo PRIVATE "-framework AppKit") > > Strangely, with the library quoted as above, the embedded space > is not escaped, leading to the (desirable but surprising) result
Link flags starting in `-` are treated as a raw part of the command line. That's how it evolved historically. > As extra context, a correct final linker command line can also be achieved > like this: > > find_library(APPKIT_LIB AppKit) > target_link_libraries(foo PRIVATE ${APPKIT_LIB}) > > In this case, while APPKIT_LIB contains a full absolute path to the > framework, CMake manages to recognise it as a framework and shortens > the linker flags to just -framework AppKit. There is special case logic for this, but IMO it was a mistake. Ideally when find_library finds a framework library it should return the absolute path to the library file within the framework, e.g. `/path/to/foo.framework/foo`. Then no special logic would be needed to recognize it and the library file can be passed directly on link lines. All the Modules/Find*.cmake modules that provide imported targets have special logic to transform the find_library result in this way. Perhaps we should fix this with a policy. Also the points raised in Eric Wing's response are valid concerns. -Brad -- 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: http://public.kitware.com/mailman/listinfo/cmake-developers