From 56a4553dd715e7147a01f2737f9ccdd4d2e1e84c Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" Date: Fri, 29 Mar 2019 12:05:35 +0100 Subject: [PATCH 1/3] cmake: Use external jansson if possible --- CMakeLists.txt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ef616e9..930f16b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,7 @@ option(FTL_STATIC_COMPILE "Set to TRUE if you want ftl to be compiled as a stati MESSAGE(STATUS "FTL FTL_STATIC_COMPILE: " ${FTL_STATIC_COMPILE}) find_package(Threads REQUIRED) +find_package(PkgConfig) set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) @@ -39,15 +40,18 @@ if (NOT CURL_FOUND AND NOT DISABLE_AUTO_INGEST) endif() # We will only try to include lib jansson if auto ingest is enabled. -SET(JANSSON_LIBRARIES "") -if (NOT DISABLE_AUTO_INGEST) +if (PKG_CONFIG_FOUND AND NOT DISABLE_AUTO_INGEST) + pkg_check_modules(JANSSON jansson) +endif() +if (NOT JANSSON_FOUND AND NOT DISABLE_AUTO_INGEST) SET(JANSSON_BUILD_DOCS OFF CACHE BOOL "Jansson docs off") SET(JANSSON_WITHOUT_TESTS ON CACHE BOOL "Jansson build without tests") SET(JANSSON_EXAMPLES OFF CACHE BOOL "Jansson disable examples") SET(USE_WINDOWS_CRYPTOAPI off) add_subdirectory(libjansson) - include_directories(${CMAKE_CURRENT_BINARY_DIR}/libjansson/include) + SET(JANSSON_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/libjansson/include) SET(JANSSON_LIBRARIES jansson) + include_directories(${JANSSON_INCLUDE_DIRS}) endif() if (WIN32) From ae2afff14f7873a087083370a4a0364f973ac68f Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" Date: Fri, 29 Mar 2019 12:06:31 +0100 Subject: [PATCH 2/3] cmake: Install into standard directories --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 930f16b..66eb27a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,7 @@ MESSAGE(STATUS "FTL DISABLE_FTL_APP: " ${DISABLE_FTL_APP}) option(FTL_STATIC_COMPILE "Set to TRUE if you want ftl to be compiled as a static lib. If TRUE, the program will want to statically link to the ftl cmake object." FALSE) MESSAGE(STATUS "FTL FTL_STATIC_COMPILE: " ${FTL_STATIC_COMPILE}) +include(GNUInstallDirs) find_package(Threads REQUIRED) find_package(PkgConfig) @@ -134,4 +135,5 @@ if (NOT DISABLE_FTL_APP) endif() # Install rules -install(TARGETS ftl DESTINATION lib) \ No newline at end of file +install(TARGETS ftl DESTINATION ${CMAKE_INSTALL_LIBDIR}) +install(FILES libftl/ftl.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libftl) From e3954804933d88526b59b502c491e7ca1a34f703 Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" Date: Fri, 29 Mar 2019 12:06:47 +0100 Subject: [PATCH 3/3] cmake: Install a pkgconfig file --- CMakeLists.txt | 9 ++++++++- libftl.pc.in | 11 +++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 libftl.pc.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 66eb27a..f6cb6c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,8 @@ cmake_minimum_required (VERSION 2.8.0) enable_language(C) project(libftl) +SET(FTL_VERSION "0.5.0") + option(DISABLE_AUTO_INGEST "Set to TRUE to disable auto ingest feature which removes curl and jansson dependancies" FALSE) MESSAGE(STATUS "FTL DISABLE_AUTO_INGEST: " ${DISABLE_AUTO_INGEST}) @@ -100,7 +102,7 @@ add_library(ftl ${FTL_LIB_TYPE} libftl/hmac/hmac.c ${FTLSDK_PLATFORM_FILES}) include_directories(libftl libftl/gettimeofday) -set_target_properties(ftl PROPERTIES VERSION "0.5.0") +set_target_properties(ftl PROPERTIES VERSION ${FTL_VERSION}) set_target_properties(ftl PROPERTIES SOVERSION 0) target_link_libraries(ftl ${CURL_LIBRARIES} ${JANSSON_LIBRARIES}) @@ -134,6 +136,11 @@ if (NOT DISABLE_FTL_APP) target_include_directories(ftl_app PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/ftl_app) endif() +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libftl.pc.in + ${CMAKE_CURRENT_BINARY_DIR}/libftl.pc @ONLY) + # Install rules install(TARGETS ftl DESTINATION ${CMAKE_INSTALL_LIBDIR}) install(FILES libftl/ftl.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libftl) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libftl.pc + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) diff --git a/libftl.pc.in b/libftl.pc.in new file mode 100644 index 0000000..106ffc8 --- /dev/null +++ b/libftl.pc.in @@ -0,0 +1,11 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=${prefix} +libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ +includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@/libftl + +Name: FTL +Description: Library for Mixer's FTL Protocol +Version: @FTL_VERSION@ +Requires.private: libcurl jansson +Libs: -L${libdir} -lftl +Cflags: -I${includedir}