- 
                Notifications
    
You must be signed in to change notification settings  - Fork 90
 
Cmake build system implementation #525
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Draft
      
      
            madjesc
  wants to merge
  1
  commit into
  LinearTapeFileSystem:master
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
madjesc:build/cmake
  
      
      
   
  
    
  
  
  
 
  
      
    base: master
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
  
     Draft
                    Changes from all commits
      Commits
    
    
  File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| #### | ||
| # Find libfuse and set the offset to 64bits | ||
| ### | ||
| find_package(PkgConfig REQUIRED) | ||
| 
     | 
||
| pkg_check_modules(FUSE REQUIRED "fuse>=2.6.0" IMPORTED_TARGET) | ||
| target_compile_definitions(PkgConfig::FUSE INTERFACE | ||
| _FILE_OFFSET_BITS=64 | ||
| ) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| ##### | ||
| # Find the Net SNMP library (net-snmp) | ||
| # | ||
| option(ENABLE_SNMP "Enable SNMP support" YES) | ||
| set(NetSNMP_FOUND OFF CACHE BOOL "net-snmp is found") | ||
| 
     | 
||
| if(ENABLE_SNMP OR NetSNMP_FIND_REQUIRED) | ||
| find_program(NetSNMP_CONFIG_BIN net-snmp-config REQUIRED) | ||
| else() | ||
| find_program(NetSNMP_CONFIG_BIN net-snmp-config) | ||
| endif() | ||
| 
     | 
||
| 
     | 
||
| if(NetSNMP_CONFIG_BIN) | ||
| execute_process(COMMAND ${NetSNMP_CONFIG_BIN} --cflags | ||
| OUTPUT_VARIABLE NetSNMP_CFLAGS | ||
| OUTPUT_STRIP_TRAILING_WHITESPACE | ||
| ) | ||
| execute_process(COMMAND ${NetSNMP_CONFIG_BIN} --libs | ||
| OUTPUT_VARIABLE NetSNMP_LIBS | ||
| OUTPUT_STRIP_TRAILING_WHITESPACE | ||
| ) | ||
| execute_process(COMMAND ${NetSNMP_CONFIG_BIN} --agent-libs | ||
| OUTPUT_VARIABLE NetSNMP_AGENT_LIBS | ||
| OUTPUT_STRIP_TRAILING_WHITESPACE | ||
| ) | ||
| # NetSNMP import library | ||
| add_library(NetSNMP INTERFACE IMPORTED) | ||
| separate_arguments(NetSNMP_CFLAGS) | ||
| separate_arguments(NetSNMP_AGENT_LIBS) | ||
| separate_arguments(NetSNMP_LIBS) | ||
| 
     | 
||
| set_target_properties(NetSNMP PROPERTIES | ||
| INTERFACE_COMPILE_OPTIONS "${NetSNMP_CFLAGS};${NetSNMP_LIBS};${NetSNMP_AGENT_LIBS}" | ||
| ) | ||
| set(NetSNMP_FOUND ON CACHE BOOL "net-snmp is found") | ||
| endif() | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| ### | ||
| # Find UUID package | ||
| # | ||
| find_package(PkgConfig REQUIRED) | ||
| 
     | 
||
| if(APPLE) | ||
| pkg_check_modules(UUID REQUIRED "uuid>=1.6" IMPORTED_TARGET) | ||
| else() | ||
| pkg_check_modules(UUID REQUIRED "uuid>=1.36" IMPORTED_TARGET) | ||
| endif() | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # | ||
| # Set the tape backend and set default in case is not defined | ||
| # | ||
| macro(option_tape_backend) | ||
| if (NOT DEFAULT_TAPE) | ||
| if(LINUX) | ||
| set(DEFAULT_TAPE sg) | ||
| elseif(APPLE) | ||
| set(DEFAULT_TAPE iokit) | ||
| elseif(BSD) | ||
| if(FREEBSD) | ||
| set(DEFAULT_TAPE cam) | ||
| elseif(NETBSD) | ||
| set(DEFAULT_TAPE scsipi-ibmtape) | ||
| endif() | ||
| endif() | ||
| elseif (NOT ENABLE_LINTAPE AND DEFAULT_TAPE STREQUAL "lin_tape") | ||
| message(FATAL_ERROR "lin_tape is not enabled -DENABLE_LINTAPE is required.") | ||
| endif() | ||
| endmacro() | ||
| 
     | 
||
| macro(option_unorm2) | ||
| string(REPLACE "." ";" ICU_VERSION_ARRAY ${ICU_VERSION}) | ||
| list(GET ICU_VERSION_ARRAY 0 ICU_VERSION_MAJOR) | ||
| if(ICU_6X OR ICU_VERSION_MAJOR GREATER_EQUAL "56") | ||
| add_compile_definitions(USE_UNORM2) | ||
| message(STATUS "Using ICU6x funtions") | ||
| endif() | ||
| endmacro() | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| cmake_minimum_required(VERSION 3.26) | ||
| project(ltfs LANGUAGES C) | ||
| set(VERSION "2.5.0.0 (Prelim cmake)") | ||
| set(CMAKE_EXPORT_COMPILE_COMMANDS ON) | ||
| set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/.cmake") | ||
| 
     | 
||
| if(NOT CMAKE_BUILD_TYPE MATCHES "Debug|Release") | ||
| set(CMAKE_BUILD_TYPE Debug) | ||
| endif() | ||
| 
     | 
||
| # Add dependencies | ||
| include(GNUInstallDirs REQUIRED) | ||
| include(LTFSUtils REQUIRED) | ||
| find_package(Threads REQUIRED) | ||
| find_package(ICU COMPONENTS uc) | ||
| find_package(LibXml2 REQUIRED) | ||
| find_package(FUSE REQUIRED) | ||
| find_package(UUID REQUIRED) | ||
| find_package(NetSNMP) | ||
| # Configure project | ||
| set(DEFAULT_TAPE "" CACHE STRING "default tape backend plugin, e.g. sg, iokit, cam, scsipi-ibmtape") | ||
| set(DEFAULT_IOSCHED "unified" CACHE STRING "default I/O scheduler plugin, e.g. unified") | ||
| set(DEFAULT_KMI "none" CACHE STRING "default key manager interface plugin, e.g. none") | ||
| option(MSG_CHECK "compile in message checking mode (may be binary is defunct)" OFF) | ||
| option(POSIXLINK_ONLY "compile with livelink mode support" ON) | ||
| option(USE_NEW_LOCKING "use new locking system or not" ON) | ||
| option(ENABLE_LIN_TAPE "support IBM's lin_tape driver or not" OFF) | ||
| option(SUPPORT_BUGGY_IFS "support buggy I/Fs for tape drivers" OFF) | ||
| option(INDENT_INDEXES "enable xml indentation for index" OFF) | ||
| option(FORMAT_SPEC25 "support format spec 2.5 or not" OFF) | ||
| option(ICU_6X "force to use ICU6x (unorm2) functions" OFF) | ||
| option(HAVE_XML_PARSE_HUGE "enable xml parsing with huge file support" OFF) | ||
| option_tape_backend() | ||
| option_unorm2() | ||
| add_compile_definitions(_GNU_SOURCE __CMAKE_BUILD) | ||
| 
     | 
||
| # Generate targets and configrations | ||
| add_subdirectory(messages) | ||
| add_subdirectory(src) | ||
| add_subdirectory(conf) | ||
| add_subdirectory(man) | ||
| configure_file(ltfs.pc.in ltfs.pc) | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| # NOTE: This can be done using an .in file with @VARS@ but somehow this is done using sed | ||
| set(PLAT_OPTS) | ||
| if(ENABLE_LINTAPE) | ||
| # list(APPEND PLAT_OPTS "plugin tape lin_tape ${CMAKE_INSTALL_LIBDIR}/ltfs/libtape_lin_tape.so") | ||
| list(APPEND PLAT_OPTS "plugin tape lin_tape libtape_lin_tape.so") | ||
| endif() | ||
| 
     | 
||
| if(LINUX) | ||
| list(APPEND PLAT_OPTS "plugin tape sg libtape_sg.so") | ||
| elseif(APPLE) | ||
| list(APPEND PLAT_OPTS "plugin tape iokit libtape_iokit.so") | ||
| elseif(BSD) | ||
| if (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") | ||
| list(APPEND PLAT_OPTS "plugin tape cam libtape-cam.so") | ||
| elseif(CMAKE_SYSTEM_NAME STREQUAL "NetBSD") | ||
| list(APPEND PLAT_OPTS "plugin tape scsipi-ibmtape libtape_scsipi_ibmtape.so") | ||
| endif() | ||
| endif() | ||
| 
     | 
||
| file(REAL_PATH "ltfs.conf.in" CONFIG_FILE) | ||
| file(COPY_FILE "ltfs.conf.local" "${CMAKE_CURRENT_BINARY_DIR}/ltfs.conf.local") | ||
| add_custom_command(OUTPUT "ltfs.conf" | ||
| COMMAND sed -e "s!__PLATFORM_DRIVERS__!${PLAT_OPTS}!" ${CONFIG_FILE} > .tmp1 | ||
| COMMAND sed -e "s!__LIBDIR__!${CMAKE_INSTALL_LIBDIR}!" .tmp1 > .tmp2 | ||
| COMMAND sed -e "s!__DEFAULT_TAPE__!${DEFAULT_TAPE}!" .tmp2 > .tmp1 | ||
| COMMAND sed -e "s!__DEFAULT_IOSCHED__!${DEFAULT_IOSCHED}!" .tmp1 > .tmp2 | ||
| COMMAND sed -e "s!__DEFAULT_KMI__!${DEFAULT_KMI}!" .tmp2 > .tmp1 | ||
| COMMAND sed -e "s!__CONFDIR__!${CMAKE_CURRENT_BINARY_DIR}!" .tmp1 > ltfs.conf | ||
| DEPENDS ${CONFIG_FILE} | ||
| BYPRODUCTS .tmp1 .tmp2 | ||
| ) | ||
| add_custom_target("conf" ALL DEPENDS "ltfs.conf") | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| set(MANPAGES | ||
| mkltfs | ||
| ltfsck | ||
| ltfs | ||
| ltfs_ordered_copy | ||
| ltfsindextool | ||
| ) | ||
| 
     | 
||
| add_custom_target(man) | ||
| foreach(NAME IN LISTS MANPAGES) | ||
| file(REAL_PATH "sgml/${NAME}.sgml" SOURCE) | ||
| add_custom_target("man_${NAME}" | ||
| docbook2man ${SOURCE} # 2> /dev/null | ||
| DEPENDS ${SOURCE} | ||
| ) | ||
| add_dependencies(man "man_${NAME}") | ||
| endforeach() | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| set(MESSAGES_LIBS | ||
| bin_ltfs | ||
| bin_ltfsck | ||
| bin_ltfsindextool | ||
| bin_mkltfs | ||
| internal_error | ||
| iosched_fcfs | ||
| iosched_unified | ||
| kmi_flatfile | ||
| kmi_simple | ||
| libltfs | ||
| tape_common | ||
| tape_freebsd_cam | ||
| tape_generic_file | ||
| tape_generic_itdtimg | ||
| tape_iokit | ||
| tape_linux_lin_tape | ||
| tape_linux_sg | ||
| ) | ||
| set(LIBS) | ||
| foreach(NAME IN LISTS MESSAGES_LIBS) | ||
| file(GLOB SRCS "${NAME}/*.txt") | ||
| set(OUT "lib${NAME}.a") | ||
| list(APPEND LIBS ${OUT}) | ||
| 
     | 
||
| make_directory("${CMAKE_CURRENT_BINARY_DIR}/res_${NAME}") | ||
| add_custom_command(OUTPUT ${OUT} | ||
| COMMAND ${ICU_GENRB_EXECUTABLE} -q ${SRCS} 1> /dev/null | ||
| COMMAND ls *.res > paths.txt | ||
| COMMAND ${ICU_PKGDATA_EXECUTABLE} -m static -p ${NAME} -q paths.txt 1> /dev/null | ||
| COMMAND cp ${OUT} .. | ||
| DEPENDS ${SRCS} | ||
| BYPRODUCTS res_${NAME} | ||
| WORKING_DIRECTORY res_${NAME} | ||
| ) | ||
| 
     | 
||
| # Define the library as an imported CMake lib | ||
| add_library("lib${NAME}" STATIC IMPORTED GLOBAL) | ||
| set_target_properties("lib${NAME}" PROPERTIES IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/lib${NAME}.a") | ||
| add_dependencies("lib${NAME}" "messages") | ||
| endforeach() | ||
| # Do this to not rebuild the entire message libraries every run | ||
| add_custom_target(messages ALL DEPENDS ${LIBS}) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| add_executable(ltfs_bin main.c ltfs_fuse.c) | ||
| target_link_libraries(ltfs_bin | ||
| Threads::Threads | ||
| PkgConfig::FUSE | ||
| LibXml2::LibXml2 | ||
| PkgConfig::UUID | ||
| ICU::uc | ||
| ltfs | ||
| ) | ||
| set_property(TARGET ltfs_bin PROPERTY OUTPUT_NAME ltfs) | ||
| target_include_directories(ltfs_bin BEFORE PUBLIC "." ) | ||
| 
     | 
||
| add_compile_definitions( | ||
| LTFS_CONFIG_FILE="${CMAKE_BINARY_DIR}/conf/ltfs.conf" | ||
| LTFS_BASE_DIR="${CMAKE_INSTALL_PREFIX}" | ||
| PACKAGE_VERSION="${VERSION}" | ||
| PACKAGE_NAME="${PROJECT_NAME}" | ||
| ) | ||
| 
     | 
||
| add_subdirectory(iosched) | ||
| add_subdirectory(kmi) | ||
| add_subdirectory(libltfs) | ||
| add_subdirectory(utils) | ||
| add_subdirectory(tape_drivers) | ||
| add_subdirectory(tape_drivers/generic/file) | ||
| add_subdirectory(tape_drivers/generic/itdtimg) | ||
| if(ENABLE_LINTAPE) | ||
| add_subdirectory(tape_drivers/linux/lin_tape) | ||
| endif() | ||
| if(LINUX) | ||
| add_subdirectory(tape_drivers/linux/sg) | ||
| elseif(APPLE) | ||
| add_subdirectory(tape_drivers/osx/iokit) | ||
| elseif(BSD) | ||
| if (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") | ||
| add_subdirectory(tape_drivers/freebsd/cam) | ||
| elseif(CMAKE_SYSTEM_NAME STREQUAL "NetBSD") | ||
| add_subdirectory(tape_drivers/netbsd/scsipi-ibmtape) | ||
| endif() | ||
| endif() | ||
| 
     | 
||
| # Configure the plugins rpath to search in | ||
| if(CMAKE_BUILD_TYPE STREQUAL "Release") | ||
| set_target_properties(ltfs PROPERTIES BUILD_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}") | ||
| else() | ||
| set_target_properties(ltfs PROPERTIES BUILD_RPATH "${PLUGINS_PATHS}") | ||
| endif() | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| add_library(iosched-fcfs SHARED fcfs.c) | ||
| target_link_libraries(iosched-fcfs | ||
| PkgConfig::FUSE | ||
| ltfs | ||
| libiosched_fcfs | ||
| ) | ||
| target_include_directories(iosched-fcfs BEFORE PUBLIC "..") | ||
| 
     | 
||
| add_library(iosched-unified SHARED | ||
| unified.c | ||
| cache_manager.c | ||
| ) | ||
| target_link_libraries(iosched-unified | ||
| PkgConfig::FUSE | ||
| ltfs | ||
| libiosched_unified | ||
| ) | ||
| target_include_directories(iosched-unified BEFORE PUBLIC "..") | ||
| 
     | 
||
| set(PLUGINS_PATHS "${PLUGINS_PATHS};${CMAKE_CURRENT_BINARY_DIR}" PARENT_SCOPE) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| add_library(kmi-simple SHARED | ||
| simple.c | ||
| key_format_ltfs.c | ||
| ) | ||
| target_link_libraries(kmi-simple | ||
| PkgConfig::FUSE | ||
| ltfs | ||
| libkmi_simple | ||
| ) | ||
| target_include_directories(kmi-simple BEFORE PUBLIC "..") | ||
| 
     | 
||
| add_library(kmi-flatfile SHARED | ||
| flatfile.c | ||
| key_format_ltfs.c | ||
| ) | ||
| target_link_libraries(kmi-flatfile | ||
| PkgConfig::FUSE | ||
| ltfs | ||
| libkmi_flatfile | ||
| ) | ||
| target_include_directories(kmi-flatfile BEFORE PUBLIC "..") | ||
| 
     | 
||
| set(PLUGINS_PATHS "${PLUGINS_PATHS};${CMAKE_CURRENT_BINARY_DIR}" PARENT_SCOPE) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| file(GLOB_RECURSE LIBLTFS_SRCS LIST_DIRECTORIES false "*.c") | ||
| add_library(ltfs SHARED ${LIBLTFS_SRCS}) | ||
| target_include_directories(ltfs BEFORE PUBLIC "..") | ||
| 
     | 
||
| target_link_libraries(ltfs | ||
| Threads::Threads | ||
| PkgConfig::FUSE | ||
| LibXml2::LibXml2 | ||
| PkgConfig::UUID | ||
| libbin_ltfs | ||
| liblibltfs | ||
| libinternal_error | ||
| libtape_common | ||
| ) | ||
| 
     | 
||
| if(ENABLE_SNMP) | ||
| target_link_libraries(ltfs NetSNMP) | ||
| endif() | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
      
      Oops, something went wrong.
        
    
  
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.