[CMake] CMake import targets, recommended Naming scheme and static/shared libraries
Norbert Lange
nolange79 at gmail.com
Mon Apr 9 10:00:16 EDT 2018
Hello,
I would like to add support for some software components, that have
not been compiled with CMake.
There are 2 options, either write a Find script or generate configs.
Later option would be more robust, as substantial changes could
be ironed out when the config is version-specific.
*) Import Name scheme
CMake seems to prefer CamelCase for their inbuilt find modules, but
this is troublesome, as usually libraries are lowercase.
eg.:
add_library(foo SHARED)
install(TARGETS foo EXPORT foo-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT foo
)
install(EXPORT foo-targets "${CMAKE_INSTALL_LIBDIR}/cmake"
NAMESPACE Foo::
)
would result in Foo::foo.
Not ideal, from the standpoint of using the CMake automatisms,
lowercase ("library-case") would be best.
*) Static + Shared libraries
often both are available.
is there a recommended suffix (prefix), and would static and non-static
versions be the same COMPONENT or a different one?
add_library(foo-static STATIC)
install(TARGETS foo-static EXPORT foo-targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT foo-static
)
install(EXPORT foo-targets "${CMAKE_INSTALL_LIBDIR}/cmake"
NAMESPACE Foo::
)
So is there any resource describing and weighting these options?
CMake doesnt seem to be particularly well equipped to allow a choice
between static/shared dependencies.
Norbert
More information about the CMake
mailing list