From d060017805a878df7a1507e0973adccde2e742d7 Mon Sep 17 00:00:00 2001 From: Falk Werner Date: Sat, 9 Feb 2019 20:08:42 +0100 Subject: [PATCH] added shared library --- CMakeLists.txt | 23 +++++++++++++++++++---- inc/wsfs.h | 2 ++ inc/wsfs/api.h | 8 ++++++++ 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 44e42aa..4b9bac2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ -cmake_minimum_required (VERSION 2.8) -project(fuse-wsfs) +cmake_minimum_required (VERSION 3.0) +project(fuse-wsfs VERSION 0.1.0 DESCRIPTION "Websocket filesystem based on libfuse") option(WITH_TESTS "enable unit tests" OFF) @@ -38,7 +38,7 @@ set(EXTRA_CFLAGS # libfuse-wsfs -add_library(fuse-wsfs +set(FUSE_WSFS_SOURCES src/wsfs/status.c src/wsfs/filesystem.c src/wsfs/server.c @@ -62,9 +62,24 @@ add_library(fuse-wsfs src/wsfs/jsonrpc/util.c ) +add_library(fuse-wsfs SHARED ${FUSE_WSFS_SOURCES}) + +set_target_properties(fuse-wsfs PROPERTIES VERSION ${PROJECT_VERSION}) +set_target_properties(fuse-wsfs PROPERTIES SOVERSION 0) +set_target_properties(fuse-wsfs PROPERTIES C_VISIBILITY_PRESET hidden) +set_target_properties(fuse-wsfs PROPERTIES COMPILE_DEFINITIONS "WSFS_API=WSFS_EXPORT") + target_include_directories(fuse-wsfs PUBLIC src ${EXTRA_INCLUDE_DIRS}) target_compile_options(fuse-wsfs PUBLIC ${EXTRA_CFLAGS}) +add_library(fuse-wsfs-static STATIC ${FUSE_WSFS_SOURCES}) + +set_target_properties(fuse-wsfs-static PROPERTIES OUTPUT_NAME fuse-wsfs) + +target_include_directories(fuse-wsfs-static PUBLIC src ${EXTRA_INCLUDE_DIRS}) +target_compile_options(fuse-wsfs-static PUBLIC ${EXTRA_CFLAGS}) + + # app add_executable(wsfs @@ -88,7 +103,7 @@ add_executable(alltests test-src/test_timer.cc ) -target_link_libraries(alltests PUBLIC fuse-wsfs ${EXTRA_LIBS} ${GTEST_LIBRARIES}) +target_link_libraries(alltests PUBLIC fuse-wsfs-static ${EXTRA_LIBS} ${GTEST_LIBRARIES}) target_include_directories(alltests PUBLIC src ${EXTRA_INCLUDE_DIRS} ${GTEST_INCLUDE_DIRS}) target_compile_options(alltests PUBLIC ${EXTRA_CFLAGS} ${GTEST_CFLAGS}) diff --git a/inc/wsfs.h b/inc/wsfs.h index d041c94..cb5b507 100644 --- a/inc/wsfs.h +++ b/inc/wsfs.h @@ -3,5 +3,7 @@ #include "wsfs/api.h" #include "wsfs/server.h" +#include "wsfs/server_config.h" +#include "wsfs/server_protocol.h" #endif diff --git a/inc/wsfs/api.h b/inc/wsfs/api.h index 5cb711a..6dec2b6 100644 --- a/inc/wsfs/api.h +++ b/inc/wsfs/api.h @@ -5,4 +5,12 @@ #define WSFS_API #endif +#ifndef WSFS_EXPORT +#ifdef __GNUC__ +#define WSFS_EXPORT __attribute__ ((visibility ("default"))) +#else +#define WSFS_EXPORT +#endif +#endif + #endif