Install Uno via CMake install
Add support to CMake install.
Hi @amontoison, do we need to install a static or a shared library?
It depends what is the CMake option used by the user (-DBUILD_SHARED_LIBS=ON or -DBUILD_SHARED_LIBS=OFF)
But you should be able to handle all cases with something like:
install(TARGETS ${_target}
COMPONENT libuno
EXPORT ${_target}Targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} # DLLs on windows
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} # Static libraries
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} # Shared libraries
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
@cvanaret I think that your current build system only generate static libraries. CMake could do the shared for you but you probably need a few modifications.
Thanks for the example. If I wanted both static and shared libraries to have the same name (not sure it's portable though), I could use something like:
add_library(uno_lib OBJECT ${UNO_SOURCE_FILES})
set_property(TARGET uno_lib PROPERTY POSITION_INDEPENDENT_CODE ON)
add_library(uno_shared SHARED $<TARGET_OBJECTS:uno_lib>)
set_target_properties(uno_shared PROPERTIES OUTPUT_NAME uno)
add_library(uno_static STATIC $<TARGET_OBJECTS:uno_lib>)
set_target_properties(uno_static PROPERTIES OUTPUT_NAME uno)
Do we want to compile with PIC for the shared library and without for the static library? It'll be expensive but it most likely results in the most efficient static library.
It's fine if they have the same name because the extension will be different. You can't generate a shared library without PIC so we need it for that. In Meson, it compiles only the code once when we ask both libraries (shared and static) so you should probably need to hack something to force CMake to compile Uno twice with different compilation options.