From 77281dbca72ae70f8da859520830f958c2900527 Mon Sep 17 00:00:00 2001 From: Enrico Seiler Date: Thu, 9 Nov 2023 14:15:37 +0100 Subject: [PATCH] [INFRA] Use CPM --- .cmake-format.yaml | 70 +++++++++++++++++++ .github/workflows/ci_coverage.yml | 6 +- .github/workflows/ci_documentation.yml | 4 +- .github/workflows/ci_iwyu.yml | 2 +- .github/workflows/ci_linux.yml | 6 +- .github/workflows/ci_macos.yml | 6 +- .github/workflows/ci_misc.yml | 13 ++-- .github/workflows/ci_util.yml | 4 +- .gitmodules | 10 --- cmake/CPM.cmake | 22 ++++++ cmake/configuration.cmake | 44 ++++++------ cmake/cpack.cmake | 16 ++++- cmake/cpack_install.cmake.in | 7 ++ cmake/hibf-config.cmake.in | 23 ++++++ cmake/install.cmake | 37 +++++----- cmake/package-lock.cmake | 38 ++++++++++ cmake/simde.cmake | 32 +++++++++ src/CMakeLists.txt | 8 +-- submodules/.gitkeep | 0 submodules/cereal | 1 - submodules/simde | 1 - test/cmake/hibf_require_benchmark.cmake | 38 ---------- test/cmake/hibf_require_test.cmake | 36 ---------- test/header/CMakeLists.txt | 4 +- test/hibf-test.cmake | 28 +++++--- test/performance/CMakeLists.txt | 4 +- .../interleaved_bloom_filter_benchmark.cpp | 6 +- test/snippet/CMakeLists.txt | 2 +- test/unit/CMakeLists.txt | 2 +- 29 files changed, 303 insertions(+), 167 deletions(-) delete mode 100644 .gitmodules create mode 100644 cmake/CPM.cmake create mode 100644 cmake/cpack_install.cmake.in create mode 100644 cmake/hibf-config.cmake.in create mode 100644 cmake/package-lock.cmake create mode 100644 cmake/simde.cmake delete mode 100644 submodules/.gitkeep delete mode 160000 submodules/cereal delete mode 160000 submodules/simde delete mode 100644 test/cmake/hibf_require_benchmark.cmake delete mode 100644 test/cmake/hibf_require_test.cmake diff --git a/.cmake-format.yaml b/.cmake-format.yaml index 3ad587ed..0f35b7f5 100644 --- a/.cmake-format.yaml +++ b/.cmake-format.yaml @@ -46,6 +46,76 @@ parse: pargs: 1 kwargs: CYCLIC_DEPENDING_INCLUDES: '+' + cpmgetpackage: + pargs: 1 + spelling: CPMGetPackage + cpmaddpackage: + pargs: + nargs: '*' + flags: [] + spelling: CPMAddPackage + kwargs: &cpmaddpackagekwargs + NAME: 1 + FORCE: 1 + VERSION: 1 + GIT_TAG: 1 + DOWNLOAD_ONLY: 1 + GITHUB_REPOSITORY: 1 + GITLAB_REPOSITORY: 1 + GIT_REPOSITORY: 1 + SVN_REPOSITORY: 1 + SVN_REVISION: 1 + SOURCE_DIR: 1 + DOWNLOAD_COMMAND: 1 + FIND_PACKAGE_ARGUMENTS: 1 + NO_CACHE: 1 + GIT_SHALLOW: 1 + URL: 1 + URL_HASH: 1 + URL_MD5: 1 + DOWNLOAD_NAME: 1 + DOWNLOAD_NO_EXTRACT: 1 + HTTP_USERNAME: 1 + HTTP_PASSWORD: 1 + EXCLUDE_FROM_ALL: 1 + SYSTEM: 1 + SOURCE_SUBDIR: 1 + OPTIONS: + + cpmfindpackage: + pargs: + nargs: '*' + flags: [] + spelling: CPMFindPackage + kwargs: *cpmaddpackagekwargs + cpmdeclarepackage: + pargs: + nargs: '*' + flags: [] + spelling: CPMDeclarePackage + kwargs: *cpmaddpackagekwargs + packageproject: + pargs: + nargs: '*' + flags: [] + spelling: packageProject + kwargs: + NAME: 1 + VERSION: 1 + INCLUDE_DIR: 1 + INCLUDE_DESTINATION: 1 + BINARY_DIR: 1 + COMPATIBILITY: 1 + VERSION_HEADER: 1 + DEPENDENCIES: + + cpmusepackagelock: + pargs: 1 + spelling: CPMUsePackageLock + cpmregisterpackage: + pargs: 1 + spelling: CPMRegisterPackage + cpmgetpackageversion: + pargs: 2 + spelling: CPMGetPackageVersion _help_override_spec: - Override configurations per-command where available override_spec: {} diff --git a/.github/workflows/ci_coverage.yml b/.github/workflows/ci_coverage.yml index 7985f90a..3d3e9de8 100644 --- a/.github/workflows/ci_coverage.yml +++ b/.github/workflows/ci_coverage.yml @@ -49,7 +49,7 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: ${{ steps.fetch_depth.outputs.depth }} - submodules: true + submodules: false - name: Setup toolchain uses: seqan/actions/setup-toolchain@main @@ -60,7 +60,7 @@ jobs: - name: Install CMake uses: seqan/actions/setup-cmake@main with: - cmake: 3.16.9 + cmake: 3.18.6 - name: Install gcovr run: | @@ -74,7 +74,7 @@ jobs: cmake ../test/${{ matrix.build }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ -DHIBF_NATIVE_BUILD=OFF \ -DHIBF_VERBOSE_TESTS=OFF - make -j2 gtest_build + make -j2 gtest_main - name: Build tests env: diff --git a/.github/workflows/ci_documentation.yml b/.github/workflows/ci_documentation.yml index 569812a2..73b397da 100644 --- a/.github/workflows/ci_documentation.yml +++ b/.github/workflows/ci_documentation.yml @@ -35,12 +35,12 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 1 - submodules: true + submodules: false - name: Install CMake uses: seqan/actions/setup-cmake@main with: - cmake: 3.16.9 + cmake: 3.18.6 - name: Install Doxygen uses: seqan/actions/setup-doxygen@main diff --git a/.github/workflows/ci_iwyu.yml b/.github/workflows/ci_iwyu.yml index 38c8da6a..0cc086cf 100644 --- a/.github/workflows/ci_iwyu.yml +++ b/.github/workflows/ci_iwyu.yml @@ -31,7 +31,7 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 1 - submodules: true + submodules: false path: hibf token: ${{ secrets.SEQAN_ACTIONS_PAT }} diff --git a/.github/workflows/ci_linux.yml b/.github/workflows/ci_linux.yml index 1e4222fc..a9a8d40c 100644 --- a/.github/workflows/ci_linux.yml +++ b/.github/workflows/ci_linux.yml @@ -65,7 +65,7 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 1 - submodules: true + submodules: false - name: Setup toolchain uses: seqan/actions/setup-toolchain@main @@ -80,7 +80,7 @@ jobs: - name: Install CMake uses: seqan/actions/setup-cmake@main with: - cmake: 3.16.9 + cmake: 3.18.6 - name: Configure tests run: | @@ -90,7 +90,7 @@ jobs: -DHIBF_NATIVE_BUILD=OFF \ -DHIBF_VERBOSE_TESTS=OFF \ -DCMAKE_CXX_FLAGS="${{ matrix.cxx_flags }}" - make -j2 gtest_build + make -j2 gtest_main - name: Build tests run: | diff --git a/.github/workflows/ci_macos.yml b/.github/workflows/ci_macos.yml index cb20263a..8b7850a2 100644 --- a/.github/workflows/ci_macos.yml +++ b/.github/workflows/ci_macos.yml @@ -54,7 +54,7 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 1 - submodules: true + submodules: false - name: Setup toolchain uses: seqan/actions/setup-toolchain@main @@ -65,7 +65,7 @@ jobs: - name: Install CMake uses: seqan/actions/setup-cmake@main with: - cmake: 3.16.9 + cmake: 3.18.6 - name: Configure tests run: | @@ -74,7 +74,7 @@ jobs: cmake ../test/${{ matrix.build }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ -DHIBF_NATIVE_BUILD=OFF \ -DHIBF_VERBOSE_TESTS=OFF - make -j3 gtest_build + make -j3 gtest_main - name: Build tests run: | diff --git a/.github/workflows/ci_misc.yml b/.github/workflows/ci_misc.yml index aee78962..d4c7a522 100644 --- a/.github/workflows/ci_misc.yml +++ b/.github/workflows/ci_misc.yml @@ -69,7 +69,7 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 1 - submodules: true + submodules: false - name: Setup toolchain uses: seqan/actions/setup-toolchain@main @@ -80,7 +80,7 @@ jobs: - name: Install CMake uses: seqan/actions/setup-cmake@main with: - cmake: 3.16.9 + cmake: 3.18.6 - name: Configure tests run: | @@ -89,13 +89,12 @@ jobs: cmake ../test/${{ matrix.build }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ -DHIBF_NATIVE_BUILD=OFF \ -DHIBF_VERBOSE_TESTS=OFF \ - -DHIBF_BENCHMARK_MIN_TIME=0.01 \ -DHIBF_USE_INCLUDE_DEPENDENCIES="${{ matrix.use_include_dependencies }}" case "${{ matrix.build }}" in - unit) make -j2 gtest_build;; - snippet) make -j2 gtest_build;; - performance) make -j2 gbenchmark_build;; - header) make -j2 gtest_build gbenchmark_build;; + unit) make -j2 gtest_main;; + snippet) make -j2 gtest_main;; + performance) make -j2 benchmark_main;; + header) make -j2 gtest_main benchmark_main;; esac - name: Check cyclic includes diff --git a/.github/workflows/ci_util.yml b/.github/workflows/ci_util.yml index aa7cf8e2..5e033907 100644 --- a/.github/workflows/ci_util.yml +++ b/.github/workflows/ci_util.yml @@ -42,7 +42,7 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 1 - submodules: true + submodules: false - name: Setup toolchain uses: seqan/actions/setup-toolchain@main @@ -53,7 +53,7 @@ jobs: - name: Install CMake uses: seqan/actions/setup-cmake@main with: - cmake: 3.16.9 + cmake: 3.18.6 - name: Configure util run: | diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 1fea3de1..00000000 --- a/.gitmodules +++ /dev/null @@ -1,10 +0,0 @@ -# SPDX-FileCopyrightText: 2006-2023, Knut Reinert & Freie Universität Berlin -# SPDX-FileCopyrightText: 2016-2023, Knut Reinert & MPI für molekulare Genetik -# SPDX-License-Identifier: CC0-1.0 - -[submodule "submodules/cereal"] - path = submodules/cereal - url = https://github.com/USCiLab/cereal.git -[submodule "submodules/simde"] - path = submodules/simde - url = https://github.com/simd-everywhere/simde.git diff --git a/cmake/CPM.cmake b/cmake/CPM.cmake new file mode 100644 index 00000000..f3d79185 --- /dev/null +++ b/cmake/CPM.cmake @@ -0,0 +1,22 @@ +# SPDX-License-Identifier: MIT +# +# SPDX-FileCopyrightText: Copyright (c) 2019-2023 Lars Melchior and contributors + +set (CPM_DOWNLOAD_VERSION 0.38.6) +set (CPM_HASH_SUM "11c3fa5f1ba14f15d31c2fb63dbc8628ee133d81c8d764caad9a8db9e0bacb07") + +if (CPM_SOURCE_CACHE) + set (CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake") +elseif (DEFINED ENV{CPM_SOURCE_CACHE}) + set (CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake") +else () + set (CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake") +endif () + +# Expand relative path. This is important if the provided path contains a tilde (~) +get_filename_component (CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE) + +file (DOWNLOAD https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake + ${CPM_DOWNLOAD_LOCATION} EXPECTED_HASH SHA256=${CPM_HASH_SUM}) + +include (${CPM_DOWNLOAD_LOCATION}) diff --git a/cmake/configuration.cmake b/cmake/configuration.cmake index 0edb162e..8da9a5b2 100644 --- a/cmake/configuration.cmake +++ b/cmake/configuration.cmake @@ -14,11 +14,28 @@ message (STATUS "Finding HIBF (${HIBF_VERSION}) and checking requirements") # Includes # ---------------------------------------------------------------------------- +set (CPM_INDENT " CMake Package Manager CPM: ") +include (${CMAKE_CURRENT_LIST_DIR}/CPM.cmake) +CPMUsePackageLock (${CMAKE_CURRENT_LIST_DIR}/package-lock.cmake) + include (CheckIncludeFileCXX) include (CheckCXXSourceCompiles) include (CheckCXXSourceRuns) include (CheckCXXCompilerFlag) +# ---------------------------------------------------------------------------- +# Find or add dependencies +# ---------------------------------------------------------------------------- + +CPMGetPackage (cereal) + +if (cereal_ADDED) + set_target_properties (cereal PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES + $) +endif () + +include (${CMAKE_CURRENT_LIST_DIR}/simde.cmake) + # ---------------------------------------------------------------------------- # Pretty printing and error handling # ---------------------------------------------------------------------------- @@ -32,22 +49,6 @@ macro (hibf_config_error text) endmacro () -# ---------------------------------------------------------------------------- -# Add submodules -# ---------------------------------------------------------------------------- - -set (HIBF_SUBMODULES_DIR - "${HIBF_SOURCE_DIR}" - CACHE STRING "Directory containing submodules.") -file (GLOB submodules ${HIBF_SUBMODULES_DIR}/submodules/*/include ${HIBF_SUBMODULES_DIR}/submodules/simde - ${HIBF_SUBMODULES_DIR}/simde) -foreach (submodule ${submodules}) - if (IS_DIRECTORY ${submodule}) - hibf_config_print (" …adding submodule include: ${submodule}") - set (HIBF_DEPENDENCY_HEADER_PATHS ${submodule} ${HIBF_DEPENDENCY_HEADER_PATHS}) - endif () -endforeach () - # ---------------------------------------------------------------------------- # Options for CheckCXXSourceCompiles # ---------------------------------------------------------------------------- @@ -55,7 +56,7 @@ endforeach () # deactivate messages in check_* set (CMAKE_REQUIRED_QUIET 1) # use global variables in Check* calls -set (CMAKE_REQUIRED_INCLUDES ${CMAKE_INCLUDE_PATH} ${HIBF_HEADER_PATH} ${HIBF_DEPENDENCY_HEADER_PATHS}) +set (CMAKE_REQUIRED_INCLUDES ${CMAKE_INCLUDE_PATH} ${HIBF_HEADER_PATH}) set (CMAKE_REQUIRED_FLAGS ${CMAKE_CXX_FLAGS}) # ---------------------------------------------------------------------------- @@ -272,7 +273,7 @@ if (Threads_FOUND) if ("${CMAKE_THREAD_LIBS_INIT}" STREQUAL "") hibf_config_print ("Thread support: builtin") else () - set (HIBF_LIBRARIES ${HIBF_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) + list (APPEND HIBF_LIBRARIES "${CMAKE_THREAD_LIBS_INIT}") hibf_config_print ("Thread support: via ${CMAKE_THREAD_LIBS_INIT}") endif () else () @@ -302,7 +303,7 @@ unset (HIBF_ROBIN_HOOD_DIR) if ((${CMAKE_SYSTEM_NAME} STREQUAL "Linux") OR (${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD") OR (${CMAKE_SYSTEM_NAME} STREQUAL "GNU")) - set (HIBF_LIBRARIES ${HIBF_LIBRARIES} rt) + list (APPEND HIBF_LIBRARIES "rt") endif () # libexecinfo -- implicit @@ -311,7 +312,8 @@ mark_as_advanced (_HIBF_HAVE_EXECINFO) if (_HIBF_HAVE_EXECINFO) hibf_config_print ("Optional dependency: libexecinfo found") if ((${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") OR (${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD")) - set (HIBF_LIBRARIES ${HIBF_LIBRARIES} execinfo elf) + list (APPEND HIBF_LIBRARIES "execinfo") + list (APPEND HIBF_LIBRARIES "elf") endif () else () hibf_config_print ("Optional dependency: libexecinfo not found") @@ -331,7 +333,7 @@ try_compile (HIBF_PLATFORM_TEST # ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cxx CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${CMAKE_CXX_FLAGS} ${HIBF_CXX_FLAGS}" - "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_INCLUDE_PATH};${HIBF_HEADER_PATH};${HIBF_DEPENDENCY_HEADER_PATHS}" + "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_INCLUDE_PATH};${HIBF_HEADER_PATH}" COMPILE_DEFINITIONS ${HIBF_DEFINITIONS} LINK_LIBRARIES ${HIBF_LIBRARIES} OUTPUT_VARIABLE HIBF_PLATFORM_TEST_OUTPUT) diff --git a/cmake/cpack.cmake b/cmake/cpack.cmake index 568b439f..528474ad 100644 --- a/cmake/cpack.cmake +++ b/cmake/cpack.cmake @@ -17,6 +17,20 @@ set (CPACK_RESOURCE_FILE_README "${HIBF_SOURCE_DIR}/README.md") # Source Package set (CPACK_SOURCE_GENERATOR "TXZ") -set (CPACK_SOURCE_IGNORE_FILES "\\\\.git($|/)") +list (APPEND CPACK_SOURCE_IGNORE_FILES "/\.git($|/)") +list (APPEND CPACK_SOURCE_IGNORE_FILES "/\.github/") +list (APPEND CPACK_SOURCE_IGNORE_FILES "/\.vscode/") +list (APPEND CPACK_SOURCE_IGNORE_FILES "/build/") +list (APPEND CPACK_SOURCE_IGNORE_FILES "/submodules/") +list (APPEND CPACK_SOURCE_IGNORE_FILES "/cmake/CPM.cmake") + +# Already being called on source package +if (NOT CPM_DOWNLOAD_LOCATION) + set (CPM_DOWNLOAD_LOCATION "${HIBF_SOURCE_DIR}/cmake/CPM.cmake") +endif () + +configure_file ("${HIBF_SOURCE_DIR}/cmake/cpack_install.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cpack_install.cmake" + @ONLY) +set (CPACK_INSTALL_SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/cpack_install.cmake") include (CPack) diff --git a/cmake/cpack_install.cmake.in b/cmake/cpack_install.cmake.in new file mode 100644 index 00000000..5f5f92f2 --- /dev/null +++ b/cmake/cpack_install.cmake.in @@ -0,0 +1,7 @@ +# SPDX-FileCopyrightText: 2006-2023, Knut Reinert & Freie Universität Berlin +# SPDX-FileCopyrightText: 2016-2023, Knut Reinert & MPI für molekulare Genetik +# SPDX-License-Identifier: BSD-3-Clause + +if (CPACK_SOURCE_INSTALLED_DIRECTORIES) + configure_file ("@CPM_DOWNLOAD_LOCATION@" "${CMAKE_CURRENT_BINARY_DIR}/cmake/CPM.cmake" COPYONLY) +endif () diff --git a/cmake/hibf-config.cmake.in b/cmake/hibf-config.cmake.in new file mode 100644 index 00000000..2a5caab4 --- /dev/null +++ b/cmake/hibf-config.cmake.in @@ -0,0 +1,23 @@ +# SPDX-FileCopyrightText: 2006-2023, Knut Reinert & Freie Universität Berlin +# SPDX-FileCopyrightText: 2016-2023, Knut Reinert & MPI für molekulare Genetik +# SPDX-License-Identifier: BSD-3-Clause + +@PACKAGE_INIT@ + +include (CMakeFindDependencyMacro) +find_dependency (cereal @HIBF_CEREAL_VERSION@ REQUIRED) + +find_package (PkgConfig QUIET) +if (PKG_CONFIG_FOUND) + pkg_check_modules (simde QUIET simde>=@HIBF_SIMDE_VERSION@) +endif () + +if (simde_FOUND) + add_library (simde IMPORTED INTERFACE) + add_library (simde::simde ALIAS simde) + target_include_directories (simde INTERFACE ${simde_INCLUDEDIR}) +else () + find_dependency (simde @HIBF_SIMDE_VERSION@ REQUIRED) +endif () + +include ("${CMAKE_CURRENT_LIST_DIR}/hibf-targets.cmake") diff --git a/cmake/install.cmake b/cmake/install.cmake index cf83b143..b08d2def 100644 --- a/cmake/install.cmake +++ b/cmake/install.cmake @@ -2,38 +2,43 @@ # SPDX-FileCopyrightText: 2016-2023, Knut Reinert & MPI für molekulare Genetik # SPDX-License-Identifier: BSD-3-Clause -install (TARGETS hibf +set (HIBF_EXPORT_TARGETS "hibf") +if (TARGET cereal) + list (APPEND HIBF_EXPORT_TARGETS "cereal") +endif () +if (TARGET simde) + list (APPEND HIBF_EXPORT_TARGETS "simde") +endif () + +# cmake-format: off +install (TARGETS ${HIBF_EXPORT_TARGETS} EXPORT hibf_targets + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR}) +# cmake-format: on -install (DIRECTORY "${HIBF_HEADER_PATH}/hibf" TYPE INCLUDE) -# install submodule header files, e.g. all external dependencies in /home/user/hibf/submodules/*, -# in /include/hibf/submodules//include -foreach (submodule_dir ${HIBF_DEPENDENCY_HEADER_PATHS}) - # e.g. submodule_dir: (1) /home/user/hibf/submodules/sdsl-lite/include or (2) /usr/include - # strip /home/user/hibf/submodules/ and /include part. - file (RELATIVE_PATH submodule "${HIBF_SOURCE_DIR}/submodules" "${submodule_dir}/..") - # submodule is either a single module name, like sdsl-lite or a relative path to a folder ../../../usr - # skip relative folders and only keep submodules that reside in the submodules folder - if (NOT submodule MATCHES "^\\.\\.") # skip relative folders - install (DIRECTORY "${submodule_dir}" DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/hibf/submodules/${submodule}") - endif () -endforeach () +install (DIRECTORY "${HIBF_HEADER_PATH}/hibf" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) install (EXPORT hibf_targets NAMESPACE seqan:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/hibf - FILE hibf-config.cmake) + EXPORT_LINK_INTERFACE_LIBRARIES + FILE hibf-targets.cmake) include (CMakePackageConfigHelpers) +configure_package_config_file (cmake/hibf-config.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/hibf-config.cmake + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/hibf) +install (FILES ${CMAKE_CURRENT_BINARY_DIR}/hibf-config.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/hibf) + set (version_file "${CMAKE_CURRENT_BINARY_DIR}/cmake/hibf-config-version.cmake") write_basic_package_version_file ( ${version_file} VERSION ${HIBF_VERSION} - COMPATIBILITY AnyNewerVersion) + COMPATIBILITY SameMajorVersion) install (FILES ${version_file} DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/hibf) install (FILES "${HIBF_SOURCE_DIR}/LICENSE.md" "${HIBF_SOURCE_DIR}/README.md" TYPE DOC) +install (DIRECTORY "${HIBF_SOURCE_DIR}/LICENSES" TYPE DOC) diff --git a/cmake/package-lock.cmake b/cmake/package-lock.cmake new file mode 100644 index 00000000..e38df408 --- /dev/null +++ b/cmake/package-lock.cmake @@ -0,0 +1,38 @@ +# SPDX-FileCopyrightText: 2006-2023, Knut Reinert & Freie Universität Berlin +# SPDX-FileCopyrightText: 2016-2023, Knut Reinert & MPI für molekulare Genetik +# SPDX-License-Identifier: CC0-1.0 + +# CPM Package Lock +# This file should be committed to version control + +# cereal +set (HIBF_CEREAL_VERSION 1.3.2) +CPMDeclarePackage (cereal + NAME cereal + VERSION ${HIBF_CEREAL_VERSION} + GITHUB_REPOSITORY USCiLab/cereal + SYSTEM TRUE + OPTIONS "JUST_INSTALL_CEREAL ON") +# simde +set (HIBF_SIMDE_VERSION 0.7.6) +CPMDeclarePackage (simde + NAME simde + VERSION ${HIBF_SIMDE_VERSION} + DOWNLOAD_ONLY YES + GITHUB_REPOSITORY simd-everywhere/simde) +# benchmark +set (HIBF_BENCHMARK_VERSION 1.8.2) +CPMDeclarePackage (benchmark + NAME benchmark + VERSION ${HIBF_BENCHMARK_VERSION} + GITHUB_REPOSITORY google/benchmark + SYSTEM TRUE + OPTIONS "BENCHMARK_ENABLE_TESTING OFF" "BENCHMARK_ENABLE_WERROR OFF") +# googletest +set (HIBF_GOOGLETEST_VERSION 1.14.0) +CPMDeclarePackage (googletest + NAME GTest + VERSION ${HIBF_GOOGLETEST_VERSION} + GITHUB_REPOSITORY google/googletest + SYSTEM TRUE + OPTIONS "BUILD_GMOCK OFF" "INSTALL_GTEST OFF") diff --git a/cmake/simde.cmake b/cmake/simde.cmake new file mode 100644 index 00000000..eb2b7748 --- /dev/null +++ b/cmake/simde.cmake @@ -0,0 +1,32 @@ +# SPDX-FileCopyrightText: 2006-2023, Knut Reinert & Freie Universität Berlin +# SPDX-FileCopyrightText: 2016-2023, Knut Reinert & MPI für molekulare Genetik +# SPDX-License-Identifier: BSD-3-Clause + +# 1: Check via pkg-config. Debian package provides a pc file. +# 2: Via CPM + +macro (hibf_define_simde SIMDE_INCLUDE_DIRECTORY) + add_library (simde INTERFACE) + add_library (simde::simde ALIAS simde) + target_include_directories (simde INTERFACE "$") + set_target_properties (simde PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES + $) +endmacro () + +if (CPM_USE_LOCAL_PACKAGES) + find_package (PkgConfig QUIET) + if (PKG_CONFIG_FOUND) + pkg_check_modules (simde QUIET simde>=${HIBF_SIMDE_VERSION}) + endif () +endif () + +if (simde_FOUND) + hibf_define_simde ("${simde_INCLUDEDIR}") + cpm_message (STATUS "${CPM_INDENT} Using local package simde@${simde_VERSION}") +else () + CPMGetPackage (simde) + + if (simde_ADDED) + hibf_define_simde ("${simde_SOURCE_DIR}") + endif () +endif () diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fc8b739f..bce36ea3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -27,10 +27,8 @@ if (NOT TARGET hibf) target_compile_options (hibf PUBLIC ${HIBF_CXX_FLAGS}) target_link_options (hibf PUBLIC ${HIBF_CXX_FLAGS}) target_link_libraries (hibf PUBLIC "${HIBF_LIBRARIES}") + target_link_libraries (hibf PUBLIC cereal::cereal simde::simde) - target_include_directories ( - hibf PUBLIC "$" "$" - "$") - - target_include_directories (hibf SYSTEM PUBLIC "$") + target_include_directories (hibf PUBLIC "$" + "$") endif () diff --git a/submodules/.gitkeep b/submodules/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/submodules/cereal b/submodules/cereal deleted file mode 160000 index ddd46724..00000000 --- a/submodules/cereal +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ddd467244713ea4fe63733628992efcdd6a9187d diff --git a/submodules/simde b/submodules/simde deleted file mode 160000 index f0f3d095..00000000 --- a/submodules/simde +++ /dev/null @@ -1 +0,0 @@ -Subproject commit f0f3d09547fefaca1134923ce0c0af1ca4a176b3 diff --git a/test/cmake/hibf_require_benchmark.cmake b/test/cmake/hibf_require_benchmark.cmake deleted file mode 100644 index c7f40143..00000000 --- a/test/cmake/hibf_require_benchmark.cmake +++ /dev/null @@ -1,38 +0,0 @@ -# SPDX-FileCopyrightText: 2006-2023, Knut Reinert & Freie Universität Berlin -# SPDX-FileCopyrightText: 2016-2023, Knut Reinert & MPI für molekulare Genetik -# SPDX-License-Identifier: BSD-3-Clause - -cmake_minimum_required (VERSION 3.16) - -# Exposes the google-benchmark target `benchmark` and `benchmark_main`. -# CMake 3.24: https://cmake.org/cmake/help/latest/module/FetchContent.html#variable:FETCHCONTENT_TRY_FIND_PACKAGE_MODE -macro (hibf_require_benchmark) - enable_testing () - - set (HIBF_BENCHMARK_TAG "v1.8.2") - - find_package (benchmark QUIET) - - # Also ensure that Google Benchmark if fetched for the latest library cron, which sets the tag to "main". - if (NOT benchmark_FOUND OR "${HIBF_BENCHMARK_TAG}" STREQUAL "main") - message (STATUS "Fetching Google Benchmark ${HIBF_BENCHMARK_TAG}") - - include (FetchContent) - FetchContent_Declare ( - gbenchmark_fetch_content - GIT_REPOSITORY "https://github.com/google/benchmark.git" - GIT_TAG "${HIBF_BENCHMARK_TAG}") - option (BENCHMARK_ENABLE_TESTING "" OFF) - option (BENCHMARK_ENABLE_WERROR "" OFF) # Does not apply to Debug builds. - option (BENCHMARK_ENABLE_INSTALL "" OFF) - FetchContent_MakeAvailable (gbenchmark_fetch_content) - else () - message (STATUS " Test dependency: Google Benchmark ${benchmark_VERSION} found.") - endif () - - # NOTE: google benchmark's CMakeLists.txt already defines Shlwapi - if (NOT TARGET gbenchmark_build) - add_custom_target (gbenchmark_build DEPENDS benchmark_main benchmark) - endif () - -endmacro () diff --git a/test/cmake/hibf_require_test.cmake b/test/cmake/hibf_require_test.cmake deleted file mode 100644 index efe0c1af..00000000 --- a/test/cmake/hibf_require_test.cmake +++ /dev/null @@ -1,36 +0,0 @@ -# SPDX-FileCopyrightText: 2006-2023, Knut Reinert & Freie Universität Berlin -# SPDX-FileCopyrightText: 2016-2023, Knut Reinert & MPI für molekulare Genetik -# SPDX-License-Identifier: BSD-3-Clause - -cmake_minimum_required (VERSION 3.16) - -# Exposes the google-test targets `gtest` and `gtest_main`. -# CMake 3.24: https://cmake.org/cmake/help/latest/module/FetchContent.html#variable:FETCHCONTENT_TRY_FIND_PACKAGE_MODE -macro (hibf_require_test) - enable_testing () - - set (HIBF_GTEST_TAG "v1.13.0") - - find_package (GTest QUIET) - - # Also ensure that Google Test if fetched for the latest library cron, which sets the tag to "main". - if (NOT GTest_FOUND OR "${HIBF_GTEST_TAG}" STREQUAL "main") - message (STATUS "Fetching Google Test ${HIBF_GTEST_TAG}") - - include (FetchContent) - FetchContent_Declare ( - gtest_fetch_content - GIT_REPOSITORY "https://github.com/google/googletest.git" - GIT_TAG "${HIBF_GTEST_TAG}") - option (BUILD_GMOCK "" OFF) - option (INSTALL_GTEST "" OFF) - FetchContent_MakeAvailable (gtest_fetch_content) - else () - message (STATUS " Test dependency: Google Test ${GTest_VERSION} found.") - endif () - - if (NOT TARGET gtest_build) - add_custom_target (gtest_build DEPENDS gtest_main gtest) - endif () - -endmacro () diff --git a/test/header/CMakeLists.txt b/test/header/CMakeLists.txt index d2575f1d..8275cc26 100644 --- a/test/header/CMakeLists.txt +++ b/test/header/CMakeLists.txt @@ -121,8 +121,8 @@ macro (hibf_header_test component header_base_path exclude_regex) unset (header_target) endmacro () -hibf_require_benchmark () -hibf_require_test () +CPMGetPackage (benchmark) +CPMGetPackage (googletest) # note: hibf/version.hpp is one of the only header that is not required to have a hibf/core/platform.hpp include hibf_header_test (hibf "${HIBF_SOURCE_DIR}/include" "hibf/version.hpp|hibf/contrib|hibf/") diff --git a/test/hibf-test.cmake b/test/hibf-test.cmake index fb69776a..537fa351 100644 --- a/test/hibf-test.cmake +++ b/test/hibf-test.cmake @@ -13,6 +13,13 @@ cmake_minimum_required (VERSION 3.10) # have to be adapted or the option deactivated. option (HIBF_BENCHMARK_ALIGN_LOOPS "Pass -falign-loops=32 to the benchmark builds." ON) +get_filename_component (HIBF_ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE) +add_subdirectory ("${HIBF_ROOT_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/hibf_lib") +target_compile_options (hibf PUBLIC "-pedantic" "-Wall" "-Wextra" "-Werror") + +set (CPM_INDENT " CMake Package Manager CPM: ") +CPMUsePackageLock ("${HIBF_ROOT_DIR}/cmake/package-lock.cmake") + # ---------------------------------------------------------------------------- # Paths to folders. # ---------------------------------------------------------------------------- @@ -29,6 +36,8 @@ list (APPEND CMAKE_MODULE_PATH "${HIBF_TEST_CMAKE_MODULE_DIR}") # Interface targets for the different test modules in hibf. # ---------------------------------------------------------------------------- +enable_testing () + # hibf::test exposes a base set of required flags, includes, definitions and # libraries which are in common for **all** hibf tests if (NOT TARGET hibf::test) @@ -50,7 +59,7 @@ endif () # needed for performance test cases in hibf/test/performance if (NOT TARGET hibf::test::performance) add_library (hibf_test_performance INTERFACE) - target_link_libraries (hibf_test_performance INTERFACE "hibf::test" "benchmark_main" "benchmark") + target_link_libraries (hibf_test_performance INTERFACE "hibf::test" "benchmark::benchmark_main") if (HIBF_BENCHMARK_ALIGN_LOOPS) target_compile_options (hibf_test_performance INTERFACE "-falign-loops=32") @@ -63,7 +72,16 @@ endif () # needed for unit test cases in hibf/test/unit if (NOT TARGET hibf::test::unit) add_library (hibf_test_unit INTERFACE) - target_link_libraries (hibf_test_unit INTERFACE "hibf::test" "gtest_main" "gtest") + + # GCC12 has some bogus warnings. They will not be fixed in googletest. + # https://github.com/google/googletest/issues/4232 + if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 12 AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13) + target_compile_options (hibf_test INTERFACE "-Wno-restrict") + endif () + endif () + + target_link_libraries (hibf_test_unit INTERFACE "hibf::test" "GTest::gtest_main") add_library (hibf::test::unit ALIAS hibf_test_unit) endif () @@ -84,10 +102,4 @@ endif () include (hibf_test_component) include (hibf_test_files) -include (hibf_require_benchmark) -include (hibf_require_test) include (hibf_add_subdirectories) - -get_filename_component (HIBF_ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE) -add_subdirectory ("${HIBF_ROOT_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/hibf_lib") -target_compile_options (hibf PUBLIC "-pedantic" "-Wall" "-Wextra" "-Werror") diff --git a/test/performance/CMakeLists.txt b/test/performance/CMakeLists.txt index 6e248c5a..62b57185 100644 --- a/test/performance/CMakeLists.txt +++ b/test/performance/CMakeLists.txt @@ -8,7 +8,7 @@ project (hibf_test_performance CXX) include (../hibf-test.cmake) set (HIBF_BENCHMARK_MIN_TIME - "1" + "0.01s" CACHE STRING "Set --benchmark_min_time= for each bechmark. Timings are unreliable in CI.") macro (hibf_benchmark benchmark_cpp) @@ -25,6 +25,6 @@ macro (hibf_benchmark benchmark_cpp) unset (test_name) endmacro () -hibf_require_benchmark () +CPMGetPackage (benchmark) add_subdirectories () diff --git a/test/performance/ibf/interleaved_bloom_filter_benchmark.cpp b/test/performance/ibf/interleaved_bloom_filter_benchmark.cpp index 60c38826..659a2072 100644 --- a/test/performance/ibf/interleaved_bloom_filter_benchmark.cpp +++ b/test/performance/ibf/interleaved_bloom_filter_benchmark.cpp @@ -30,9 +30,9 @@ static void arguments(benchmark::internal::Benchmark * b) // Total size: 1MiB // bins, bin_size, hash_num, sequence_length b->Args({64, 1LL << 17, 2, 1LL << 17}); - b->Args({128, 1LL << 16, 2, 1LL << 17}); - b->Args({192, 1LL << 16, 2, 1LL << 17}); - b->Args({256, 1LL << 15, 2, 1LL << 17}); + // b->Args({128, 1LL << 16, 2, 1LL << 17}); + // b->Args({192, 1LL << 16, 2, 1LL << 17}); + // b->Args({256, 1LL << 15, 2, 1LL << 17}); // b->Args({320, 1LL << 15, 2, 1LL << 17}); // b->Args({384, 1LL << 14, 2, 1LL << 17}); // b->Args({448, 1LL << 14, 2, 1LL << 17}); diff --git a/test/snippet/CMakeLists.txt b/test/snippet/CMakeLists.txt index 55b9ee32..26808616 100644 --- a/test/snippet/CMakeLists.txt +++ b/test/snippet/CMakeLists.txt @@ -49,7 +49,7 @@ macro (hibf_snippets test_name_prefix snippet_base_path) endforeach () endmacro () -hibf_require_test () +CPMGetPackage (googletest) hibf_snippets ("snippet" "${CMAKE_CURRENT_SOURCE_DIR}") hibf_snippets ("doc/snippet" "${CMAKE_CURRENT_SOURCE_DIR}/../../doc") diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index 5e30e0e0..7572d6fd 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -43,7 +43,7 @@ macro (hibf_test unit_test_cpp) unset (test_name) endmacro () -hibf_require_test () +CPMGetPackage (googletest) add_subdirectories ()