On 02-Oct-14 20:56, Alexander Lamaison wrote:
How do you manage the paths to the libraries that your static library
package depends on in the XXXConfig.cmake that gets installed with
package XXX?
I'm exporting my static library package from both the build tree and
from the installation location like
add_library(foo STATIC ...)
target_link_libraries(foo PRIVATE ...)
install(TARGETS foo EXPORT FooConfig ...)
## During package installation, install FooConfig.cmake
install(EXPORT FooConfig NAMESPACE Foo:: DESTINATION lib)
## During build, register directly from build tree
export(TARGETS foo NAMESPACE Foo:: FILE FooConfig.cmake)
export(PACKAGE Foo)
This does a great job of generating a FooConfig.cmake that can be used
by other projects on the local machine. But target foo is linked with
other dependencies, for example, OpenSSH so the installed config file
includes the following:
set_property(TARGET Foo::foo APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
set_target_properties(Foo::foo PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C"
IMPORTED_LINK_INTERFACE_LIBRARIES_DEBUG
"C:/OpenSSL-Win64/lib/VC/ssleay32MDd.lib;C:/OpenSSL-Win64/lib/VC/libeay32MDd.lib;ws2_32"
IMPORTED_LOCATION_DEBUG "${_IMPORT_PREFIX}/lib/libfoo.lib")
You can run `find_package` from FooConfig.cmake:
# FooConfig.cmake.in
@PACKAGE_INIT@
find_package(OpenSSL REQUIRED)
target_link_libraries(Foo::foo ${OPENSSL_LIBRARIES})
target_include_directories(Foo::foo ${OPENSSL_INCLUDE_DIR})
So my question is, in general, how can I make installabled static
libraries with a package config file? Or is the trying to redistribute
static libraries a bad idea in the first place?
It's not related to static/shared, this is about absolute path. If you
have an absolute path for dynamic library in FooConfig.cmake you'll have
the same issue.
--
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