Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install Uno via CMake install #35

Open
cvanaret opened this issue Oct 19, 2024 · 5 comments
Open

Install Uno via CMake install #35

cvanaret opened this issue Oct 19, 2024 · 5 comments
Assignees
Labels

Comments

@cvanaret
Copy link
Owner

Add support to CMake install.

@cvanaret cvanaret self-assigned this Oct 19, 2024
@cvanaret
Copy link
Owner Author

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

@amontoison
Copy link
Contributor

amontoison commented Dec 11, 2024

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
Copy link
Contributor

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

@cvanaret
Copy link
Owner Author

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.

@amontoison
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants