1
0
mirror of https://github.com/falk-werner/webfuse-provider synced 2024-10-27 20:44:10 +00:00
falk-werner_webfuse-provider/CMakeLists.txt

142 lines
3.6 KiB
CMake
Raw Normal View History

2019-02-10 08:38:31 +00:00
cmake_minimum_required (VERSION 3.1)
2019-02-09 19:08:42 +00:00
project(fuse-wsfs VERSION 0.1.0 DESCRIPTION "Websocket filesystem based on libfuse")
2019-01-27 02:45:03 +00:00
option(WITHOUT_TESTS "disable unit tests" OFF)
option(WITHOUT_EXAMPLE "disable example" OFF)
2019-01-30 20:53:57 +00:00
2019-01-27 02:45:03 +00:00
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(FUSE3 REQUIRED fuse3)
pkg_check_modules(LWS REQUIRED libwebsockets)
pkg_check_modules(JANSSON REQUIRED jansson)
2019-02-10 08:22:58 +00:00
set(CMAKE_C_STANDARD 99)
2019-02-10 08:38:31 +00:00
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
2019-02-10 08:22:58 +00:00
set(C_WARNINGS -Wall -Wextra)
2019-01-27 02:45:03 +00:00
set(EXTRA_INCLUDE_DIRS
2019-02-10 13:19:15 +00:00
"include"
2019-01-27 02:45:03 +00:00
${FUSE3_INCLUDE_DIRS}
${LWS_INCLUDE_DIRS}
${JANSSON_INCLUDE_DIRS}
)
set(EXTRA_LIBS
${EXTRA_LIBS}
${FUSE3_LIBRARIES}
${LWS_LIBRARIES}
${JANSSON_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
)
set(EXTRA_CFLAGS
2019-02-10 08:22:58 +00:00
${C_WARNINGS}
2019-01-27 02:45:03 +00:00
${FUSE3_CFLAGS_OTHER}
${LWS_CFLAGS_OTHER}
${JANSSON_CFLAGS_OTHER}
"-pthread"
)
# libfuse-wsfs
2019-02-09 19:08:42 +00:00
set(FUSE_WSFS_SOURCES
2019-02-10 13:19:15 +00:00
lib/wsfs/status.c
lib/wsfs/filesystem.c
lib/wsfs/server.c
lib/wsfs/message.c
lib/wsfs/message_queue.c
lib/wsfs/time/timepoint.c
lib/wsfs/time/timer.c
lib/wsfs/time/timeout_manager.c
lib/wsfs/operation/lookup.c
lib/wsfs/operation/getattr.c
lib/wsfs/operation/readdir.c
lib/wsfs/operation/open.c
lib/wsfs/operation/close.c
lib/wsfs/operation/read.c
lib/wsfs/server_config.c
lib/wsfs/server_protocol.c
lib/wsfs/jsonrpc/server.c
lib/wsfs/jsonrpc/method.c
lib/wsfs/jsonrpc/request.c
lib/wsfs/jsonrpc/response.c
lib/wsfs/jsonrpc/util.c
2019-01-27 02:45:03 +00:00
)
2019-02-09 19:08:42 +00:00
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")
2019-02-10 13:19:15 +00:00
target_include_directories(fuse-wsfs PUBLIC lib ${EXTRA_INCLUDE_DIRS})
2019-01-27 02:45:03 +00:00
target_compile_options(fuse-wsfs PUBLIC ${EXTRA_CFLAGS})
2019-02-10 14:06:46 +00:00
file(WRITE "${PROJECT_BINARY_DIR}/libfuse-wsfs.pc"
"prefix=\"${CMAKE_INSTALL_PREFIX}\"
exec_prefix=\${prefix}
libdir=\${exec_prefix}/lib${LIB_SUFFIX}
includedir=\${prefix}/include
Name: libfuse-wsfs
Description: Websockets filesystem server library
Version: ${PROJECT_VERSION}
Libs: -L\${libdir} -lfuse-wsfs -l${FUSE3_LIBRARIES} -l${LWS_LIBRARIES} -l${JANSSON_LIBRARIES}
Cflags: -I\${includedir}"
)
2019-02-09 19:08:42 +00:00
2019-02-10 14:06:46 +00:00
install(TARGETS fuse-wsfs DESTINATION lib${LIB_SUFFIX})
install(FILES include/wsfs.h DESTINATION include)
install(DIRECTORY include/wsfs DESTINATION include)
install(FILES "${PROJECT_BINARY_DIR}/libfuse-wsfs.pc" DESTINATION lib${LIB_SUFFIX}/pkgconfig)
2019-02-09 19:08:42 +00:00
2019-01-27 02:45:03 +00:00
# app
if(NOT WITHOUT_EXAMPLE)
2019-02-10 13:19:15 +00:00
2019-01-27 02:45:03 +00:00
add_executable(wsfs
2019-02-10 13:19:15 +00:00
example/main.c
2019-01-27 02:45:03 +00:00
)
target_link_libraries(wsfs PUBLIC fuse-wsfs ${EXTRA_LIBS})
target_include_directories(wsfs PUBLIC ${EXTRA_INCLUDE_DIRS})
2019-01-27 02:45:03 +00:00
target_compile_options(wsfs PUBLIC ${EXTRA_CFLAGS})
endif(NOT WITHOUT_EXAMPLE)
2019-02-10 13:19:15 +00:00
2019-01-27 02:45:03 +00:00
# tests
2019-01-30 20:53:57 +00:00
if(NOT WITHOUT_TESTS)
2019-01-30 20:53:57 +00:00
pkg_check_modules(GTEST gtest_main)
2019-02-10 14:06:46 +00:00
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 lib ${EXTRA_INCLUDE_DIRS})
target_compile_options(fuse-wsfs-static PUBLIC ${EXTRA_CFLAGS})
2019-01-27 02:45:03 +00:00
add_executable(alltests
2019-02-13 19:49:05 +00:00
test/msleep.cc
2019-02-10 13:19:15 +00:00
test/test_response_parser.cc
test/test_server.cc
test/test_timepoint.cc
test/test_timer.cc
2019-01-27 02:45:03 +00:00
)
2019-02-09 19:08:42 +00:00
target_link_libraries(alltests PUBLIC fuse-wsfs-static ${EXTRA_LIBS} ${GTEST_LIBRARIES})
2019-02-10 13:19:15 +00:00
target_include_directories(alltests PUBLIC lib ${EXTRA_INCLUDE_DIRS} ${GTEST_INCLUDE_DIRS})
2019-01-30 20:53:57 +00:00
target_compile_options(alltests PUBLIC ${EXTRA_CFLAGS} ${GTEST_CFLAGS})
enable_testing()
add_test(alltests alltests)
2019-01-27 02:45:03 +00:00
endif(NOT WITHOUT_TESTS)