diff --git a/CMakeLists.txt b/CMakeLists.txt index 5b42004..4a9b754 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,38 @@ -cmake_minimum_required(VERSION 3.5.0 FATAL_ERROR) #CPACK_DEBIAN__PACKAGE_NAME +cmake_minimum_required(VERSION 3.12...3.18 FATAL_ERROR) +if (POLICY CMP0109) + # find_program requires permission to execute but not to read + cmake_policy(SET CMP0109 NEW) +endif() +if (POLICY CMP0121) + # Detect invalid indices in list() + cmake_policy(SET CMP0121 NEW) +endif() +if (POLICY CMP0125) + # Consistent behavior for cache variables managed by find_*() + cmake_policy(SET CMP0125 NEW) +endif() +if (POLICY CMP0130) + # Diagnose condition evaluation errors in while() + cmake_policy(SET CMP0130 NEW) +endif() +if (POLICY CMP0132) + # Consistent handling of compiler environment variables + cmake_policy(SET CMP0132 NEW) +endif() +if (POLICY CMP0140) + # Check validity of return() params + cmake_policy(SET CMP0140 NEW) +endif() +if (POLICY CMP0167) + # Bypass FindBoost module + cmake_policy(SET CMP0167 NEW) +endif() list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/cmake") set(MUNGEFS_VERSION_MAJOR "1") set(MUNGEFS_VERSION_MINOR "0") -set(MUNGEFS_VERSION_PATCH "7") +set(MUNGEFS_VERSION_PATCH "8") set(MUNGEFS_VERSION "${MUNGEFS_VERSION_MAJOR}.${MUNGEFS_VERSION_MINOR}.${MUNGEFS_VERSION_PATCH}") set(MUNGEFS_CXX_STANDARD 14) @@ -36,7 +64,7 @@ find_package(Boost REQUIRED COMPONENTS system filesystem program_options) find_package(LibArchive REQUIRED) -find_package(FUSE 2.6 REQUIRED) +find_package(FUSE 2.9 REQUIRED) find_package(AvroCpp REQUIRED) find_package(cppzmq REQUIRED) @@ -50,7 +78,7 @@ add_executable( target_link_libraries( mungefs PRIVATE - ${FUSE_LIBRARIES} + FUSE::FUSE cppzmq::cppzmq Avro::AvroCpp Boost::system @@ -62,7 +90,6 @@ target_include_directories( mungefs PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/include" - ${FUSE_INCLUDE_DIRS} ) target_compile_definitions(mungefs PRIVATE ${MUNGEFS_COMPILE_DEFINITIONS}) @@ -77,7 +104,7 @@ add_executable( target_link_libraries( mungefsctl PRIVATE - ${FUSE_LIBRARIES} + FUSE::FUSE cppzmq::cppzmq Avro::AvroCpp Boost::system diff --git a/cmake/FindAvroCpp.cmake b/cmake/FindAvroCpp.cmake index de75e78..2118305 100644 --- a/cmake/FindAvroCpp.cmake +++ b/cmake/FindAvroCpp.cmake @@ -38,7 +38,15 @@ TODO #]=======================================================================] cmake_policy(PUSH) -cmake_policy(SET CMP0054 NEW) # Only interpret if() arguments as variables or keywords when unquoted +cmake_minimum_required(VERSION 3.12...3.18 FATAL_ERROR) +if (POLICY CMP0125) + # Consistent behavior for cache variables managed by find_*() + cmake_policy(SET CMP0125 NEW) +endif() +if (POLICY CMP0132) + # Consistent handling of compiler environment variables + cmake_policy(SET CMP0132 NEW) +endif() find_path(AVROCPP_INCLUDE_DIR NAMES avro/AvroParse.hh) find_library(AVROCPP_LIBRARY NAMES avrocpp libavrocpp) @@ -46,7 +54,7 @@ find_program(AVROCPP_AVROGEN_EXECUTABLE NAMES avrogencpp) include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(AvroCpp - REQUIRED_VARS AVROCPP_INCLUDE_DIR AVROCPP_LIBRARY AVROCPP_AVROGEN_EXECUTABLE) + REQUIRED_VARS AVROCPP_LIBRARY AVROCPP_INCLUDE_DIR AVROCPP_AVROGEN_EXECUTABLE) if (AvroCpp_FOUND) if (NOT TARGET Avro::AvroCpp) diff --git a/cmake/FindFUSE.cmake b/cmake/FindFUSE.cmake index aabe9f8..706ba28 100644 --- a/cmake/FindFUSE.cmake +++ b/cmake/FindFUSE.cmake @@ -1,169 +1,318 @@ -# From https://github.com/iovisor/bcc-fuse/blob/412c6f269bd44b836e0a7f28fff952a5a2df099f/cmake/Modules/Findfuse.cmake - -# This module can find FUSE Library -# -# Requirements: -# - CMake >= 2.8.3 -# -# The following variables will be defined for your use: -# - FUSE_FOUND : was FUSE found? -# - FUSE_INCLUDE_DIRS : FUSE include directory -# - FUSE_LIBRARIES : FUSE library -# - FUSE_DEFINITIONS : FUSE cflags -# - FUSE_VERSION : complete version of FUSE (major.minor) -# - FUSE_MAJOR_VERSION : major version of FUSE -# - FUSE_MINOR_VERSION : minor version of FUSE -# -# Example Usage: -# -# 1. Copy this file in the root of your project source directory -# 2. Then, tell CMake to search this non-standard module in your project directory by adding to your CMakeLists.txt: -# set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}) -# 3. Finally call find_package() once, here are some examples to pick from -# -# Require FUSE 2.6 or later -# find_package(FUSE 2.6 REQUIRED) -# -# if(FUSE_FOUND) -# add_definitions(${FUSE_DEFINITIONS}) -# include_directories(${FUSE_INCLUDE_DIRS}) -# add_executable(myapp myapp.c) -# target_link_libraries(myapp ${FUSE_LIBRARIES}) -# endif() - -#============================================================================= -# Copyright (c) 2012, julp -# -# Distributed under the OSI-approved BSD License -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -#============================================================================= - -cmake_minimum_required(VERSION 2.8.3) - -########## Private ########## -function(fusedebug _varname) - if(FUSE_DEBUG) - message("${_varname} = ${${_varname}}") - endif(FUSE_DEBUG) -endfunction(fusedebug) - -########## Public ########## -set(FUSE_FOUND TRUE) -set(FUSE_LIBRARIES ) -set(FUSE_DEFINITIONS ) -set(FUSE_INCLUDE_DIRS ) - -find_package(PkgConfig) - -set(PC_FUSE_INCLUDE_DIRS ) -set(PC_FUSE_LIBRARY_DIRS ) -if(PKG_CONFIG_FOUND) - pkg_check_modules(PC_FUSE "fuse" QUIET) - if(PC_FUSE_FOUND) -# fusedebug(PC_FUSE_LIBRARIES) -# fusedebug(PC_FUSE_LIBRARY_DIRS) -# fusedebug(PC_FUSE_LDFLAGS) -# fusedebug(PC_FUSE_LDFLAGS_OTHER) -# fusedebug(PC_FUSE_INCLUDE_DIRS) -# fusedebug(PC_FUSE_CFLAGS) -# fusedebug(PC_FUSE_CFLAGS_OTHER) - set(FUSE_DEFINITIONS "${PC_FUSE_CFLAGS_OTHER}") - endif(PC_FUSE_FOUND) -endif(PKG_CONFIG_FOUND) + +cmake_policy(PUSH) +cmake_minimum_required(VERSION 3.12...3.18 FATAL_ERROR) +if (POLICY CMP0121) + # Detect invalid indices in list() + cmake_policy(SET CMP0121 NEW) +endif() +if (POLICY CMP0125) + # Consistent behavior for cache variables managed by find_*() + cmake_policy(SET CMP0125 NEW) +endif() +if (POLICY CMP0132) + # Consistent handling of compiler environment variables + cmake_policy(SET CMP0132 NEW) +endif() + +# docstrings +set(FUSE_INCLUDE_DIRS_DOCSTR "Paths to fuse headers") +set(FUSE_LIBRARIES_DOCSTR "Paths to fuse libraries") +set(FUSE_COMPILE_OPTIONS_DOCSTR "Compile options needed to use fuse") +set(FUSE_LINK_OPTIONS_DOCSTR "Link options needed to use fuse") +set(FUSE_NEEDS_LIBDL_DOCSTR "Whether fuse needs libdl") +set(FUSE_NEEDS_LIBRT_DOCSTR "Whether fuse needs librt") +set(FUSE_NEEDS_PTHREAD_DOCSTR "Whether fuse needs pthread") + +# extract fuse version from headers +function(_ffuse_extract_version includedirs) + foreach(includedir IN LISTS includedirs) + if (EXISTS "${includedir}/fuse_common.h") + set(fcommon_header "${includedir}/fuse_common.h") + break() + elseif(EXISTS "${includedir}/fuse/fuse_common.h") + set(fcommon_header "${includedir}/fuse/fuse_common.h") + break() + endif() + endforeach() + if (NOT fcommon_header) + message(WARNING "Unable to determine fuse version: could not find fuse_common.h") + return() + endif(NOT fcommon_header) + + file(READ "${fcommon_header}" _contents) + if(_contents MATCHES ".*[\n\r][ \\t]*#[ \\t]*define[ \\t]+FUSE_MAJOR_VERSION[ \\t]+([0-9]+).*") + set(_FUSE_MAJOR_VERSION "${CMAKE_MATCH_1}") + endif() + if(_contents MATCHES ".*[\n\r][ \\t]*#[ \\t]*define[ \\t]+FUSE_MINOR_VERSION[ \\t]+([0-9]+).*") + set(_FUSE_MINOR_VERSION "${CMAKE_MATCH_1}") + endif() + if(_contents MATCHES ".*[\n\r][ \\t]*#[ \\t]*define[ \\t]+FUSE_HOTFIX_VERSION[ \\t]+([0-9]+).*") + set(_FUSE_HOTFIX_VERSION "${CMAKE_MATCH_1}") + endif() + if (_FUSE_MAJOR_VERSION AND (_FUSE_MINOR_VERSION OR (_FUSE_MINOR_VERSION STREQUAL "0"))) + set(FUSE_MAJOR_VERSION "${_FUSE_MAJOR_VERSION}" PARENT_SCOPE) + set(FUSE_MINOR_VERSION "${_FUSE_MINOR_VERSION}" PARENT_SCOPE) + if (_FUSE_HOTFIX_VERSION OR (_FUSE_HOTFIX_VERSION STREQUAL "0")) + set(FUSE_PATCH_VERSION "${_FUSE_HOTFIX_VERSION}" PARENT_SCOPE) + set(FUSE_VERSION "${_FUSE_MAJOR_VERSION}.${_FUSE_MINOR_VERSION}.${_FUSE_HOTFIX_VERSION}" PARENT_SCOPE) + else() + set(FUSE_VERSION "${_FUSE_MAJOR_VERSION}.${_FUSE_MINOR_VERSION}" PARENT_SCOPE) + endif() + else() + message(WARNING "Unable to determine fuse version: could not parse fuse_common.h") + endif() +endfunction() + +# check whether -D_FILE_OFFSET_BITS=64 needs to be added to defines +function(_ffuse_foff_check resultvar_out includedirs cflags) + get_property(ENABLED_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES) + if ("CXX" IN_LIST ENABLED_LANGUAGES) + set(FUSE_TEST_SOURCE "${CMAKE_CURRENT_LIST_DIR}/fuse_test.cpp") + set(FUSE_TEST_CFLAGS_VAR "CMAKE_CXX_FLAGS") + elseif ("C" IN_LIST ENABLED_LANGUAGES) + set(FUSE_TEST_SOURCE "${CMAKE_CURRENT_LIST_DIR}/fuse_test.c") + set(FUSE_TEST_CFLAGS_VAR "CMAKE_C_FLAGS") + else() + message(FATAL_ERROR "Either C or CXX must be enabled.") + endif() + + if (cflags) + set(FUSE_TEST_CFLAGS "-D${FUSE_TEST_CFLAGS_VAR}:STRING=${cflags}") + else() + set(FUSE_TEST_CFLAGS) + endif() + + try_compile( + FUSE_FOFF_CHECK + "${CMAKE_CURRENT_BINARY_DIR}" + SOURCES "${FUSE_TEST_SOURCE}" + CMAKE_FLAGS + "-DINCLUDE_DIRECTORIES:STRING=${includedirs}" + "${FUSE_TEST_CFLAGS}" + ) + + if (FUSE_FOFF_CHECK) + set("${resultvar_out}" FALSE) + else() + set("${resultvar_out}" TRUE) + endif() +endfunction() + +# ugliness follows. +# pkg-config is really inadequate for CMake. fuse.pc can pull in librt, libdl, and pthread, all of +# which we have special handling for. Furthermore, there is no clean way to pull the include dirs +# and libraries specific to fuse *and not its dependencies* out of fuse.pc without at least a little +# bit of guesswork/assumption-making. What follows is my clunky attempt at handling this to the +# best of my ability. + +# search for a library in pc result variables, remove any entries found, and return paths +function(_ffuse_filter_pc_lib foundvar_out pathsvar_out libname pclibsvar pclibpathsvar) + + set(PC_LIBRARIES "${pclibsvar}") + set(PC_LINK_LIBRARIES "${${pclibpathsvar}}") + if ("${${pathsvar_out}}") + set(LIBPATHS_OUT "${${pathsvar_out}}") + endif("${${pathsvar_out}}") + + foreach(libprefix IN LISTS CMAKE_FIND_LIBRARY_PREFIXES) + foreach(libsuffix IN LISTS CMAKE_FIND_LIBRARY_SUFFIXES) + list(APPEND libfnames "${libprefix}${libname}${libsuffix}") + endforeach() + endforeach() + + if ("${libname}" IN_LIST PC_LIBRARIES) + set("${foundvar_out}" TRUE PARENT_SCOPE) + list(REMOVE_ITEM PC_LIBRARIES "${libname}") + endif("${libname}" IN_LIST PC_LIBRARIES) + + foreach(libpath IN LISTS PC_LINK_LIBRARIES) + cmake_path(GET libpath FILENAME libfname) + if (libfname IN_LIST libfnames) + set("${foundvar_out}" TRUE PARENT_SCOPE) + list(APPEND libpaths "${libpath}") + endif(libfname IN_LIST libfnames) + endforeach() + + foreach(libpath IN LISTS libpaths) + list(APPEND LIBPATHS_OUT "${libpath}") + list(REMOVE_ITEM PC_LINK_LIBRARIES "${libpath}") + endforeach() + + set("${pclibsvar}" "${PC_LIBRARIES}" PARENT_SCOPE) + set("${pclibpathsvar}" "${PC_LINK_LIBRARIES}" PARENT_SCOPE) + if (LIBPATHS_OUT) + list(REMOVE_DUPLICATES LIBPATHS_OUT) + set("${pathsvar_out}" "${LIBPATHS_OUT}" PARENT_SCOPE) + endif(LIBPATHS_OUT) +endfunction() + +# some defaults +set(_FUSE_NEEDS_LIBDL FALSE) +set(_FUSE_NEEDS_LIBRT FALSE) +set(_FUSE_NEEDS_PTHREAD TRUE) + +if ((NOT FUSE_INCLUDE_DIRS) AND (NOT FUSE_LIBRARIES)) + find_package(PkgConfig) + if (PKG_CONFIG_FOUND) + pkg_check_modules(PC_FUSE "fuse" QUIET) + if (PC_FUSE_FOUND) + + set(_FUSE_PCLIBS "${PC_FUSE_LIBRARIES}") + set(_FUSE_PCLIBPATHS "${PC_FUSE_LINK_LIBRARIES}") + set(_FUSE_LDFLAGS "${PC_FUSE_LDFLAGS_OTHER}") + + # Check for dl + _ffuse_filter_pc_lib(_FUSE_NEEDS_LIBDL _DL_LIBPATHS "dl" _FUSE_PCLIBS _FUSE_PCLIBPATHS) + _ffuse_filter_pc_lib(_FUSE_NEEDS_LIBDL _DL_LIBPATHS "${CMAKE_DL_LIBS}" _FUSE_PCLIBS _FUSE_PCLIBPATHS) + + # check for rt + _ffuse_filter_pc_lib(_FUSE_NEEDS_LIBRT _RT_LIBPATHS "rt" _FUSE_PCLIBS _FUSE_PCLIBPATHS) + + # Check for pthread + # we default to pulling in pthread, so use a different variable here + _ffuse_filter_pc_lib(_FUSE_NEEDS_PTHREAD_PC _PTHREAD_LIBPATHS "pthread" _FUSE_PCLIBS _FUSE_PCLIBPATHS) + if ("-pthread" IN_LIST _FUSE_LDFLAGS) + set(_FUSE_NEEDS_PTHREAD_PC TRUE) + list(REMOVE_ITEM _FUSE_LDFLAGS "-pthread") + endif("-pthread" IN_LIST _FUSE_LDFLAGS) + if (NOT _FUSE_NEEDS_PTHREAD_PC) + set(_FUSE_NEEDS_PTHREAD FALSE) + endif(NOT _FUSE_NEEDS_PTHREAD_PC) + + endif(PC_FUSE_FOUND) + endif(PKG_CONFIG_FOUND) +endif((NOT FUSE_INCLUDE_DIRS) AND (NOT FUSE_LIBRARIES)) find_path( - FUSE_INCLUDE_DIRS - NAMES fuse.h - PATHS "${PC_FUSE_INCLUDE_DIRS}" - DOC "Include directories for FUSE" + FUSE_INCLUDE_DIRS + NAMES fuse.h + PATHS "${PC_FUSE_INCLUDE_DIRS}" + DOC "${FUSE_INCLUDE_DIRS_DOCSTR}" ) -if(NOT FUSE_INCLUDE_DIRS) - set(FUSE_FOUND FALSE) -endif(NOT FUSE_INCLUDE_DIRS) +if (_FUSE_PCLIBPATHS) + set(FUSE_LIBRARIES "${_FUSE_PCLIBPATHS}" CACHE STRING "${FUSE_LIBRARIES_DOCSTR}") +else() + find_library( + FUSE_LIBRARIES + NAMES "fuse" + PATHS "${PC_FUSE_LIBRARY_DIRS}" + DOC "${FUSE_LIBRARIES_DOCSTR}" + ) +endif() -find_library( - FUSE_LIBRARIES - NAMES "fuse" - PATHS "${PC_FUSE_LIBRARY_DIRS}" - DOC "Libraries for FUSE" -) +set(FUSE_NEEDS_LIBDL "${_FUSE_NEEDS_LIBDL}" CACHE BOOL "${FUSE_NEEDS_LIBDL_DOCSTR}") +set(FUSE_NEEDS_LIBRT "${_FUSE_NEEDS_LIBRT}" CACHE BOOL "${FUSE_NEEDS_LIBRT_DOCSTR}") +set(FUSE_NEEDS_PTHREAD "${_FUSE_NEEDS_PTHREAD}" CACHE BOOL "${FUSE_NEEDS_PTHREAD_DOCSTR}") + +if (FUSE_INCLUDE_DIRS) + + _ffuse_extract_version("${FUSE_INCLUDE_DIRS}") + + if (NOT DEFINED FUSE_COMPILE_OPTIONS) + if (PC_FUSE_CFLAGS_OTHER) + set(_FUSE_COMPILE_OPTIONS "${PC_FUSE_CFLAGS_OTHER}") + endif(PC_FUSE_CFLAGS_OTHER) + + _ffuse_foff_check(_FUSE_NEEDS_FOFF64 "${FUSE_INCLUDE_DIRS}" "${PC_FUSE_CFLAGS_OTHER}") + if (_FUSE_NEEDS_FOFF64) + list(APPEND _FUSE_COMPILE_OPTIONS "-D_FILE_OFFSET_BITS=64") + endif(_FUSE_NEEDS_FOFF64) + + set(FUSE_COMPILE_OPTIONS "${_FUSE_COMPILE_OPTIONS}" CACHE STRING "${FUSE_COMPILE_OPTIONS_DOCSTR}") + endif(NOT DEFINED FUSE_COMPILE_OPTIONS) + + if (NOT DEFINED FUSE_LINK_OPTIONS) + set(FUSE_LINK_OPTIONS "${_FUSE_LDFLAGS}" CACHE STRING "${FUSE_LINK_OPTIONS_DOCSTR}") + endif(NOT DEFINED FUSE_LINK_OPTIONS) -if(NOT FUSE_LIBRARIES) - set(FUSE_FOUND FALSE) -endif(NOT FUSE_LIBRARIES) - -if(FUSE_FOUND) - if(EXISTS "${FUSE_INCLUDE_DIRS}/fuse/fuse_common.h") - file(READ "${FUSE_INCLUDE_DIRS}/fuse/fuse_common.h" _contents) - string(REGEX REPLACE ".*# *define *FUSE_MAJOR_VERSION *([0-9]+).*" "\\1" FUSE_MAJOR_VERSION "${_contents}") - string(REGEX REPLACE ".*# *define *FUSE_MINOR_VERSION *([0-9]+).*" "\\1" FUSE_MINOR_VERSION "${_contents}") - set(FUSE_VERSION "${FUSE_MAJOR_VERSION}.${FUSE_MINOR_VERSION}") - endif() - - include(CheckCSourceCompiles) - # Backup CMAKE_REQUIRED_* - set(OLD_CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES}") - set(OLD_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") - set(OLD_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}") - # Add FUSE compilation flags - set(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES}" "${FUSE_INCLUDE_DIRS}") - set(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}" "${FUSE_LIBRARIES}") - set(CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}" "${FUSE_DEFINITIONS}") - check_c_source_compiles("#include -#include -#include -#include -#include -#include - -int main(void) { -return 0; -}" FUSE_CFLAGS_CHECK) - if(NOT FUSE_CFLAGS_CHECK) - set(FUSE_DEFINITIONS "-D_FILE_OFFSET_BITS=64") - # Should we run again previous test to assume the failure was due to missing definition -D_FILE_OFFSET_BITS=64? - endif(NOT FUSE_CFLAGS_CHECK) - # Restore CMAKE_REQUIRED_* - set(CMAKE_REQUIRED_INCLUDES "${OLD_CMAKE_REQUIRED_INCLUDES}") - set(CMAKE_REQUIRED_LIBRARIES "${OLD_CMAKE_REQUIRED_LIBRARIES}") - set(CMAKE_REQUIRED_DEFINITIONS "${OLD_CMAKE_REQUIRED_DEFINITIONS}") -endif(FUSE_FOUND) - -if(FUSE_INCLUDE_DIRS) - include(FindPackageHandleStandardArgs) - if(FUSE_FIND_REQUIRED AND NOT FUSE_FIND_QUIETLY) - find_package_handle_standard_args(FUSE REQUIRED_VARS FUSE_LIBRARIES FUSE_INCLUDE_DIRS VERSION_VAR FUSE_VERSION) - else() - find_package_handle_standard_args(FUSE "FUSE not found" FUSE_LIBRARIES FUSE_INCLUDE_DIRS) - endif() -else(FUSE_INCLUDE_DIRS) - if(FUSE_FIND_REQUIRED AND NOT FUSE_FIND_QUIETLY) - message(FATAL_ERROR "Could not find FUSE include directory") - endif() endif(FUSE_INCLUDE_DIRS) -mark_as_advanced( - FUSE_INCLUDE_DIRS - FUSE_LIBRARIES -) +include(FindPackageHandleStandardArgs) + +if (FUSE_VERSION) + find_package_handle_standard_args( + FUSE + REQUIRED_VARS FUSE_LIBRARIES FUSE_INCLUDE_DIRS + VERSION_VAR FUSE_VERSION + ) +else() + find_package_handle_standard_args( + FUSE + REQUIRED_VARS FUSE_LIBRARIES FUSE_INCLUDE_DIRS + ) +endif() + +if (FUSE_FOUND AND (NOT TARGET FUSE::FUSE)) + add_library(FUSE::FUSE INTERFACE IMPORTED) + + unset(_ffuse_REQUIRED) + if (FUSE_FIND_REQUIRED) + set(_ffuse_REQUIRED REQUIRED) + endif(FUSE_FIND_REQUIRED) + + # the first library in the list is usually the "main" library + list(GET FUSE_LIBRARIES 0 _FUSE_TARGET_LIB) + set_target_properties( + FUSE::FUSE + PROPERTIES + IMPORTED_LOCATION "${_FUSE_TARGET_LIB}" + ) + + set_target_properties( + FUSE::FUSE + PROPERTIES + INTERFACE_LINK_LIBRARIES "${FUSE_LIBRARIES}" + ) + + if (FUSE_NEEDS_LIBDL) + set_property( + TARGET FUSE::FUSE + APPEND + PROPERTY INTERFACE_LINK_LIBRARIES "${CMAKE_DL_LIBS}" + ) + endif(FUSE_NEEDS_LIBDL) + + if (FUSE_NEEDS_LIBRT) + find_package(LibRT ${_ffuse_REQUIRED}) + set_property( + TARGET FUSE::FUSE + APPEND + PROPERTY INTERFACE_LINK_LIBRARIES LibRT::LibRT + ) + endif(FUSE_NEEDS_LIBRT) + + if (FUSE_NEEDS_PTHREAD) + find_package(Threads ${_ffuse_REQUIRED}) + set_property( + TARGET FUSE::FUSE + APPEND + PROPERTY INTERFACE_LINK_LIBRARIES Threads::Threads + ) + endif(FUSE_NEEDS_PTHREAD) + + set_target_properties( + FUSE::FUSE + PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${FUSE_INCLUDE_DIRS}" + ) + + if (FUSE_COMPILE_OPTIONS) + set_target_properties( + FUSE::FUSE + PROPERTIES + INTERFACE_COMPILE_OPTIONS "${FUSE_COMPILE_OPTIONS}" + ) + endif(FUSE_COMPILE_OPTIONS) + + if (FUSE_LINK_OPTIONS) + set_target_properties( + FUSE::FUSE + PROPERTIES + INTERFACE_LINK_OPTIONS "${FUSE_LINK_OPTIONS}" + ) + endif(FUSE_LINK_OPTIONS) + +endif(FUSE_FOUND AND (NOT TARGET FUSE::FUSE)) -# IN (args) -fusedebug("FUSE_FIND_COMPONENTS") -fusedebug("FUSE_FIND_REQUIRED") -fusedebug("FUSE_FIND_QUIETLY") -fusedebug("FUSE_FIND_VERSION") -# OUT -# Found -fusedebug("FUSE_FOUND") -# Definitions -fusedebug("FUSE_DEFINITIONS") -# Linking -fusedebug("FUSE_INCLUDE_DIRS") -fusedebug("FUSE_LIBRARIES") -# Version -fusedebug("FUSE_MAJOR_VERSION") -fusedebug("FUSE_MINOR_VERSION") -fusedebug("FUSE_VERSION") +cmake_policy(POP) diff --git a/cmake/FindLibRT.cmake b/cmake/FindLibRT.cmake new file mode 100644 index 0000000..04b7590 --- /dev/null +++ b/cmake/FindLibRT.cmake @@ -0,0 +1,115 @@ +#[=======================================================================[.rst: +FindLibRT +----------- + +Finds RT. + +IMPORTED Targets +^^^^^^^^^^^^^^^^ + +The following :prop_tgt:`IMPORTED` targets may be defined: + +``LibRT::LibRT`` + RT + +``rt::rt`` + Alias for ``LibRT::LibRT`` + +Result variables +^^^^^^^^^^^^^^^^ + +This module will set the following variables in your project: + +``LibRT_FOUND`` + true if RT headers and library were found +``LibRT_INCLUDE_DIR`` + the directory containing RT headers +``LibRT_LIBRARY`` + RT library to be linked (can be blank if ``LibRT_EXPLICIT_LINK`` is + ``FALSE``) +``LibRT_EXPLICIT_LINK`` + Whether RT needs to be linked to explicitly + +``LibRT_INCLUDE_DIR``, ``LibRT_LIBRARY``, and ``LibRT_EXPLICIT_LINK`` are +cache variables that can be set to control the behavior of this module. + +#]=======================================================================] + +cmake_policy(PUSH) +cmake_minimum_required(VERSION 3.12...3.18 FATAL_ERROR) +if (POLICY CMP0125) + # Consistent behavior for cache variables managed by find_*() + cmake_policy(SET CMP0125 NEW) +endif() +if (POLICY CMP0132) + # Consistent handling of compiler environment variables + cmake_policy(SET CMP0132 NEW) +endif() + +set(LibRT_INCLUDE_DIR_DOCSTR "Path to RT headers") +set(LibRT_EXPLICIT_LINK_DOCSTR "Whether RT library must be linked to be used") +set(LibRT_LIBRARY_DOCSTR "Path to the RT library (can be blank if LibRT_EXPLICIT_LINK is FALSE)") + +include(FindPackageHandleStandardArgs) + +find_path(LibRT_INCLUDE_DIR NAMES "time.h" DOC "${LibRT_INCLUDE_DIR_DOCSTR}") + +if (LibRT_INCLUDE_DIR) + + if (DEFINED LibRT_EXPLICIT_LINK) + + if (NOT LibRT_EXPLICIT_LINK) + set(LibRT_NO_EXPLICIT_LINK TRUE) + endif(NOT LibRT_EXPLICIT_LINK) + + else(DEFINED LibRT_EXPLICIT_LINK) + + get_property(ENABLED_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES) + if ("CXX" IN_LIST ENABLED_LANGUAGES) + set(LibRT_TEST_SOURCE "${CMAKE_CURRENT_LIST_DIR}/librt_test.cpp") + elseif ("C" IN_LIST ENABLED_LANGUAGES) + set(LibRT_TEST_SOURCE "${CMAKE_CURRENT_LIST_DIR}/librt_test.c") + else() + message(FATAL_ERROR "Either C or CXX must be enabled.") + endif() + + try_compile( + LibRT_NO_EXPLICIT_LINK + "${CMAKE_CURRENT_BINARY_DIR}" + SOURCES "${LibRT_TEST_SOURCE}" + CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${LibRT_INCLUDE_DIR}" + ) + + endif(DEFINED LibRT_EXPLICIT_LINK) + + if (LibRT_NO_EXPLICIT_LINK) + set (LibRT_EXPLICIT_LINK FALSE CACHE BOOL "${LibRT_EXPLICIT_LINK_DOCSTR}") + set(LibRT_LIBRARY "" CACHE FILEPATH "${LibRT_LIBRARY_DOCSTR}") + find_package_handle_standard_args(LibRT REQUIRED_VARS LibRT_INCLUDE_DIR) + else(LibRT_NO_EXPLICIT_LINK) + set (LibRT_EXPLICIT_LINK TRUE CACHE BOOL "${LibRT_EXPLICIT_LINK_DOCSTR}") + find_library(LibRT_LIBRARY NAMES rt DOC "${LibRT_LIBRARY_DOCSTR}") + find_package_handle_standard_args(LibRT REQUIRED_VARS LibRT_LIBRARY LibRT_INCLUDE_DIR) + endif(LibRT_NO_EXPLICIT_LINK) + +else(LibRT_INCLUDE_DIR) + + set(LibRT_LIBRARY "LibRT_LIBRARY-NOTFOUND" CACHE FILEPATH "${LibRT_LIBRARY_DOCSTR}") + find_package_handle_standard_args(LibRT REQUIRED_VARS LibRT_LIBRARY LibRT_INCLUDE_DIR) + +endif(LibRT_INCLUDE_DIR) + +if (LibRT_FOUND) + if (NOT TARGET LibRT::LibRT) + add_library (LibRT::LibRT INTERFACE IMPORTED) + set_target_properties(LibRT::LibRT PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${LibRT_INCLUDE_DIR}") + if (LibRT_EXPLICIT_LINK) + set_target_properties(LibRT::LibRT PROPERTIES IMPORTED_LOCATION "${LibRT_LIBRARY}") + endif(LibRT_EXPLICIT_LINK) + endif(NOT TARGET LibRT::LibRT) + if (NOT TARGET rt::rt) + add_library(rt::rt ALIAS LibRT::LibRT) + endif(NOT TARGET rt::rt) +endif(LibRT_FOUND) + +cmake_policy(POP) diff --git a/cmake/FindZeroMQ.cmake b/cmake/FindZeroMQ.cmake index 9bf3827..34ac115 100644 --- a/cmake/FindZeroMQ.cmake +++ b/cmake/FindZeroMQ.cmake @@ -32,14 +32,22 @@ TODO #]=======================================================================] cmake_policy(PUSH) -cmake_policy(SET CMP0054 NEW) # Only interpret if() arguments as variables or keywords when unquoted +cmake_minimum_required(VERSION 3.12...3.18 FATAL_ERROR) +if (POLICY CMP0125) + # Consistent behavior for cache variables managed by find_*() + cmake_policy(SET CMP0125 NEW) +endif() +if (POLICY CMP0132) + # Consistent handling of compiler environment variables + cmake_policy(SET CMP0132 NEW) +endif() find_path(ZeroMQ_INCLUDE_DIR NAMES zmq.h) find_library(ZeroMQ_LIBRARY NAMES zmq) include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(ZeroMQ - REQUIRED_VARS ZeroMQ_INCLUDE_DIR ZeroMQ_LIBRARY) + REQUIRED_VARS ZeroMQ_LIBRARY ZeroMQ_INCLUDE_DIR) if (ZeroMQ_FOUND) if (NOT TARGET ZeroMQ::libzmq) diff --git a/cmake/Findcppzmq.cmake b/cmake/Findcppzmq.cmake index 55a3cde..d7e66e0 100644 --- a/cmake/Findcppzmq.cmake +++ b/cmake/Findcppzmq.cmake @@ -30,7 +30,15 @@ TODO #]=======================================================================] cmake_policy(PUSH) -cmake_policy(SET CMP0054 NEW) # Only interpret if() arguments as variables or keywords when unquoted +cmake_minimum_required(VERSION 3.12...3.18 FATAL_ERROR) +if (POLICY CMP0125) + # Consistent behavior for cache variables managed by find_*() + cmake_policy(SET CMP0125 NEW) +endif() +if (POLICY CMP0132) + # Consistent handling of compiler environment variables + cmake_policy(SET CMP0132 NEW) +endif() unset(_cppzmq_ZeroMQ_REQUIRED) if (cppzmq_FIND_REQUIRED) diff --git a/cmake/fuse_test.c b/cmake/fuse_test.c new file mode 100644 index 0000000..8eba916 --- /dev/null +++ b/cmake/fuse_test.c @@ -0,0 +1,9 @@ +#include +#include +#include +#include +#include + +int main(void) { + return 0; +} diff --git a/cmake/fuse_test.cpp b/cmake/fuse_test.cpp new file mode 100644 index 0000000..b6e6f17 --- /dev/null +++ b/cmake/fuse_test.cpp @@ -0,0 +1,9 @@ +#include +#include +#include +#include +#include + +int main(void) { + return 0; +} diff --git a/cmake/librt_test.c b/cmake/librt_test.c new file mode 100644 index 0000000..8ca9ce7 --- /dev/null +++ b/cmake/librt_test.c @@ -0,0 +1,11 @@ +#include + +#include +#include + +int main(void) { + timer_t timerid; + struct sigevent sev; + timer_create(CLOCK_REALTIME, &sev, &timerid); + return 0; +} diff --git a/cmake/librt_test.cpp b/cmake/librt_test.cpp new file mode 100644 index 0000000..23b9843 --- /dev/null +++ b/cmake/librt_test.cpp @@ -0,0 +1,11 @@ +#include + +#include +#include + +int main(void) { + timer_t timerid{}; + struct sigevent sev{}; + timer_create(CLOCK_REALTIME, &sev, &timerid); + return 0; +}