Hi All, I have been cleaning up our legacy CMake to use newer features (available in 3.12+) including trying to use target_...() functions nearly exclusively. As part of this, I was toying with cleaning up our use cases for adding compiler flags and similar definitions using real targets and target_link_libraries.
For instance, as a simple example, let's say I wanted to add/provide a definition MY_FLAG, I could do something like... ``` add_library(my_flag INTERFACE) target_compile_definitions(my_flag INTERFACE MY_FLAG=1) add_library(other_library SHARED ...) target_link_libraries(other_library ... *PRIVATE *my_flag) export/install rules ``` I want this library to be private to my component, and it's only used under the PRIVATE banner. However, the issue I'm running into is with the install/export rules. I get an error similar to ... ``` CMake Error: install(EXPORT "MY_PROJECT" ...) includes target "other_library" which requires target "my_flag" that is not in the export set. ``` If my_flag is defined in my component, I can add it to the export set perhaps to workaround the issue, but in many cases, it would be coming from a helper script in another sub-project I'm fetching using FetchContent and don't want to expose the functionality via my export scripts. (1) Is it recommended to use interface libraries to clean up compile defintions, etc. (2) Should it be possible to link privately such libraries and not have the export functionality complain? Thanks!
-- 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