diff --git a/dokan_fuse/CMakeLists.txt b/dokan_fuse/CMakeLists.txt index 962ba5c7c..b67c9446a 100644 --- a/dokan_fuse/CMakeLists.txt +++ b/dokan_fuse/CMakeLists.txt @@ -7,6 +7,8 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE) endif(NOT CMAKE_BUILD_TYPE) +option(FUSE_PKG_CONFIG "Install a libfuse-compatible pkg-config file (fuse.pc)" ON) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -mwin32 -Wall") add_definitions(-D_FILE_OFFSET_BITS=64) include_directories( @@ -14,6 +16,33 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../sys ) +if(FUSE_PKG_CONFIG) + # Defining helper-function to deal with setups that manually set an + # absolute path for CMAKE_INSTALL_(LIB|INCLUDE)DIR... + # We could also just make all paths absolute, but this way the + # pkg-config-file is more human-readable and pkg-config may be able to deal + # with varying prefixes. + # CMake does not have a ternary operator for generator expressions, so this + # looks more complicated than it is. + function ( make_pkg_config_absolute out_path in_path ) + if(IS_ABSOLUTE "${${in_path}}") + set(${out_path} "${${in_path}}" PARENT_SCOPE) + else() + set(${out_path} "\${prefix}/${${in_path}}" PARENT_SCOPE) + endif() + endfunction() + + set(pkg_config_file "${CMAKE_CURRENT_BINARY_DIR}/fuse.pc") + make_pkg_config_absolute(PKG_CONFIG_LIBDIR CMAKE_INSTALL_LIBDIR) + make_pkg_config_absolute(PKG_CONFIG_INCLUDEDIR CMAKE_INSTALL_INCLUDEDIR) + + CONFIGURE_FILE( + "${CMAKE_CURRENT_SOURCE_DIR}/pkg-config.pc.in" + ${pkg_config_file} + @ONLY + ) +endif() + file(GLOB sources src/*.cpp src/*.c src/*.rc) set(install_headers include/fuse.h @@ -30,6 +59,9 @@ add_library(dokanfuse1 SHARED ${sources}) INSTALL(FILES ${install_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/fuse/) INSTALL(FILES ${compat_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +if(FUSE_PKG_CONFIG) + INSTALL(FILES ${pkg_config_file} DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +endif() INSTALL(TARGETS dokanfuse1 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} diff --git a/dokan_fuse/pkg-config.pc.in b/dokan_fuse/pkg-config.pc.in new file mode 100644 index 000000000..ebc0ade3a --- /dev/null +++ b/dokan_fuse/pkg-config.pc.in @@ -0,0 +1,13 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=${prefix} +libdir=@PKG_CONFIG_LIBDIR@ +includedir=@PKG_CONFIG_INCLUDEDIR@ + +Name: Dokan FUSE +Description: FUSE-API compatibility library for the Dokan user mode filesystem driver for Windows +# Dokan FUSE provides compatibility with libfuse 2.6.x. +# The corresponding libfuse-version is therefore reported instead of the Dokan FUSE-version +Version: 2.6.0 +URL: https://dokan-dev.github.io +Libs: -L${libdir} -l@PROJECT_NAME@ +Cflags: -I${includedir} -D_FILE_OFFSET_BITS=64