-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
185 lines (152 loc) · 5.45 KB
/
Copy pathCMakeLists.txt
File metadata and controls
185 lines (152 loc) · 5.45 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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# CMakeLists.txt
cmake_minimum_required(VERSION 4.3.0)
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "451f2fe2-a8a2-47c3-bc32-94786d8fc91b")
set(CMAKE_CXX_MODULE_STD ON)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Set the version of C++ for the project
if(WIN32)
set(CMAKE_CXX_STANDARD 23)
else()
set(CMAKE_CXX_STANDARD 26)
endif()
# Turning off extensions avoids an issue with the clang 16 compiler
# clang 17 and greater can avoid this setting
set(CMAKE_CXX_EXTENSIONS OFF)
# Keep all internal functions (including the static C++ library) private.
# Only show the specific Python entry point.
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)
project(raspa3
VERSION 3.1.0
DESCRIPTION ""
HOMEPAGE_URL "https://github.com/iraspa/raspa3"
LANGUAGES C CXX)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
add_definitions(-DVERSION=${PROJECT_VERSION})
find_package(ZLIB)
find_package(BLAS REQUIRED)
find_package(LAPACK)
find_package(OpenCL)
include_directories(${OpenCL_INCLUDE_DIRS})
set(MSVC_WARNINGS /W4 /w14242 /w14254 /w14263 /w14265 /w14287 /we4289 /w14296 /w14311 /w14545 /w14546 /w14547 /w14549 /w14555 /w14619 /w14640 /w14826 /w14826 /w14905 /w14906 /w14928 /permissive-)
set(CLANG_WARNINGS -Wall -Wextra -Wshadow -Wnon-virtual-dtor -Wold-style-cast -Wcast-align -Wunused -Woverloaded-virtual -Wpedantic -Wconversion -Wsign-conversion -Wnull-dereference -Wdouble-promotion -Wformat=2 -Wimplicit-fallthrough -Wno-gnu-anonymous-struct -Wno-error=deprecated-declarations -Wno-error=nan-infinity-disabled -Wno-deprecated-declarations -Wno-nan-infinity-disabled -Wno-unknown-warning-option)
set(GCC_WARNINGS -Wall -Wextra -Wmisleading-indentation -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wuseless-cast -Wsuggest-override)
if(MSVC)
set(PROJECT_WARNINGS_CXX ${MSVC_WARNINGS})
elseif(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")
set(PROJECT_WARNINGS_CXX ${CLANG_WARNINGS})
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(PROJECT_WARNINGS_CXX ${GCC_WARNINGS})
endif()
if(BUILD_LIBTORCH)
find_package(Torch REQUIRED)
add_definitions(-DBUILD_LIBTORCH -Wno-invalid-specialization)
message("TORCH_LIBRARIES: ${TORCH_LIBRARIES}")
include_directories(
"${TORCH_INCLUDE_DIRS}" # libtorch headers
)
endif()
if(BUILD_TESTING)
enable_testing()
include(FetchContent)
FetchContent_Declare(googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.17.0
EXCLUDE_FROM_ALL)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
include(GoogleTest)
include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR})
include_directories(${gmock_SOURCE_DIR}/include ${gmock_SOURCE_DIR})
endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
include(FetchContent)
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libraries" FORCE)
set(BUILD_STATIC_LIBS ON CACHE BOOL "Build static libraries" FORCE)
set(HDF5_BUILD_CPP_LIB ON CACHE BOOL "Build static libraries" FORCE)
set(HDF5_ENABLE_NONSTANDARD_FEATURE_FLOAT16 OFF CACHE BOOL "Build static libraries" FORCE)
FetchContent_Declare(hdf5
GIT_REPOSITORY https://github.com/HDFGroup/hdf5.git
GIT_TAG 2.1.1
EXCLUDE_FROM_ALL)
FetchContent_MakeAvailable(hdf5)
set(HDF5_INCLUDE_DIRS "$<BUILD_INTERFACE:${hdf5_SOURCE_DIR}/src/;${hdf5_SOURCE_DIR}/src/H5FDsubfiling;${hdf5_SOURCE_DIR}/c++/src;${hdf5_BINARY_DIR};${hdf5_BINARY_DIR}/src>")
include_directories(${HDF5_INCLUDE_DIRS})
function(raspa_target_link_libraries target_name)
if(CONDA)
target_link_libraries(${target_name}
PUBLIC
${BLAS_LIBRARIES}
${LAPACK_LIBRARIES}
hdf5-static;hdf5_tools-static;hdf5_hl-static;hdf5_cpp-static;hdf5_hl_cpp-static
${TORCH_LIBRARIES}
OpenCL::OpenCL
ZLIB::ZLIB
-lpthread)
elseif(LINUX)
target_link_libraries(${target_name}
PUBLIC
-static-libgcc
${BLAS_LIBRARIES}
${LAPACK_LIBRARIES}
hdf5-static;hdf5_tools-static;hdf5_hl-static;hdf5_cpp-static;hdf5_hl_cpp-static
${TORCH_LIBRARIES}
-Wl,--as-needed OpenCL::OpenCL
-nostdlib++
-l:libc++.a
-l:libc++abi.a
-l:libunwind.a
-lm
-ldl
${ZLIB_LIBRARIES}
-lpthread)
elseif(WIN32)
target_link_libraries(${target_name}
PUBLIC
${BLAS_LIBRARIES}
${LAPACK_LIBRARIES}
${HDF5_LIBRARIES_TO_EXPORT}
${TORCH_LIBRARIES}
OpenCL::OpenCL
-nostdlib++
${ZLIB_LIBRARIES})
elseif(APPLE)
target_link_libraries(${target_name}
PUBLIC
${BLAS_LIBRARIES}
${LAPACK_LIBRARIES}
hdf5-static;hdf5_tools-static;hdf5_hl-static;hdf5_cpp-static;hdf5_hl_cpp-static
${TORCH_LIBRARIES}
OpenCL::OpenCL
${ZLIB_LIBRARIES}
-static-libstdc++
-nostdlib++ # Prevent linking system libstdc++ or system libc++
$ENV{HOMEBREW_PREFIX}/opt/llvm/lib/c++/libc++.a
$ENV{HOMEBREW_PREFIX}/opt/llvm/lib/c++/libc++abi.a
$ENV{HOMEBREW_PREFIX}/opt/llvm/lib/unwind/libunwind.a
-lpthread)
endif()
endfunction()
add_subdirectory(src)
if(BUILD_PYTHON)
add_subdirectory(raspa)
endif()
if(BUILD_APP)
add_subdirectory(data)
add_subdirectory(examples)
add_subdirectory(app)
endif()
if(BUILD_CLI)
add_subdirectory(cli)
endif()
if(BUILD_DOXYGEN)
add_subdirectory(docs)
endif()
add_subdirectory(packaging)
if(BUILD_TESTING)
add_subdirectory(tests)
endif()
if(BUILD_BENCHMARKS)
add_subdirectory(benchmarks)
endif()