Skip to content
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

Add support for PCH #85

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ jobs:
-DHICTK_ENABLE_TESTING=ON \
-DHICTK_DOWNLOAD_TEST_DATASET=OFF \
-DHICTK_ENABLE_GIT_VERSION_TRACKING=OFF \
-DHICTK_USE_PCH=ON \
-S . \
-B build

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/macos-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ jobs:
-DOPT_ENABLE_CPPCHECK=OFF \
-DHICTK_DOWNLOAD_TEST_DATASET=OFF \
-DHICTK_ENABLE_GIT_VERSION_TRACKING=OFF \
-DHICTK_USE_PCH=ON \
-DCMAKE_INSTALL_PREFIX=dest \
-S "${{ github.workspace }}" \
-B "${{ github.workspace }}/build"
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/run-clang-tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ jobs:
-DHICTK_ENABLE_TESTING=ON \
-DHICTK_DOWNLOAD_TEST_DATASET=OFF \
-DHICTK_ENABLE_GIT_VERSION_TRACKING=OFF \
-DHICTK_USE_PCH=ON \
-S . \
-B build

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ubuntu-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ jobs:
-DHICTK_DOWNLOAD_TEST_DATASET=OFF \
-DHICTK_ENABLE_GIT_VERSION_TRACKING=OFF \
-DCMAKE_INSTALL_PREFIX=dest \
-DHICTK_USE_PCH=ON \
-S . \
-B build

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/windows-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ jobs:
-DHICTK_ENABLE_GIT_VERSION_TRACKING=OFF \
-DOPT_ENABLE_CLANG_TIDY=OFF \
-DOPT_ENABLE_CPPCHECK=OFF \
-DHICTK_USE_PCH=OFF \
-S . \
-B build

Expand Down
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ target_compile_features(hictk_project_options INTERFACE "cxx_std_${CMAKE_CXX_STA

# Tweak fmt
target_compile_definitions(hictk_project_options INTERFACE FMT_HEADER_ONLY FMT_ENFORCE_COMPILE_STRING)
# Tweak spanlite
target_compile_definitions(hictk_project_options INTERFACE span_FEATURE_MAKE_SPAN=1)
# Tweak spdlog
target_compile_definitions(hictk_project_options INTERFACE SPDLOG_FMT_EXTERNAL)
#Tweak xxHash
Expand All @@ -136,6 +138,7 @@ option(HICTK_BUILD_EXAMPLES "Build examples" OFF)
option(HICTK_BUILD_BENCHMARKS "Build benchmarks" OFF)
option(HICTK_WITH_EIGEN "Build with Eigen3 support" ON)
option(HICTK_BUILD_TOOLS "Build cli tools" ON)
option(HICTK_USE_PCH "Build hictk using PCH" OFF)

if(HICTK_WITH_EIGEN)
target_compile_definitions(hictk_project_options INTERFACE HICTK_WITH_EIGEN)
Expand Down
5 changes: 5 additions & 0 deletions src/hictk/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ target_sources(
${CMAKE_CURRENT_SOURCE_DIR}/zoomify/zoomify.cpp)

target_include_directories(hictk PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include")

if(HICTK_USE_PCH)
target_precompile_headers(hictk PRIVATE [["hictk/tools/internal/pch.hpp"]])
endif()

target_link_libraries(hictk PRIVATE hictk_project_options hictk_project_warnings hictk::libhictk)

target_link_system_libraries(
Expand Down
39 changes: 39 additions & 0 deletions src/hictk/include/hictk/tools/internal/pch.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright (C) 2023 Roberto Rossini <roberros@uio.no>
//
// SPDX-License-Identifier: MIT

#pragma once

#include <fmt/format.h>

#include <algorithm>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <exception>
#include <filesystem>
#include <functional>
#include <highfive/H5File.hpp>
#include <iterator>
#include <limits>
#include <memory>
#include <stdexcept>
#include <string>
#include <string_view>
#include <type_traits>
#include <utility>
#include <variant>
#include <vector>

#include "hictk/balancing/methods.hpp"
#include "hictk/bin_table.hpp"
#include "hictk/chromosome.hpp"
#include "hictk/common.hpp"
#include "hictk/cooler/cooler.hpp"
#include "hictk/cooler/dataset.hpp"
#include "hictk/cooler/group.hpp"
#include "hictk/hic/common.hpp"
#include "hictk/pixel.hpp"
#include "hictk/reference.hpp"
#include "hictk/suppress_warnings.hpp"
#include "hictk/type_traits.hpp"
2 changes: 0 additions & 2 deletions src/libhictk/balancing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,3 @@ target_link_system_libraries(
phmap
xxHash::xxhash
"zstd::libzstd_$<IF:$<BOOL:${BUILD_SHARED_LIBS}>,shared,static>")

target_compile_definitions(balancing INTERFACE span_FEATURE_MAKE_SPAN=1)
2 changes: 2 additions & 0 deletions test/units/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

include_directories(include)

add_subdirectory(pch)

add_subdirectory(balancing)
add_subdirectory(bin_table)
add_subdirectory(chromosome)
Expand Down
4 changes: 4 additions & 0 deletions test/units/balancing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ add_executable(hictk_balancing_tests)

target_sources(hictk_balancing_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/balancing_test.cpp)

if(HICTK_USE_PCH)
target_precompile_headers(hictk_balancing_tests REUSE_FROM hictk_test_pch)
endif()

target_link_libraries(
hictk_balancing_tests
PRIVATE hictk_project_warnings hictk_project_options
Expand Down
18 changes: 11 additions & 7 deletions test/units/bin_table/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,21 @@ find_package(Filesystem REQUIRED)
include(CTest)
include(Catch)

add_executable(bin_table_tests)
add_executable(hictk_bin_table_tests)

target_sources(bin_table_tests PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/bin_table_test.cpp")
target_sources(hictk_bin_table_tests PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/bin_table_test.cpp")

if(HICTK_USE_PCH)
target_precompile_headers(hictk_bin_table_tests REUSE_FROM hictk_test_pch)
endif()

target_link_libraries(
bin_table_tests
hictk_bin_table_tests
PRIVATE hictk_project_warnings hictk_project_options
PUBLIC hictk::bin_table hictk::format)

target_link_system_libraries(
bin_table_tests
hictk_bin_table_tests
PUBLIC
Catch2::Catch2WithMain
std::filesystem)
Expand All @@ -27,7 +31,7 @@ file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/Testing/")
# automatically discover tests that are defined in catch based test files you can modify the unittests. TEST_PREFIX to
# whatever you want, or use different for different binaries
catch_discover_tests(
bin_table_tests
hictk_bin_table_tests
TEST_SPEC
"[short]"
TEST_SUFFIX
Expand All @@ -41,7 +45,7 @@ catch_discover_tests(
--skip-benchmarks)

catch_discover_tests(
bin_table_tests
hictk_bin_table_tests
TEST_SPEC
"[medium]"
TEST_SUFFIX
Expand All @@ -53,7 +57,7 @@ catch_discover_tests(
--skip-benchmarks)

catch_discover_tests(
bin_table_tests
hictk_bin_table_tests
TEST_SPEC
"[long]"
TEST_SUFFIX
Expand Down
4 changes: 4 additions & 0 deletions test/units/cooler/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ target_sources(
"${CMAKE_CURRENT_SOURCE_DIR}/utils_merge_test.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/utils_validation_test.cpp")

if(HICTK_USE_PCH)
target_precompile_headers(hictk_cooler_tests REUSE_FROM hictk_test_pch)
endif()

target_link_libraries(
hictk_cooler_tests
PRIVATE hictk_project_warnings hictk_project_options
Expand Down
4 changes: 4 additions & 0 deletions test/units/file/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ add_executable(hictk_file_tests)

target_sources(hictk_file_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/file_test.cpp)

if(HICTK_USE_PCH)
target_precompile_headers(hictk_file_tests REUSE_FROM hictk_test_pch)
endif()

target_link_libraries(
hictk_file_tests
PRIVATE hictk_project_warnings hictk_project_options
Expand Down
4 changes: 4 additions & 0 deletions test/units/hic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ target_sources(
"${CMAKE_CURRENT_SOURCE_DIR}/hic_file_test.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/pixel_selector_test.cpp")

if(HICTK_USE_PCH)
target_precompile_headers(hictk_hic_tests REUSE_FROM hictk_test_pch)
endif()

target_link_libraries(
hictk_hic_tests
PRIVATE hictk_project_warnings hictk_project_options
Expand Down
17 changes: 17 additions & 0 deletions test/units/pch/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright (C) 2022 Roberto Rossini <roberros@uio.no>
#
# SPDX-License-Identifier: MIT

find_package(fmt REQUIRED)

if(HICTK_USE_PCH)
add_library(hictk_test_pch)
target_sources(hictk_test_pch PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/lib.cpp")
target_precompile_headers(hictk_test_pch PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/pch.hpp")
target_link_libraries(
hictk_test_pch
PRIVATE hictk_project_options hictk_project_warnings
PUBLIC hictk::libhictk
Catch2::Catch2WithMain
fmt::fmt-header-only)
endif()
3 changes: 3 additions & 0 deletions test/units/pch/lib.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Copyright (C) 2023 Roberto Rossini <roberros@uio.no>
//
// SPDX-License-Identifier: MIT
42 changes: 42 additions & 0 deletions test/units/pch/pch.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright (C) 2023 Roberto Rossini <roberros@uio.no>
//
// SPDX-License-Identifier: MIT

#pragma once

#include <fmt/format.h>

#include <algorithm>
#include <cassert>
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers_floating_point.hpp>
#include <catch2/matchers/catch_matchers_string.hpp>
#include <cstddef>
#include <cstdint>
#include <exception>
#include <filesystem>
#include <functional>
// #include <highfive/H5File.hpp>
#include <iterator>
#include <limits>
#include <memory>
#include <stdexcept>
#include <string>
#include <string_view>
#include <type_traits>
#include <utility>
#include <variant>
#include <vector>

#include "hictk/balancing/methods.hpp"
#include "hictk/bin_table.hpp"
#include "hictk/chromosome.hpp"
#include "hictk/common.hpp"
#include "hictk/cooler/cooler.hpp"
#include "hictk/cooler/dataset.hpp"
#include "hictk/cooler/group.hpp"
#include "hictk/hic/common.hpp"
#include "hictk/pixel.hpp"
#include "hictk/reference.hpp"
#include "hictk/suppress_warnings.hpp"
#include "hictk/type_traits.hpp"
4 changes: 4 additions & 0 deletions test/units/pixel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ add_executable(hictk_pixel_tests)

target_sources(hictk_pixel_tests PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/pixel_test.cpp")

if(HICTK_USE_PCH)
target_precompile_headers(hictk_pixel_tests REUSE_FROM hictk_test_pch)
endif()

target_link_libraries(
hictk_pixel_tests
PRIVATE hictk_project_warnings hictk_project_options
Expand Down
4 changes: 4 additions & 0 deletions test/units/reference/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ add_executable(hictk_reference_tests)

target_sources(hictk_reference_tests PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/reference_test.cpp")

if(HICTK_USE_PCH)
target_precompile_headers(hictk_reference_tests REUSE_FROM hictk_test_pch)
endif()

target_link_libraries(
hictk_reference_tests
PRIVATE hictk_project_warnings hictk_project_options
Expand Down
4 changes: 4 additions & 0 deletions test/units/transformers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ add_executable(hictk_transformers_tests)

target_sources(hictk_transformers_tests PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/transformers_test.cpp")

if(HICTK_USE_PCH)
target_precompile_headers(hictk_transformers_tests REUSE_FROM hictk_test_pch)
endif()

target_link_libraries(
hictk_transformers_tests
PRIVATE hictk_project_warnings hictk_project_options
Expand Down
4 changes: 4 additions & 0 deletions test/units/variant/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ add_executable(hictk_variant_tests)

target_sources(hictk_variant_tests PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/variant_test.cpp")

if(HICTK_USE_PCH)
target_precompile_headers(hictk_variant_tests REUSE_FROM hictk_test_pch)
endif()

target_link_libraries(
hictk_variant_tests
PRIVATE hictk_project_warnings hictk_project_options
Expand Down
Loading