Wilke, Jeremiah J via CMake
2018-12-06 18:55:55 UTC
We are cleaning up the cmake in our project. Targets are not currently exported with namespaces, but ideally should be. However, we have enough users based on the old cmake that we donât want to require people to use the namespaced target (for a while).
I couldnât find recommendations on this in documentation or list archives.
1. Even when the exported target is namespace::imported_lib, this still seems to work:
target_link_libraries(myLib imported_lib)
which I did not understand.
2. AFAIK, you cannot ALIAS an imported target in the config file:
add_library(imported_lib ALIAS namespace::imported_lib)
so that both the namespace and non-namespaced versions are valid
3. It did work to use the following in the config file:
add_library(imported_lib INTERFACE)
target_link_libraries(imported_lib INTERFACE namespace::imported_lib)
but this just feels like the wrong way to do it
Any help would be greatly appreciated.
Thanks,
Jeremy
I couldnât find recommendations on this in documentation or list archives.
1. Even when the exported target is namespace::imported_lib, this still seems to work:
target_link_libraries(myLib imported_lib)
which I did not understand.
2. AFAIK, you cannot ALIAS an imported target in the config file:
add_library(imported_lib ALIAS namespace::imported_lib)
so that both the namespace and non-namespaced versions are valid
3. It did work to use the following in the config file:
add_library(imported_lib INTERFACE)
target_link_libraries(imported_lib INTERFACE namespace::imported_lib)
but this just feels like the wrong way to do it
Any help would be greatly appreciated.
Thanks,
Jeremy