Add DIRECT_CYNARA_COMPAT to dissociate libs
authorJosé Bollo <jose.bollo@iot.bzh>
Fri, 4 Oct 2019 15:28:24 +0000 (17:28 +0200)
committerJosé Bollo <jose.bollo@iot.bzh>
Fri, 4 Oct 2019 19:30:12 +0000 (21:30 +0200)
The flag DIRECT_CYNARA_COMPAT remove the dependency
of libcynara-compat to libcynagora.

Change-Id: Ib8ded68fc799a7cdb53acd4416b255abdf765311
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
fixup! 9d08a0b

compat/src/CMakeLists.txt
mkbuild.sh
src/CMakeLists.txt

index 7c8feca..351c560 100644 (file)
 # limitations under the License.
 ###########################################################################
 
+option(DIRECT_CYNARA_COMPAT "cynara compat access server directly without using libcynagora" OFF)
+
 add_compile_definitions(_GNU_SOURCE)
 
 ###########################################
 # build and install libcynara-compat
 ###########################################
-add_library(cynara-compat SHARED lib-compat.c)
+if(DIRECT_CYNARA_COMPAT)
+       add_library(cynara-compat SHARED lib-compat.c $<TARGET_OBJECTS:client-objects>)
+       target_include_directories(cynara-compat PRIVATE ../../src)
+else()
+       add_library(cynara-compat SHARED lib-compat.c)
+       target_link_libraries(cynara-compat PRIVATE cynagora)
+endif()
 target_include_directories(cynara-compat PUBLIC ../include)
 set_target_properties(cynara-compat
        PROPERTIES
@@ -29,9 +37,6 @@ set_target_properties(cynara-compat
                SOVERSION ${CYNARA_SOVERSION}
                LINK_FLAGS -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/export-cynara-compat.map
 )
-target_link_libraries(cynara-compat
-       PRIVATE cynagora
-)
 install(TARGETS cynara-compat LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR})
 
 ###########################################
index e8514ab..8e7db5b 100755 (executable)
@@ -10,6 +10,7 @@ cmake \
        -DCMAKE_INSTALL_PREFIX=~/.local \
        -DWITH_SYSTEMD=ON \
        -DWITH_CYNARA_COMPAT=ON \
+       -DDIRECT_CYNARA_COMPAT=ON \
        ..
 make -j
 
index 8fdb9e7..b69c15f 100644 (file)
@@ -61,13 +61,18 @@ set_target_properties(cynagora-core PROPERTIES
 install(TARGETS cynagora-core LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR})
 
 ###########################################
-# build and install libcynagora-client
+# build client-objects
 ###########################################
-add_library(cynagora SHARED ${LIBCLI_SOURCES})
-target_include_directories(cynagora PUBLIC .)
-target_compile_definitions(cynagora PRIVATE
+add_library(client-objects OBJECT ${LIBCLI_SOURCES})
+target_compile_definitions(client-objects PRIVATE
        DEFAULT_SOCKET_DIR="${DEFAULT_SOCKET_DIR}"
 )
+target_compile_options(client-objects PRIVATE -fPIC)
+
+###########################################
+# build and install libcynagora-client
+###########################################
+add_library(cynagora SHARED $<TARGET_OBJECTS:client-objects>)
 set_target_properties(cynagora PROPERTIES
        VERSION ${CYNAGORA_VERSION}
        SOVERSION ${CYNAGORA_SOVERSION}