Uno icon indicating copy to clipboard operation
Uno copied to clipboard

Install Uno via CMake install

Open cvanaret opened this issue 1 year ago • 5 comments

Add support to CMake install.

cvanaret avatar Oct 19 '24 13:10 cvanaret

Hi @amontoison, do we need to install a static or a shared library?

cvanaret avatar Dec 11 '24 21:12 cvanaret

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})

amontoison avatar Dec 11 '24 21:12 amontoison

@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.

amontoison avatar Dec 11 '24 21:12 amontoison

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.

cvanaret avatar Dec 11 '24 22:12 cvanaret

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.

amontoison avatar Dec 11 '24 22:12 amontoison