From f38f48943762a2bc72efd27ef1ee7dbab7ce6ee2 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 27 Sep 2023 19:40:39 -0400 Subject: [PATCH] xo-cmake: + xo_add_shared_library() + misc --- cmake/xo_cxx.cmake | 42 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/cmake/xo_cxx.cmake b/cmake/xo_cxx.cmake index 53cccb58..7fe1c65d 100644 --- a/cmake/xo_cxx.cmake +++ b/cmake/xo_cxx.cmake @@ -47,11 +47,7 @@ macro(xo_toplevel_compile_options) endif() endmacro() -# ---------------------------------------------------------------- -# use this in subdirs that compile c++ code. -# do not use for header-only subsystems; see xo_include_headeronly_options2() -# -macro(xo_include_options2 target) +macro(xo_include_headeronly_options2 target) # ---------------------------------------------------------------- # PROJECT_SOURCE_DIR: # so we can for example write @@ -63,7 +59,7 @@ macro(xo_include_options2 target) # compiler's include path # target_include_directories( - ${target} PUBLIC + ${target} INTERFACE $ # e.g. for #include "indentlog/scope.hpp" $ $ # e.g. for #include "Refcounted.hpp" in refcnt/src @@ -82,7 +78,37 @@ macro(xo_include_options2 target) endif() endmacro() -macro(xo_include_headeronly_options2 target) +# ---------------------------------------------------------------- +# use this for a shared library. +# +macro(xo_add_shared_library target targetversion soversion sources) + add_library(${target} SHARED ${sources}) + foreach(arg IN ITEMS ${ARGN}) + #message("target=${target}; arg=${arg}") + + # to use PUBLIC here would need to split: + # $ + # $ + # but shouldn't need that, since we arrange to install includes via + # xo_include_options2() below + # + target_sources(${target} PRIVATE ${arg}) + endforeach() + set_target_properties( + ${target} + PROPERTIES + VERSION ${targetversion} + SOVERSION ${soversion}) + xo_compile_options(${target}) + xo_include_options2(${target}) + xo_install_library2(${target}) +endmacro() + +# ---------------------------------------------------------------- +# use this in subdirs that compile c++ code. +# do not use for header-only subsystems; see xo_include_headeronly_options2() +# +macro(xo_include_options2 target) # ---------------------------------------------------------------- # PROJECT_SOURCE_DIR: # so we can for example write @@ -94,7 +120,7 @@ macro(xo_include_headeronly_options2 target) # compiler's include path # target_include_directories( - ${target} INTERFACE + ${target} PUBLIC $ # e.g. for #include "indentlog/scope.hpp" $ $ # e.g. for #include "Refcounted.hpp" in refcnt/src