-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
105 lines (87 loc) · 3.16 KB
/
CMakeLists.txt
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
cmake_minimum_required(VERSION 3.5)
project(GENIE LANGUAGES CXX)
include_directories(include/)
# Set the CMake standard
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Set a default build type to Release (-O3 -DNDEBUG for GCC)
if (NOT CMAKE_BUILD_TYPE)
message(STATUS "Setting build type to 'Release' as none was specified.")
message(STATUS " You can specify with the flag -DCMAKE_BUILD_TYPE=<Debug|Release|MinSizeRel|RelWithDebInfo>")
message(STATUS " 'Release' will build optimised binaries, but 'Debug' may be better while developing.")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
endif ()
message(STATUS "CMake build type is set to ${CMAKE_BUILD_TYPE}")
# Find required dependencies
find_package(Threads REQUIRED)
# Determine system architecture
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|AMD64)")
set(ARCHITECTURE "amd64")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64|arm64)")
set(ARCHITECTURE "arm64")
else()
set(ARCHITECTURE "unknown")
endif()
# Print the detected architecture
message(STATUS "Detected architecture: ${ARCHITECTURE}")
# Handle user preference for SSE support (default: OFF)
option(ENABLE_SSE "Enable SSE support" OFF)
# Set SSE_SUPPORT based on the ENABLE_SSE option and architecture
if (ENABLE_SSE)
if (ARCHITECTURE STREQUAL "amd64")
set(SSE_SUPPORT 1)
else()
message(WARNING "SSE support currently only available on amd64 platforms. Turning OFF SSE support.")
set(SSE_SUPPORT 0)
endif()
else()
set(SSE_SUPPORT 0)
endif()
ADD_DEFINITIONS(-DSSE_SUPPORT=${SSE_SUPPORT})
# Check whether we need to link against the rt library
include(CheckCXXSourceCompiles)
check_cxx_source_compiles("
#include <time.h>
int main() {
struct timespec ts;
return clock_gettime(CLOCK_REALTIME, &ts);
}
" HAVE_CLOCK_GETTIME)
set(genie_lib_header
include/arguments.h
include/genotype.h
include/helper.h
include/io.h
include/mailman.h
include/matmult.h
include/printable.h
include/std.h
include/storage.h
include/functions.h
include/vectorfn.h
)
set(genie_lib_source
src/genotype.cpp
src/matmult.cpp
src/storage.cpp
src/functions.cpp
)
add_library(genie_lib STATIC ${genie_lib_header} ${genie_lib_source})
target_include_directories(genie_lib INTERFACE include)
target_link_libraries(genie_lib PRIVATE Threads::Threads)
IF (NOT HAVE_CLOCK_GETTIME)
target_link_libraries(genie_lib PRIVATE rt)
ENDIF ()
add_executable(GENIE_mem src/ge_mem_flexible.cpp)
add_executable(GENIE src/ge_hetro_flexible.cpp)
add_executable(GENIE_multi_pheno src/ge_hetro_flexible_multi_pheno.cpp)
# Link executables against required dependencies
target_link_libraries(GENIE PRIVATE genie_lib)
target_link_libraries(GENIE_mem PRIVATE genie_lib)
target_link_libraries(GENIE_multi_pheno PRIVATE genie_lib)
# Handle user preference for SSE support (default: OFF)
option(BUILD_PYTHON_MODULE "Whether the python module is being built from the scikit-build-core context" OFF)
if (BUILD_PYTHON_MODULE)
install(TARGETS GENIE GENIE_mem GENIE_multi_pheno DESTINATION rhe)
endif ()