CMake import targets, recommended Naming scheme and static/shared libraries

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

CMake import targets, recommended Naming scheme and static/shared libraries

Norbert Lange
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
--

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