From c89294ff9d636159c5b16695449f256248af096f Mon Sep 17 00:00:00 2001 From: gregory guy Date: Sun, 6 Oct 2019 15:05:09 +0200 Subject: [PATCH] Conversion to the cmake building system. rfc4791.pdf has been moved to the doc folder. caldav pc file has been moved in the src folder. Signed-off-by: gregory guy (cherry picked from commit 19b046ec429c32f88658352232e6cc92276dff97) --- CMakeLists.txt | 80 ++++++++++++++++++++++++++++++++++ ConfigureChecks.cmake | 41 +++++++++++++++++ config.h.cmake | 8 ++++ doc/CMakeLists.txt | 4 ++ rfc4791.pdf => doc/rfc4791.pdf | 0 src/CMakeLists.txt | 74 +++++++++++++++++++++++++++++++ src/libcaldav.pc.cmake | 15 +++++++ test/CMakeLists.txt | 1 + test/src/CMakeLists.txt | 20 +++++++++ test/unittest/CMakeLists.txt | 20 +++++++++ 10 files changed, 263 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 ConfigureChecks.cmake create mode 100644 config.h.cmake create mode 100644 doc/CMakeLists.txt rename rfc4791.pdf => doc/rfc4791.pdf (100%) create mode 100644 src/CMakeLists.txt create mode 100644 src/libcaldav.pc.cmake create mode 100644 test/CMakeLists.txt create mode 100644 test/src/CMakeLists.txt create mode 100644 test/unittest/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..4895c59 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,80 @@ +############################################ +# # +# Improvements and feedbacks are welcome # +# # +# This file is released under GPL >= 3 # +# # +############################################ + + +cmake_minimum_required( VERSION 2.8 ) + + +#### general package setup + +project( libcaldav ) +set( VERSION R14.1.0 ) +set( PACKAGE_VERSION 0.6.5 ) + + +#### include essential cmake modules + +include( FindPkgConfig ) +include( CheckFunctionExists ) +include( CheckSymbolExists ) +include( CheckIncludeFile ) +include( CheckLibraryExists ) +include( CheckCSourceCompiles ) + + +#### include our cmake modules + +set( CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules" ) +include( TDEMacros ) + + +##### setup install paths + +include( TDESetupPaths ) +tde_setup_paths( ) + + +##### optional stuff + +option( WITH_ALL_OPTIONS "Enable all optional support" OFF ) +option( WITH_GCC_VISIBILITY "Enable fvisibility and fvisibility-inlines-hidden" ${WITH_ALL_OPTIONS} ) + + +##### user requested modules + +option( BUILD_ALL "Build all" OFF ) +option( BUILD_DOC "Build documentation" ${BUILD_ALL} ) +option( BUILD_CALDAV_TEST "Build caldav-test executable" OFF ) +option( BUILD_UNITTEST "Build unittest executable" OFF ) + + +##### configure checks + +include( ConfigureChecks.cmake ) + + +###### global compiler settings + +add_definitions( -DHAVE_CONFIG_H ) + +set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TQT_CXX_FLAGS}" ) +set( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined" ) +set( CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-undefined" ) + + +##### directories + +add_subdirectory( src ) +tde_conditional_add_subdirectory( BUILD_DOC doc ) +tde_conditional_add_subdirectory( BUILD_CALDAV_TEST test/src ) +tde_conditional_add_subdirectory( BUILD_UNITTEST test/unittest ) + + +##### write configure files + +configure_file( config.h.cmake config.h @ONLY ) diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake new file mode 100644 index 0000000..ead6ab6 --- /dev/null +++ b/ConfigureChecks.cmake @@ -0,0 +1,41 @@ +########################################### +# # +# Improvements and feedback are welcome # +# # +# This file is released under GPL >= 3 # +# # +########################################### + + +# required stuff + +tde_setup_architecture_flags( ) + +include(TestBigEndian) +test_big_endian(WORDS_BIGENDIAN) + +tde_setup_largefiles( ) + + +##### check for gcc visibility support + +if( WITH_GCC_VISIBILITY ) + tde_setup_gcc_visibility( ) +endif( WITH_GCC_VISIBILITY ) + + +##### check for glib-2.0 - gthread-2.0 + +pkg_search_module( GTHREAD gthread-2.0 ) +if( NOT GTHREAD_FOUND ) + tde_message_fatal( "glib-2.0 with thread support is required, but was not found on your system" ) +endif() + + +##### check for curl + +set( CURL_MIN_VERSION "7.15.5" ) +find_package( CURL ${CURL_MIN_VERSION} REQUIRED ) +if( NOT CURL_FOUND ) + tde_message_fatal( "curl >= 7.15.5 is required, but was not found on your system" ) +endif() diff --git a/config.h.cmake b/config.h.cmake new file mode 100644 index 0000000..61ede3a --- /dev/null +++ b/config.h.cmake @@ -0,0 +1,8 @@ +#define VERSION "@VERSION@" + +// Defined if you have fvisibility and fvisibility-inlines-hidden support. +#cmakedefine __KDE_HAVE_GCC_VISIBILITY 1 + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#cmakedefine WORDS_BIGENDIAN @WORDS_BIGENDIAN@ diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt new file mode 100644 index 0000000..2552068 --- /dev/null +++ b/doc/CMakeLists.txt @@ -0,0 +1,4 @@ +install( + FILES rfc4791.pdf + DESTINATION ${SHARE_INSTALL_PREFIX}/doc/${PROJECT_NAME} +) diff --git a/rfc4791.pdf b/doc/rfc4791.pdf similarity index 100% rename from rfc4791.pdf rename to doc/rfc4791.pdf diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..9b4d21d --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,74 @@ +include_directories( + ${CMAKE_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ${GTHREAD_INCLUDE_DIRS} + ${CURL_INCLUDE_DIRS} +) + + +set( _SRC caldav.c + add-caldav-object.c + delete-caldav-object.c + modify-caldav-object.c + get-caldav-report.c + get-display-name.c + caldav-utils.c + caldav-utils.h md5.c + options-caldav-server.c + lock-caldav-object.c + get-freebusy-report.c +) + + +##### caldav (shared) + +tde_add_library( caldav SHARED + + SOURCES + ${_SRC} + LINK + ${GTHREAD_LIBRARIES} + ${CURL_LIBRARIES} + + VERSION 0.0.6 + + DESTINATION ${LIB_INSTALL_DIR} +) + + +if( BUILD_CALDAV_TEST OR BUILD_UNITTEST ) +##### caldav (static) + +tde_add_library( caldav STATIC + + SOURCES + ${_SRC} + LINK + ${GTHREAD_LIBRARIES} + ${CURL_LIBRARIES} +) +endif() + + +#### pkg-config + +set( prefix ${CMAKE_INSTALL_PREFIX} ) +string( REGEX REPLACE "^${CMAKE_INSTALL_PREFIX}" "\${prefix}" PC_EXEC_PREFIX ${EXEC_INSTALL_PREFIX} ) +string( REGEX REPLACE "^${CMAKE_INSTALL_PREFIX}" "\${prefix}" PC_INCLUDE_DIR ${INCLUDE_INSTALL_DIR} ) +string( REGEX REPLACE "^${CMAKE_INSTALL_PREFIX}" "\${prefix}" PC_LIB_DIR ${LIB_INSTALL_DIR} ) + +configure_file( ${CMAKE_PROJECT_NAME}.pc.cmake ${CMAKE_PROJECT_NAME}.pc @ONLY ) + +install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}.pc + DESTINATION ${PKGCONFIG_INSTALL_DIR} +) + + +##### header + +install( + FILES caldav.h + DESTINATION ${INCLUDE_INSTALL_DIR}/${CMAKE_PROJECT_NAME} +) diff --git a/src/libcaldav.pc.cmake b/src/libcaldav.pc.cmake new file mode 100644 index 0000000..c8f4b6f --- /dev/null +++ b/src/libcaldav.pc.cmake @@ -0,0 +1,15 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=@PC_EXEC_PREFIX@ +libdir=@PC_LIB_DIR@ +includedir=@PC_INCLUDE_DIR@ + +pkglibdir=${libdir} +pkgincludedir=${includedir}/@PROJECT_NAME@ + +Name: @PROJECT_NAME@ +Version: @PACKAGE_VERSION@ +Description: @PROJECT_NAME@ is a client library for CalDAV + +Requires.private: gthread-2.0 libcurl +Cflags: -I${includedir} +Libs: -L${libdir} -lcaldav diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..d5b0f6d --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1 @@ +#add_subdirectory( ics ) diff --git a/test/src/CMakeLists.txt b/test/src/CMakeLists.txt new file mode 100644 index 0000000..947fc8a --- /dev/null +++ b/test/src/CMakeLists.txt @@ -0,0 +1,20 @@ +include_directories( + ${CMAKE_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_SOURCE_DIR}/src + ${GTHREAD_INCLUDE_DIRS} +) + + +##### caldav-test (executable) + +tde_add_executable( caldav-test + + SOURCES + caldav-test.c + LINK + caldav-static + + DESTINATION ${BIN_INSTALL_DIR} +) diff --git a/test/unittest/CMakeLists.txt b/test/unittest/CMakeLists.txt new file mode 100644 index 0000000..1efdef2 --- /dev/null +++ b/test/unittest/CMakeLists.txt @@ -0,0 +1,20 @@ +include_directories( + ${CMAKE_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_SOURCE_DIR}/src + ${GTHREAD_INCLUDE_DIRS} +) + + +##### unittest (executable) + +tde_add_executable( unittest + + SOURCES + libunit.c + LINK + caldav-static + + DESTINATION ${BIN_INSTALL_DIR} +)