From aa187918541f8a4fbf0b7e50af652b74b9af47bf Mon Sep 17 00:00:00 2001 From: Marcus Holland-Moritz Date: Sun, 11 Aug 2024 19:23:55 +0200 Subject: [PATCH] build: factor out FUSE loading --- CMakeLists.txt | 19 ++----------------- cmake/need_fuse.cmake | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 17 deletions(-) create mode 100644 cmake/need_fuse.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 680953f8..6dbfc368 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -203,23 +203,6 @@ if(USE_JEMALLOC) pkg_check_modules(JEMALLOC IMPORTED_TARGET jemalloc>=${JEMALLOC_REQUIRED_VERSION}) endif() -if(WIN32) - if(NOT WINFSP_PATH) - set(WINFSP_PATH "C:/Program Files (x86)/WinFsp") - endif() - find_library(WINFSP winfsp-x64.lib "${WINFSP_PATH}/lib") - if (NOT WINFSP) - message(FATAL_ERROR "No WinFsp library found") - endif() -else() - pkg_check_modules(FUSE IMPORTED_TARGET fuse>=2.9.9) - pkg_check_modules(FUSE3 IMPORTED_TARGET fuse3>=3.10.5) - - if(NOT FUSE_FOUND AND NOT FUSE3_FOUND) - message(FATAL_ERROR "No FUSE or FUSE3 library found") - endif() -endif() - include(${CMAKE_SOURCE_DIR}/cmake/thrift_library.cmake) include(${CMAKE_SOURCE_DIR}/cmake/folly.cmake) @@ -264,6 +247,8 @@ install(TARGETS mkdwarfs dwarfsck dwarfsextract RUNTIME DESTINATION bin) list(APPEND MAIN_TARGETS mkdwarfs_main dwarfsck_main dwarfsextract_main) +include(${CMAKE_SOURCE_DIR}/cmake/need_fuse.cmake) + if(FUSE3_FOUND OR WINFSP OR APPLE) add_library(dwarfs_main OBJECT tools/src/dwarfs_main.cpp) target_compile_definitions(dwarfs_main PRIVATE _FILE_OFFSET_BITS=64) diff --git a/cmake/need_fuse.cmake b/cmake/need_fuse.cmake new file mode 100644 index 00000000..b0a4e9cb --- /dev/null +++ b/cmake/need_fuse.cmake @@ -0,0 +1,36 @@ +# +# Copyright (c) Marcus Holland-Moritz +# +# This file is part of dwarfs. +# +# dwarfs is free software: you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation, either version 3 of the License, or (at your option) any later +# version. +# +# dwarfs is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# dwarfs. If not, see . +# + +cmake_minimum_required(VERSION 3.28.0) + +if(WIN32) + if(NOT WINFSP_PATH) + set(WINFSP_PATH "C:/Program Files (x86)/WinFsp") + endif() + find_library(WINFSP winfsp-x64.lib "${WINFSP_PATH}/lib") + if (NOT WINFSP) + message(FATAL_ERROR "No WinFsp library found") + endif() +else() + pkg_check_modules(FUSE IMPORTED_TARGET fuse>=2.9.9) + pkg_check_modules(FUSE3 IMPORTED_TARGET fuse3>=3.10.5) + + if(NOT FUSE_FOUND AND NOT FUSE3_FOUND) + message(FATAL_ERROR "No FUSE or FUSE3 library found") + endif() +endif()