"Fossies" - the Fresh Open Source Software Archive

Member "xxHash-0.8.0/cmake_unofficial/CMakeLists.txt" (27 Jul 2020, 6640 Bytes) of package /linux/misc/xxHash-0.8.0.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "CMakeLists.txt": 0.7.3_vs_0.7.4.

    1 # To the extent possible under law, the author(s) have dedicated all
    2 # copyright and related and neighboring rights to this software to
    3 # the public domain worldwide. This software is distributed without
    4 # any warranty.
    5 #
    6 # For details, see <https://creativecommons.org/publicdomain/zero/1.0/>.
    7 
    8 cmake_minimum_required (VERSION 2.8.12 FATAL_ERROR)
    9 
   10 set(XXHASH_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..")
   11 
   12 file(STRINGS "${XXHASH_DIR}/xxhash.h" XXHASH_VERSION_MAJOR REGEX "^#define XXH_VERSION_MAJOR +([0-9]+) *$")
   13 string(REGEX REPLACE "^#define XXH_VERSION_MAJOR +([0-9]+) *$" "\\1" XXHASH_VERSION_MAJOR "${XXHASH_VERSION_MAJOR}")
   14 file(STRINGS "${XXHASH_DIR}/xxhash.h" XXHASH_VERSION_MINOR REGEX "^#define XXH_VERSION_MINOR +([0-9]+) *$")
   15 string(REGEX REPLACE "^#define XXH_VERSION_MINOR +([0-9]+) *$" "\\1" XXHASH_VERSION_MINOR "${XXHASH_VERSION_MINOR}")
   16 file(STRINGS "${XXHASH_DIR}/xxhash.h" XXHASH_VERSION_RELEASE REGEX "^#define XXH_VERSION_RELEASE +([0-9]+) *$")
   17 string(REGEX REPLACE "^#define XXH_VERSION_RELEASE +([0-9]+) *$" "\\1" XXHASH_VERSION_RELEASE "${XXHASH_VERSION_RELEASE}")
   18 set(XXHASH_VERSION_STRING "${XXHASH_VERSION_MAJOR}.${XXHASH_VERSION_MINOR}.${XXHASH_VERSION_RELEASE}")
   19 set(XXHASH_LIB_VERSION ${XXHASH_VERSION_STRING})
   20 set(XXHASH_LIB_SOVERSION "${XXHASH_VERSION_MAJOR}")
   21 mark_as_advanced(XXHASH_VERSION_MAJOR XXHASH_VERSION_MINOR XXHASH_VERSION_RELEASE XXHASH_VERSION_STRING XXHASH_LIB_VERSION XXHASH_LIB_SOVERSION)
   22 
   23 if("${CMAKE_VERSION}" VERSION_LESS "3.13")
   24     #message(WARNING "CMake ${CMAKE_VERSION} has no CMP0077 policy: options will erase uncached/untyped normal vars!")
   25 else()
   26     cmake_policy (SET CMP0077 NEW)
   27 endif()
   28 if("${CMAKE_VERSION}" VERSION_LESS "3.0")
   29     project(xxHash C)
   30 else()
   31     cmake_policy (SET CMP0048 NEW)
   32     project(xxHash
   33         VERSION ${XXHASH_VERSION_STRING}
   34         LANGUAGES C)
   35 endif()
   36 
   37 if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
   38   set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Project build type" FORCE)
   39   set_property(CACHE CMAKE_BUILD_TYPE
   40     PROPERTY STRINGS "Debug" "Release" "RelWithDebInfo" "MinSizeRel")
   41 endif()
   42 if(NOT CMAKE_CONFIGURATION_TYPES)
   43   message(STATUS "xxHash build type: ${CMAKE_BUILD_TYPE}")
   44 endif()
   45 
   46 option(BUILD_SHARED_LIBS "Build shared library" ON)
   47 set(XXHASH_BUILD_XXHSUM ON CACHE BOOL "Build the xxhsum binary")
   48 
   49 # If XXHASH is being bundled in another project, we don't want to
   50 # install anything.  However, we want to let people override this, so
   51 # we'll use the XXHASH_BUNDLED_MODE variable to let them do that; just
   52 # set it to OFF in your project before you add_subdirectory(xxhash/cmake_unofficial).
   53 if(NOT DEFINED XXHASH_BUNDLED_MODE)
   54   if("${PROJECT_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
   55     set(XXHASH_BUNDLED_MODE OFF)
   56   else()
   57     set(XXHASH_BUNDLED_MODE ON)
   58   endif()
   59 endif()
   60 set(XXHASH_BUNDLED_MODE ${XXHASH_BUNDLED_MODE} CACHE BOOL "" FORCE)
   61 mark_as_advanced(XXHASH_BUNDLED_MODE)
   62 
   63 # Allow people to choose whether to build shared or static libraries
   64 # via the BUILD_SHARED_LIBS option unless we are in bundled mode, in
   65 # which case we always use static libraries.
   66 include(CMakeDependentOption)
   67 CMAKE_DEPENDENT_OPTION(BUILD_SHARED_LIBS "Build shared libraries" ON "NOT XXHASH_BUNDLED_MODE" OFF)
   68 
   69 # libxxhash
   70 add_library(xxhash "${XXHASH_DIR}/xxhash.c")
   71 add_library(${PROJECT_NAME}::xxhash ALIAS xxhash)
   72 
   73 target_include_directories(xxhash
   74   PUBLIC
   75     $<BUILD_INTERFACE:${XXHASH_DIR}>
   76     $<INSTALL_INTERFACE:include/>)
   77 if (BUILD_SHARED_LIBS)
   78   target_compile_definitions(xxhash PUBLIC XXH_EXPORT)
   79 endif ()
   80 set_target_properties(xxhash PROPERTIES
   81   SOVERSION "${XXHASH_VERSION_STRING}"
   82   VERSION "${XXHASH_VERSION_STRING}")
   83 
   84 if(XXHASH_BUILD_XXHSUM)
   85   # xxhsum
   86   add_executable(xxhsum "${XXHASH_DIR}/xxhsum.c")
   87   add_executable(${PROJECT_NAME}::xxhsum ALIAS xxhsum)
   88 
   89   target_link_libraries(xxhsum PRIVATE xxhash)
   90   target_include_directories(xxhsum PRIVATE "${XXHASH_DIR}")
   91 endif(XXHASH_BUILD_XXHSUM)
   92 
   93 # Extra warning flags
   94 include (CheckCCompilerFlag)
   95 if (XXHASH_C_FLAGS)
   96   set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${XXHASH_C_FLAGS}")
   97 endif()
   98 foreach (flag
   99     -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow
  100     -Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement
  101     -Wstrict-prototypes -Wundef)
  102   # Because https://gcc.gnu.org/wiki/FAQ#wnowarning
  103   string(REGEX REPLACE "\\-Wno\\-(.+)" "-W\\1" flag_to_test "${flag}")
  104   string(REGEX REPLACE "[^a-zA-Z0-9]+" "_" test_name "CFLAG_${flag_to_test}")
  105 
  106   check_c_compiler_flag("${ADD_COMPILER_FLAGS_PREPEND} ${flag_to_test}" ${test_name})
  107 
  108   if(${test_name})
  109     set(CMAKE_C_FLAGS "${flag} ${CMAKE_C_FLAGS}")
  110   endif()
  111 
  112   unset(test_name)
  113   unset(flag_to_test)
  114 endforeach (flag)
  115 
  116 if(NOT XXHASH_BUNDLED_MODE)
  117   include(GNUInstallDirs)
  118 
  119   install(TARGETS xxhash
  120     EXPORT xxHashTargets
  121     RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
  122     LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
  123     ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}")
  124   install(FILES "${XXHASH_DIR}/xxhash.h"
  125     DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
  126   install(FILES "${XXHASH_DIR}/xxh3.h"
  127     DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
  128   if(XXHASH_BUILD_XXHSUM)
  129     install(TARGETS xxhsum
  130       EXPORT xxHashTargets
  131       RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
  132     install(FILES "${XXHASH_DIR}/xxhsum.1"
  133       DESTINATION "${CMAKE_INSTALL_MANDIR}/man1")
  134   endif(XXHASH_BUILD_XXHSUM)
  135 
  136   include(CMakePackageConfigHelpers)
  137 
  138   set(xxHash_VERSION_CONFIG "${PROJECT_BINARY_DIR}/xxHashConfigVersion.cmake")
  139   set(xxHash_PROJECT_CONFIG "${PROJECT_BINARY_DIR}/xxHashConfig.cmake")
  140   set(xxHash_TARGETS_CONFIG "${PROJECT_BINARY_DIR}/xxHashTargets.cmake")
  141   set(xxHash_CONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/xxHash/")
  142   write_basic_package_version_file(${xxHash_VERSION_CONFIG}
  143     VERSION ${XXHASH_VERSION_STRING}
  144     COMPATIBILITY AnyNewerVersion)
  145   configure_package_config_file(
  146     ${PROJECT_SOURCE_DIR}/xxHashConfig.cmake.in
  147     ${xxHash_PROJECT_CONFIG}
  148     INSTALL_DESTINATION ${xxHash_CONFIG_INSTALL_DIR})
  149   if("${CMAKE_VERSION}" VERSION_LESS "3.0")
  150       set(XXHASH_EXPORT_SET xxhash)
  151       if(XXHASH_BUILD_XXHSUM)
  152         set(XXHASH_EXPORT_SET ${XXHASH_EXPORT_SET} xxhsum)
  153       endif()
  154       export(TARGETS ${XXHASH_EXPORT_SET}
  155       FILE ${xxHash_TARGETS_CONFIG}
  156       NAMESPACE ${PROJECT_NAME}::)
  157   else()
  158     export(EXPORT xxHashTargets
  159       FILE ${xxHash_TARGETS_CONFIG}
  160       NAMESPACE ${PROJECT_NAME}::)
  161   endif()
  162 
  163   install(FILES ${xxHash_PROJECT_CONFIG} ${xxHash_VERSION_CONFIG}
  164     DESTINATION ${xxHash_CONFIG_INSTALL_DIR})
  165   install(EXPORT xxHashTargets
  166     DESTINATION ${xxHash_CONFIG_INSTALL_DIR}
  167     NAMESPACE ${PROJECT_NAME}::)
  168 endif(NOT XXHASH_BUNDLED_MODE)