On 10/31/2016 11:42 AM, Dave Flogeras wrote: > Hi, are static libraries able to be added to a component?
Yes! > > The following minimal example doesn't work as I expected: > > CMAKE_MINIMUM_REQUIRED( VERSION 3.0.0 ) > PROJECT( foo ) > > ADD_LIBRARY( foo foo.c ) > INSTALL( TARGETS foo ARCHIVE DESTINATION lib > RUNTIME DESTINATION bin > LIBRARY DESTINATION bin > COMPONENT bar ) > > INCLUDE( CPack ) > > If I run "make list_install_components" it says "Unspecified" > > However, if I add "SHARED" to the ADD_LIBRARY call (or set > BUILD_SHARED_LIBS), it lists the component as "bar" which is what I'd > expect. > Try something like: INSTALL( TARGETS foo ARCHIVE DESTINATION lib COMPONENT bar RUNTIME DESTINATION bin COMPONENT bar LIBRARY DESTINATION bin COMPONENT bar ) The nesting of brackets "[]" in docs [0], requires a COMPONENT keyword and argument (should you choose to use components) for each kind of target file keyword (ARCHIVE, RUNTIME, LIBRARY, etc..) you use. I believe you get the puzzling behavior varying with STATIC versus SHARED library type because of the way the command is parsed. When building a STATIC library, there is only an ARCHIVE, which has no COMPONENT listed, so you get "Unspecified" when listing components. When building a SHARED library on non-DLL platforms, the binary is a LIBRARY target, which has the COMPONENT "bar" listed. Each kind of target file keyword (ARCHIVE, RUNTIME, LIBRARY, etc..) has its own list of subsequent properties. [0] https://cmake.org/cmake/help/v3.7/command/install.html#installing-targets [1] example in ParaView: https://github.com/Kitware/ParaView/blob/6714c5c4d1e643f451421dd1004d9540d8607524/CMakeLists.txt#L710 > Is this a bug, or by design? I'm attempting to figure out how I can > separate shared/static libraries in my project for different install > types. For example, if I am packaging a binary only install, I don't > need to install static libraries, but I would need the runtime libraries. > > Dave > > -- 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