-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
164 lines (140 loc) · 4.82 KB
/
CMakeLists.txt
File metadata and controls
164 lines (140 loc) · 4.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
cmake_minimum_required(VERSION 3.14)
project(InterSubMod CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# --- Compiler Options ---
add_compile_options(-Wall -Wextra -pedantic)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_options(-g -O0)
add_definitions(-DDEBUG)
else()
add_compile_options(-O3 -march=native)
add_definitions(-DNDEBUG)
endif()
# --- Output Directory ---
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
# --- Jemalloc Integration ---
include(ExternalProject)
set(JEMALLOC_PREFIX ${CMAKE_BINARY_DIR}/external/jemalloc)
set(JEMALLOC_LIB_DIR ${JEMALLOC_PREFIX}/lib)
set(JEMALLOC_INCLUDE_DIR ${JEMALLOC_PREFIX}/include)
# Create directories to satisfy CMake checks
file(MAKE_DIRECTORY ${JEMALLOC_INCLUDE_DIR})
file(MAKE_DIRECTORY ${JEMALLOC_LIB_DIR})
# Download and build jemalloc statically
ExternalProject_Add(jemalloc_external
URL https://github.com/jemalloc/jemalloc/releases/download/5.3.0/jemalloc-5.3.0.tar.bz2
PREFIX ${JEMALLOC_PREFIX}
# Configure: disable shared, enable static, no prefix (replace system malloc)
CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=<INSTALL_DIR> --disable-shared --enable-static --with-jemalloc-prefix=
BUILD_COMMAND make
INSTALL_COMMAND make install
)
# Define imported library for jemalloc
add_library(jemalloc STATIC IMPORTED)
set_target_properties(jemalloc PROPERTIES
IMPORTED_LOCATION ${JEMALLOC_LIB_DIR}/libjemalloc.a
INTERFACE_INCLUDE_DIRECTORIES ${JEMALLOC_INCLUDE_DIR}
)
add_dependencies(jemalloc jemalloc_external)
# Enable jemalloc usage in code
add_definitions(-DUSE_JEMALLOC)
# --- Dependencies ---
# OpenMP
find_package(OpenMP REQUIRED)
# HTSlib
find_package(PkgConfig REQUIRED)
pkg_check_modules(HTSlib REQUIRED htslib)
# Eigen3
include(FetchContent)
FetchContent_Declare(
eigen3
URL https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.gz
)
# Disable Eigen3 tests and docs to avoid Fortran compiler requirement
set(BUILD_TESTING OFF CACHE BOOL "" FORCE)
set(EIGEN_BUILD_DOC OFF CACHE BOOL "" FORCE)
set(EIGEN_BUILD_PKGCONFIG OFF CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(eigen3)
# Re-enable testing for our project
set(BUILD_TESTING ON CACHE BOOL "" FORCE)
include_directories(${eigen3_SOURCE_DIR})
# --- Includes ---
include_directories(include)
include_directories(${EIGEN3_INCLUDE_DIRS})
# jemalloc include dir will be added via target usage, but global include helps too
include_directories(${JEMALLOC_INCLUDE_DIR})
# --- Library ---
add_library(inter_sub_mod_core
src/core/Config.cpp
src/core/SomaticSnv.cpp
src/core/BamReader.cpp
src/core/ReadParser.cpp
src/core/MethylationParser.cpp
src/core/MatrixBuilder.cpp
src/core/RegionProcessor.cpp
src/core/DistanceMatrix.cpp
src/core/TreeStructure.cpp
src/core/HierarchicalClustering.cpp
src/core/MathUtils.cpp
src/core/FisherExact.cpp
src/core/GlobalTest.cpp
src/core/LocalTest.cpp
src/core/StructureTest.cpp
src/core/Bootstrap.cpp
src/core/SignificanceAnalyzer.cpp
src/core/LabelTest.cpp
src/utils/Logger.cpp
src/utils/FastaReader.cpp
src/io/RegionWriter.cpp
src/io/TreeWriter.cpp
)
target_link_libraries(inter_sub_mod_core PUBLIC
OpenMP::OpenMP_CXX
${HTSlib_LIBRARIES}
jemalloc
dl
pthread
)
target_include_directories(inter_sub_mod_core PUBLIC
${HTSlib_INCLUDE_DIRS}
${JEMALLOC_INCLUDE_DIR}
)
# --- Main Executable ---
add_executable(inter_sub_mod src/main.cpp)
target_link_libraries(inter_sub_mod PRIVATE inter_sub_mod_core)
# --- Dev Tools / Ad-hoc Tests ---
add_executable(test_phase1_2 src/test/test_phase1_2.cpp)
target_link_libraries(test_phase1_2 PRIVATE inter_sub_mod_core)
add_executable(test_phase3 src/test/test_phase3.cpp)
target_link_libraries(test_phase3 PRIVATE inter_sub_mod_core)
add_executable(test_phase4_5 src/test/test_phase4_5.cpp)
target_link_libraries(test_phase4_5 PRIVATE inter_sub_mod_core)
# --- Tests ---
enable_testing()
# Fetch GoogleTest
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/refs/tags/v1.14.0.zip
)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
# Run tests with custom main to track resources
add_executable(run_tests
tests/main_test.cpp
tests/test_config.cpp
tests/test_bam_reader.cpp
tests/test_distance_matrix.cpp
tests/test_hierarchical_clustering.cpp
tests/test_significance_stats.cpp
tests/test_global_local.cpp
tests/test_structure_bootstrap.cpp
tests/test_significance_analyzer.cpp
)
target_link_libraries(run_tests PRIVATE inter_sub_mod_core GTest::gtest)
include(GoogleTest)
gtest_discover_tests(run_tests)