Debian Codegraph @

src/H5Z-SPERR/CMakeLists.txt

raw
1 cmake_minimum_required(VERSION 3.14)
2
3 project(H5Z-SPERR VERSION 0.2.3 LANGUAGES C CXX DESCRIPTION "HDF5 plugin for SPERR compression")
4
5 set(CMAKE_C_STANDARD 11)
6 set(CMAKE_CXX_STANDARD 14)
7 if(NOT CMAKE_BUILD_TYPE)
8 set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE)
9 set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "RelWithDebInfo")
10 endif()
11
12 option( BUILD_SHARED_LIBS "Build shared libraries" ON )
13 option( BUILD_CLI_UTILITIES "Build a set of command line utilities" ON )
14 option( BUILD_UNIT_TESTS "Build unit tests using GoogleTest" OFF )
15 option( H5ZPLUGIN_PREFER_RPATH "Set RPATH; this can fight with package managers
16 so turn off when building for them" ON )
17 mark_as_advanced(FORCE H5ZPLUGIN_PREFER_RPATH)
18
19 find_package(HDF5 REQUIRED COMPONENTS C)
20 message(STATUS "Found HDF5 Version: ${HDF5_VERSION}: ${HDF5_C_LIBRARIES}")
21
22 if(H5ZPLUGIN_PREFER_RPATH)
23 set( CMAKE_SKIP_BUILD_RPATH FALSE )
24 set( CMAKE_BUILD_WITH_INSTALL_RPATH FALSE )
25 set( CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" )
26 set( CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE )
27 endif()
28
29 set (SPERR_INSTALL_DIR "SPERR INSTALL DIRECTORY"
30 CACHE STRING "where subdirectories such as lib and include are found")
31 list(APPEND CMAKE_PREFIX_PATH ${SPERR_INSTALL_DIR})
32 find_package(PkgConfig REQUIRED)
33 pkg_search_module(SPERR REQUIRED IMPORTED_TARGET GLOBAL SPERR)
34 if (SPERR_FOUND)
35 message(STATUS "Found SPERR version ${SPERR_VERSION}: ${SPERR_LINK_LIBRARIES}")
36 endif()
37
38 add_subdirectory( src )
39
40 #
41 # Build command line utilities
42 #
43 if( BUILD_CLI_UTILITIES )
44 add_subdirectory( utilities ${CMAKE_BINARY_DIR}/bin )
45 endif()
46
47 #
48 # Build unit tests
49 #
50 if( BUILD_UNIT_TESTS )
51 # Control internal options of GoogleTest
52 #
53 set( INSTALL_GTEST OFF CACHE INTERNAL "Not install GoogleTest")
54 set( BUILD_GMOCK ON CACHE INTERNAL "Build gmock")
55
56 # Let's use the new mechanism to incorporate GoogleTest
57 #
58 include(FetchContent)
59 if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.24")
60 FetchContent_Declare( googletest
61 URL https://github.com/google/googletest/archive/refs/heads/main.zip
62 DOWNLOAD_EXTRACT_TIMESTAMP NEW )
63 endif()
64
65 # Prevent overriding the parent project's compiler/linker settings on Windows
66 #
67 set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
68 FetchContent_MakeAvailable(googletest)
69
70 enable_testing() # calling this function before adding subdirectory to enable
71 # invoking ctest from the top-level build directory.
72 add_subdirectory( test_scripts )
73 endif()
74
75 #
76 # Start installation using GNU installation rules
77 #
78 include( GNUInstallDirs )
79 install( TARGETS h5z-sperr h5z-clamp LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} )
80
81 if( BUILD_CLI_UTILITIES )
82 install( TARGETS generate_cd_values decode_cd_values
83 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} )
84 endif()