Isolate compatibility with old cynara
authorJosé Bollo <jose.bollo@iot.bzh>
Thu, 3 Oct 2019 12:33:21 +0000 (14:33 +0200)
committerJosé Bollo <jose.bollo@iot.bzh>
Fri, 4 Oct 2019 14:02:32 +0000 (16:02 +0200)
The compatibility items of the old cynara
librarie are separated and isolated.

The option WITH_CYNARA_COMPAT activates it or not.

Change-Id: Iba77c97d8df31f5f515b57411487943192451ac6
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
29 files changed:
CMakeLists.txt
compat/CMakeLists.txt [new file with mode: 0644]
compat/include/CMakeLists.txt [moved from include/CMakeLists.txt with 100% similarity]
compat/include/cynara/cynara-admin-types.h [moved from include/cynara/cynara-admin-types.h with 100% similarity]
compat/include/cynara/cynara-admin.h [moved from include/cynara/cynara-admin.h with 100% similarity]
compat/include/cynara/cynara-agent.h [moved from include/cynara/cynara-agent.h with 100% similarity]
compat/include/cynara/cynara-client-async.h [moved from include/cynara/cynara-client-async.h with 100% similarity]
compat/include/cynara/cynara-client-plugin.h [moved from include/cynara/cynara-client-plugin.h with 100% similarity]
compat/include/cynara/cynara-client.h [moved from include/cynara/cynara-client.h with 100% similarity]
compat/include/cynara/cynara-creds-commons.h [moved from include/cynara/cynara-creds-commons.h with 100% similarity]
compat/include/cynara/cynara-creds-dbus.h [moved from include/cynara/cynara-creds-dbus.h with 100% similarity]
compat/include/cynara/cynara-creds-gdbus.h [moved from include/cynara/cynara-creds-gdbus.h with 100% similarity]
compat/include/cynara/cynara-creds-self.h [moved from include/cynara/cynara-creds-self.h with 100% similarity]
compat/include/cynara/cynara-creds-socket.h [moved from include/cynara/cynara-creds-socket.h with 100% similarity]
compat/include/cynara/cynara-error.h [moved from include/cynara/cynara-error.h with 100% similarity]
compat/include/cynara/cynara-limits.h [moved from include/cynara/cynara-limits.h with 100% similarity]
compat/include/cynara/cynara-monitor.h [moved from include/cynara/cynara-monitor.h with 100% similarity]
compat/include/cynara/cynara-plugin.h [moved from include/cynara/cynara-plugin.h with 100% similarity]
compat/include/cynara/cynara-policy-types.h [moved from include/cynara/cynara-policy-types.h with 100% similarity]
compat/include/cynara/cynara-session.h [moved from include/cynara/cynara-session.h with 100% similarity]
compat/pkgconfig/CMakeLists.txt [new file with mode: 0644]
compat/pkgconfig/cynara-compat.pc.in [moved from pkgconfig/cynara-compat.pc.in with 100% similarity]
compat/pkgconfig/link-to-cynara-compat.pc [moved from pkgconfig/link-to-cynara-compat.pc with 100% similarity]
compat/src/CMakeLists.txt [new file with mode: 0644]
compat/src/export-cynara-compat.map [moved from src/export-cynara-compat.map with 100% similarity]
compat/src/lib-compat.c [moved from src/lib-compat.c with 100% similarity]
compat/src/main-test-old-cynara.c [moved from src/main-test-old-cynara.c with 100% similarity]
pkgconfig/CMakeLists.txt
src/CMakeLists.txt

index 5879513..f96a1d6 100644 (file)
@@ -44,7 +44,9 @@ set(CYNARA_SOVERSION 1.99)
 
 add_definitions(-DCYNARA_VERSION="${CYNARA_VERSION}")
 
-set(SYSTEMD ON CACHE BOOL "should use systemd")
+option(WITH_SYSTEMD       "should include systemd compatibility" ON)
+option(WITH_CYNARA_COMPAT "produce artifacts for compatibility with cynara" OFF)
+
 set(DEFAULT_DB_DIR "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/cynara"
        CACHE PATH "directory path of the database")
 set(DEFAULT_SOCKET_DIR "${CMAKE_INSTALL_FULL_RUNSTATEDIR}/cynara"
@@ -55,7 +57,6 @@ set(DEFAULT_INIT_FILE "${DEFAULT_CONFIG_DIR}/cynara.initial")
 
 ###########################################################################
 
-include_directories(include)
 link_libraries(-Wl,--as-needed -Wl,--gc-sections -Wl,--no-undefined)
 
 add_compile_options(-Wall -Wextra -Wconversion)
@@ -64,27 +65,22 @@ add_compile_options(-Wno-sign-compare -Wno-sign-conversion)
 add_compile_options(-Werror=maybe-uninitialized)
 add_compile_options(-Werror=implicit-function-declaration)
 add_compile_options(-ffunction-sections -fdata-sections)
-add_compile_options(-fPIC)
-add_compile_options(-g)
-add_compile_options(-fstack-protector -D_FORTIFY_SOURCE=2 -O2)
-add_compile_options(-ffile-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}=.)
-
-set(CMAKE_C_FLAGS_PROFILING    "-g -O2 -pg")
-set(CMAKE_C_FLAGS_DEBUG        "-g -ggdb --fstack-protector -D_FORTIFY_SOURCE=2")
-set(CMAKE_C_FLAGS_RELEASE      "-g -O2")
-set(CMAKE_C_FLAGS_CCOV         "-g -O2 --coverage")
+add_compile_options(-ffile-prefix-map=${CMAKE_SOURCE_DIR}=.)
 
 ###########################################################################
 
-if(SYSTEMD)
+if(WITH_SYSTEMD)
        PKG_CHECK_MODULES(libsystemd REQUIRED libsystemd>=222)
        add_subdirectory(systemd)
 endif()
 
-add_subdirectory(include)
 add_subdirectory(src)
 add_subdirectory(pkgconfig)
 
+if(WITH_CYNARA_COMPAT)
+       add_subdirectory(compat)
+endif()
+
 install(FILES
        ${CMAKE_CURRENT_SOURCE_DIR}/cynara.initial
        DESTINATION
diff --git a/compat/CMakeLists.txt b/compat/CMakeLists.txt
new file mode 100644 (file)
index 0000000..02af4a1
--- /dev/null
@@ -0,0 +1,21 @@
+###########################################################################
+# Copyright (C) 2018 "IoT.bzh"
+#
+# author: José Bollo <jose.bollo@iot.bzh>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+###########################################################################
+
+add_subdirectory(src)
+add_subdirectory(include)
+add_subdirectory(pkgconfig)
diff --git a/compat/pkgconfig/CMakeLists.txt b/compat/pkgconfig/CMakeLists.txt
new file mode 100644 (file)
index 0000000..6707a22
--- /dev/null
@@ -0,0 +1,41 @@
+###########################################################################
+# Copyright (C) 2018 "IoT.bzh"
+#
+# author: José Bollo <jose.bollo@iot.bzh>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+###########################################################################
+
+configure_file(cynara-compat.pc.in cynara-compat.pc @ONLY)
+
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cynara-compat.pc
+  DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
+
+foreach(item cynara-admin.pc 
+             cynara-agent.pc 
+             cynara-client-async.pc 
+             cynara-client.pc 
+             cynara-commons.pc 
+             cynara-creds-commons.pc 
+             cynara-creds-dbus.pc 
+             cynara-creds-gdbus.pc 
+             cynara-creds-self.pc 
+             cynara-creds-socket.pc 
+             cynara-monitor.pc
+             cynara-plugin.pc
+             cynara-session.pc) 
+  install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/link-to-cynara-compat.pc
+    DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
+         RENAME ${item})
+endforeach(item)
+
diff --git a/compat/src/CMakeLists.txt b/compat/src/CMakeLists.txt
new file mode 100644 (file)
index 0000000..3bda2da
--- /dev/null
@@ -0,0 +1,47 @@
+###########################################################################
+# Copyright (C) 2018 "IoT.bzh"
+#
+# author: José Bollo <jose.bollo@iot.bzh>
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+###########################################################################
+
+add_compile_definitions(_GNU_SOURCE)
+
+###########################################
+# build and install libcynara-compat
+###########################################
+add_library(cynara-compat SHARED lib-compat.c)
+target_include_directories(cynara-compat PUBLIC ../include)
+set_target_properties(cynara-compat
+       PROPERTIES
+               VERSION ${CYNARA_VERSION}
+               SOVERSION ${CYNARA_SOVERSION}
+)
+target_link_libraries(cynara-compat
+       PRIVATE cynara-client
+)
+target_link_options(cynara-compat
+       PRIVATE
+       -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/export-cynara-compat.map
+)
+install(TARGETS cynara-compat LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR})
+
+###########################################
+# build and install test-old-cynara
+###########################################
+add_executable(test-old-cynara main-test-old-cynara.c)
+target_link_libraries(test-old-cynara cynara-compat)
+install(TARGETS test-old-cynara
+        RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR})
+
similarity index 100%
rename from src/lib-compat.c
rename to compat/src/lib-compat.c
index 6875ab6..14c05d5 100644 (file)
@@ -20,27 +20,3 @@ configure_file(cynara.pc.in cynara.pc @ONLY)
 
 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cynara.pc
   DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
-
-configure_file(cynara-compat.pc.in cynara-compat.pc @ONLY)
-
-install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cynara-compat.pc
-  DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
-
-foreach(item cynara-admin.pc 
-             cynara-agent.pc 
-             cynara-client-async.pc 
-             cynara-client.pc 
-             cynara-commons.pc 
-             cynara-creds-commons.pc 
-             cynara-creds-dbus.pc 
-             cynara-creds-gdbus.pc 
-             cynara-creds-self.pc 
-             cynara-creds-socket.pc 
-             cynara-monitor.pc
-             cynara-plugin.pc
-             cynara-session.pc) 
-  install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/link-to-cynara-compat.pc
-    DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
-         RENAME ${item})
-endforeach(item)
-
index 8ef4b8a..e2a17e8 100644 (file)
@@ -55,23 +55,19 @@ set(LIBCLI_SOURCES
        socket.c
 )
 
-set(LIBCOMPAT_SOURCES
-       lib-compat.c
-)
-
 add_compile_definitions(_GNU_SOURCE)
 
 ###########################################
 # build and install libcynara-core
 ###########################################
 add_library(cynara-core SHARED ${LIBCORE_SOURCES})
+target_include_directories(cynara-core PUBLIC .)
 set_target_properties(cynara-core PROPERTIES
        VERSION ${CYNARA_VERSION}
        SOVERSION ${CYNARA_SOVERSION})
 target_link_libraries(cynara-core
+       PRIVATE
        -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/export-cynara-core.map
-       -Wl,--as-needed
-       -Wl,--gc-sections
 )
 install(TARGETS cynara-core LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR})
 
@@ -79,6 +75,7 @@ install(TARGETS cynara-core LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR})
 # build and install libcynara-client
 ###########################################
 add_library(cynara-client SHARED ${LIBCLI_SOURCES})
+target_include_directories(cynara-client PUBLIC .)
 target_compile_definitions(cynara-client PRIVATE
        RCYN_DEFAULT_SOCKET_DIR="${DEFAULT_SOCKET_DIR}"
 )
@@ -88,30 +85,10 @@ set_target_properties(cynara-client PROPERTIES
 target_link_options(cynara-client
        PRIVATE
        -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/export-cynara-client.map
-       -Wl,--as-needed
-       -Wl,--gc-sections
 )
 install(TARGETS cynara-client LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR})
 install(FILES rcyn-client.h DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR}/cynara)
 
-###########################################
-# build and install libcynara-compat
-###########################################
-add_library(cynara-compat SHARED ${LIBCOMPAT_SOURCES})
-set_target_properties(cynara-compat PROPERTIES
-       VERSION ${CYNARA_VERSION}
-       SOVERSION ${CYNARA_SOVERSION})
-target_link_libraries(cynara-compat
-       PRIVATE cynara-client
-)
-target_link_options(cynara-compat
-       PRIVATE
-       -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/export-cynara-compat.map
-       -Wl,--as-needed
-       -Wl,--gc-sections
-)
-install(TARGETS cynara-compat LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR})
-
 ###########################################
 # build and install cynarad
 ###########################################
@@ -122,7 +99,7 @@ target_compile_definitions(cynarad PRIVATE
        DEFAULT_INIT_FILE="${DEFAULT_INIT_FILE}"
        RCYN_DEFAULT_SOCKET_DIR="${DEFAULT_SOCKET_DIR}"
 )
-if(SYSTEMD)
+if(WITH_SYSTEMD)
        target_compile_definitions(cynarad PRIVATE WITH_SYSTEMD_ACTIVATION)
        target_link_libraries(cynarad ${libsystemd_LDFLAGS} ${libsystemd_LINK_LIBRARIES})
        target_include_directories(cynarad PRIVATE ${libsystemd_INCLUDE_DIRS})
@@ -140,11 +117,3 @@ target_link_libraries(cynadm cynara-client)
 install(TARGETS cynadm
         RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR})
 
-###########################################
-# build and install test-old-cynara
-###########################################
-add_executable(test-old-cynara main-test-old-cynara.c)
-target_link_libraries(test-old-cynara cynara-compat)
-install(TARGETS test-old-cynara
-        RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR})
-