@@ -3,20 +3,20 @@ cmake_minimum_required(VERSION 3.19)
3
3
project (finufft VERSION 2.2.0 LANGUAGES C CXX)
4
4
5
5
set (GNU_LIKE_FRONTENDS AppleClang Clang GNU)
6
- if (CMAKE_CXX_COMPILER_ID IN_LIST GNU_LIKE_FRONTENDS)
6
+ if (CMAKE_CXX_COMPILER_ID IN_LIST GNU_LIKE_FRONTENDS)
7
7
# Set custom compiler flags for gcc-compatible compilers
8
8
set (CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG -funroll-loops" )
9
9
set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG -funroll-loops" )
10
- endif ()
10
+ endif ()
11
11
12
12
include (CTest)
13
13
14
- if (CMAKE_SYSTEM_PROCESSOR MATCHES "ppc|ppc64|powerpc|powerpc64" OR (APPLE AND CMAKE_OSX_ARCHITECTURES MATCHES "ppc|ppc64" ))
14
+ if (CMAKE_SYSTEM_PROCESSOR MATCHES "ppc|ppc64|powerpc|powerpc64" OR (APPLE AND CMAKE_OSX_ARCHITECTURES MATCHES "ppc|ppc64" ))
15
15
# PowerPC arch does not have -march flag.
16
16
set (FINUFFT_ARCH_FLAGS "-mtune=native" CACHE STRING "Compiler flags for specifying target architecture." )
17
- else ()
17
+ else ()
18
18
set (FINUFFT_ARCH_FLAGS "-march=native" CACHE STRING "Compiler flags for specifying target architecture." )
19
- endif ()
19
+ endif ()
20
20
set (FINUFFT_FFTW_SUFFIX "OpenMP" CACHE STRING "Suffix for FFTW libraries (e.g. OpenMP, Threads etc.)" )
21
21
set (FINUFFT_FFTW_LIBRARIES "DEFAULT" CACHE STRING "Specify a custom FFTW library" )
22
22
@@ -34,24 +34,24 @@ option(FINUFFT_STATIC_LINKING "Whether to link the static FINUFFT library (libfi
34
34
option (FINUFFT_BUILD_DEVEL "Whether to build developement executables" OFF )
35
35
# sphinx tag (don't remove): @cmake_opts_end
36
36
37
- if (FINUFFT_USE_CPU)
37
+ if (FINUFFT_USE_CPU)
38
38
# suppress Windows warnings about "unsafe" functions
39
- if (WIN32 )
39
+ if (WIN32 )
40
40
add_definitions (-D_CRT_SECURE_NO_WARNINGS)
41
- endif ()
41
+ endif ()
42
42
43
43
# make apple with gnu use old linker, new linker breaks, see issue #360
44
- if ((APPLE ) AND (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" ))
44
+ if ((APPLE ) AND (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" ))
45
45
add_link_options ("-ld64" )
46
- endif ()
46
+ endif ()
47
47
48
48
set (CPM_DOWNLOAD_VERSION 0.38.0)
49
49
set (FFTW_VERSION 3.3.10)
50
50
51
51
include (cmake/setupCPM.cmake)
52
52
include (cmake/setupFFTW.cmake)
53
53
54
- endif ()
54
+ endif ()
55
55
56
56
if (FINUFFT_BUILD_MATLAB)
57
57
# When building for matlab, we will fetch the OpenMP library used by matlab
@@ -99,21 +99,21 @@ endfunction()
99
99
100
100
# Utility function to link static/dynamic lib
101
101
function (finufft_link_test target )
102
- if (FINUFFT_STATIC_LINKING)
103
- target_link_libraries (${target} PRIVATE finufft_static)
104
- if (FINUFFT_USE_OPENMP)
105
- target_link_libraries (${target} PRIVATE OpenMP::OpenMP_CXX)
106
- if (WIN32 )
107
- target_link_options (${target} PRIVATE ${OpenMP_CXX_FLAGS} )
108
- endif ()
109
- endif ()
110
- else ()
111
- target_link_libraries (${target} PRIVATE finufft)
112
- if (WIN32 )
113
- target_compile_definitions (${target} PRIVATE FINUFFT_DLL)
114
- endif ()
115
- endif ()
116
- enable_asan(${target} )
102
+ if (FINUFFT_STATIC_LINKING)
103
+ target_link_libraries (${target} PRIVATE finufft_static)
104
+ if (FINUFFT_USE_OPENMP)
105
+ target_link_libraries (${target} PRIVATE OpenMP::OpenMP_CXX)
106
+ if (WIN32 )
107
+ target_link_options (${target} PRIVATE ${OpenMP_CXX_FLAGS} )
108
+ endif ()
109
+ endif ()
110
+ else ()
111
+ target_link_libraries (${target} PRIVATE finufft)
112
+ if (WIN32 )
113
+ target_compile_definitions (${target} PRIVATE FINUFFT_DLL)
114
+ endif ()
115
+ endif ()
116
+ enable_asan(${target} )
117
117
endfunction ()
118
118
119
119
# Utility function to set finufft compilation options.
@@ -134,9 +134,9 @@ function(set_finufft_options target)
134
134
target_link_libraries (${target} PRIVATE OpenMP::OpenMP_CXX)
135
135
# there are issues on windows with OpenMP and CMake, so we need to manually add the flags
136
136
# otherwise there are link errors
137
- if (WIN32 )
137
+ if (WIN32 )
138
138
target_link_options (${target} PRIVATE ${OpenMP_CXX_FLAGS} )
139
- endif ()
139
+ endif ()
140
140
else ()
141
141
if (CMAKE_CXX_COMPILER_ID IN_LIST FINUFFT_GNU_LIKE_COMPILERS)
142
142
# OpenMP disabled, suppress unknown pragma warnings to avoid spam.
@@ -148,16 +148,16 @@ function(set_finufft_options target)
148
148
# include them since we need them for build not for install
149
149
# trying to include them directly into the fftw and fftwf targets causes issues with
150
150
# the latest version of cmake, so we do it here instead.
151
- if ( (NOT FFTW_FOUND ) OR (FINUFFT_FFTW_LIBRARIES STREQUAL DOWNLOAD))
152
- list (GET FINUFFT_FFTW_LIBRARIES 0 element)
151
+ if ((NOT FFTW_FOUND) OR (FINUFFT_FFTW_LIBRARIES STREQUAL DOWNLOAD))
152
+ list (GET FINUFFT_FFTW_LIBRARIES 0 element)
153
153
get_property (FFTW_SOURCE_DIR TARGET ${element} PROPERTY SOURCE_DIR)
154
154
set (FFTW_INCLUDE_DIR ${FFTW_SOURCE_DIR} /api)
155
155
target_include_directories (${target} PUBLIC ${FFTW_INCLUDE_DIR} )
156
- endif ()
156
+ endif ()
157
157
158
158
endfunction ()
159
159
160
- if (FINUFFT_USE_CPU)
160
+ if (FINUFFT_USE_CPU)
161
161
# Main finufft libraries
162
162
add_library (finufft_f32 OBJECT ${FINUFFT_PRECISION_DEPENDENT_SOURCES} )
163
163
target_compile_definitions (finufft_f32 PRIVATE SINGLE)
@@ -169,7 +169,7 @@ if(FINUFFT_USE_CPU)
169
169
set_finufft_options(finufft_f64)
170
170
target_link_libraries (finufft_f64 PUBLIC ${FINUFFT_FFTW_LIBRARIES} )
171
171
172
- if (WIN32 )
172
+ if (WIN32 )
173
173
add_library (finufft_f32_dll OBJECT ${FINUFFT_PRECISION_DEPENDENT_SOURCES} )
174
174
target_compile_definitions (finufft_f32_dll PRIVATE SINGLE dll_EXPORTS FINUFFT_DLL)
175
175
set_finufft_options(finufft_f32_dll)
@@ -179,54 +179,54 @@ if(FINUFFT_USE_CPU)
179
179
target_compile_definitions (finufft_f64_dll PRIVATE dll_EXPORTS FINUFFT_DLL)
180
180
set_finufft_options(finufft_f64_dll)
181
181
target_link_libraries (finufft_f64_dll PUBLIC ${FINUFFT_FFTW_LIBRARIES} )
182
- endif ()
182
+ endif ()
183
183
184
184
add_library (finufft SHARED src/utils_precindep.cpp contrib/legendre_rule_fast.cpp)
185
185
target_compile_definitions (finufft PRIVATE dll_EXPORTS FINUFFT_DLL)
186
186
set_finufft_options(finufft)
187
- if (NOT WIN32 )
187
+ if (NOT WIN32 )
188
188
target_link_libraries (finufft PUBLIC finufft_f32 finufft_f64)
189
- else ()
189
+ else ()
190
190
target_link_libraries (finufft PUBLIC finufft_f32_dll finufft_f64_dll)
191
- endif ()
191
+ endif ()
192
192
# windows does not have a math library, so we need to exclude it
193
- if (NOT WIN32 )
193
+ if (NOT WIN32 )
194
194
target_link_libraries (finufft PUBLIC m)
195
- endif ()
195
+ endif ()
196
196
target_include_directories (finufft PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /include >)
197
197
target_include_directories (finufft SYSTEM INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX} /include >)
198
198
199
199
add_library (finufft_static STATIC src/utils_precindep.cpp contrib/legendre_rule_fast.cpp)
200
200
set_finufft_options(finufft_static)
201
201
target_link_libraries (finufft_static PUBLIC finufft_f32 finufft_f64)
202
202
# windows does not have a math library, so we need to exclude it
203
- if (NOT WIN32 )
203
+ if (NOT WIN32 )
204
204
target_link_libraries (finufft_static PUBLIC m)
205
- endif ()
205
+ endif ()
206
206
target_include_directories (finufft_static PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /include >)
207
207
target_include_directories (finufft_static SYSTEM INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX} /include >)
208
208
209
209
file (GLOB FINUFFT_PUBLIC_HEADERS "${CMAKE_CURRENT_SOURCE_DIR} /include/finufft*.h" )
210
210
set_target_properties (finufft PROPERTIES PUBLIC_HEADER "${FINUFFT_PUBLIC_HEADERS} " )
211
211
212
212
list (APPEND INSTALL_TARGETS finufft finufft_static)
213
- endif ()
214
-
215
- if (FINUFFT_USE_CUDA)
216
- if (NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
217
- message ("FINUFFT WARNING: No CUDA architecture supplied via '-DCMAKE_CUDA_ARCHITECTURES=...', defaulting to '60;70;75;'" )
218
- message ("See: https://developer.nvidia.com/cuda-gpus for more details on what architecture to supply." )
219
- set (CMAKE_CUDA_ARCHITECTURES "60;70;75" CACHE STRING "" FORCE)
220
- endif ()
221
- enable_language (CUDA)
222
- find_package (CUDAToolkit REQUIRED)
223
- add_subdirectory (src/cuda)
224
- if (BUILD_TESTING AND FINUFFT_BUILD_TESTS)
225
- add_subdirectory (perftest/cuda)
226
- endif ()
227
-
228
- list (APPEND INSTALL_TARGETS cufinufft cufinufft_static)
229
- endif ()
213
+ endif ()
214
+
215
+ if (FINUFFT_USE_CUDA)
216
+ if (NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
217
+ message ("FINUFFT WARNING: No CUDA architecture supplied via '-DCMAKE_CUDA_ARCHITECTURES=...', defaulting to '60;70;75;'" )
218
+ message ("See: https://developer.nvidia.com/cuda-gpus for more details on what architecture to supply." )
219
+ set (CMAKE_CUDA_ARCHITECTURES "60;70;75" CACHE STRING "" FORCE)
220
+ endif ()
221
+ enable_language (CUDA)
222
+ find_package (CUDAToolkit REQUIRED)
223
+ add_subdirectory (src/cuda)
224
+ if (BUILD_TESTING AND FINUFFT_BUILD_TESTS)
225
+ add_subdirectory (perftest/cuda)
226
+ endif ()
227
+
228
+ list (APPEND INSTALL_TARGETS cufinufft cufinufft_static)
229
+ endif ()
230
230
231
231
# Add tests defined in their own directory
232
232
if (BUILD_TESTING AND FINUFFT_BUILD_TESTS AND FINUFFT_USE_CPU)
@@ -258,27 +258,27 @@ endif ()
258
258
include (GNUInstallDirs)
259
259
install (TARGETS ${INSTALL_TARGETS} PUBLIC_HEADER )
260
260
install (FILES ${PROJECT_SOURCE_DIR} /LICENSE
261
- DESTINATION ${CMAKE_INSTALL_DATAROOTDIR} /licenses/finufft)
261
+ DESTINATION ${CMAKE_INSTALL_DATAROOTDIR} /licenses/finufft)
262
262
if (FINUFFT_USE_CPU)
263
- install (DIRECTORY ${PROJECT_SOURCE_DIR} /examples
264
- DESTINATION ${CMAKE_INSTALL_DATAROOTDIR} /finufft
265
- PATTERN "CMakeLists.txt" EXCLUDE
266
- PATTERN "README" EXCLUDE
267
- PATTERN "examples/cuda" EXCLUDE
268
- )
269
- if (FINUFFT_BUILD_FORTRAN)
270
- install (DIRECTORY ${PROJECT_SOURCE_DIR} /fortran/examples
271
- DESTINATION ${CMAKE_INSTALL_DATAROOTDIR} /finufft/fortran
272
- )
273
- install (FILES ${PROJECT_SOURCE_DIR} /include /finufft.fh
274
- DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
263
+ install (DIRECTORY ${PROJECT_SOURCE_DIR} /examples
264
+ DESTINATION ${CMAKE_INSTALL_DATAROOTDIR} /finufft
265
+ PATTERN "CMakeLists.txt" EXCLUDE
266
+ PATTERN "README" EXCLUDE
267
+ PATTERN "examples/cuda" EXCLUDE
275
268
)
276
- endif ()
269
+ if (FINUFFT_BUILD_FORTRAN)
270
+ install (DIRECTORY ${PROJECT_SOURCE_DIR} /fortran/examples
271
+ DESTINATION ${CMAKE_INSTALL_DATAROOTDIR} /finufft/fortran
272
+ )
273
+ install (FILES ${PROJECT_SOURCE_DIR} /include /finufft.fh
274
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
275
+ )
276
+ endif ()
277
277
endif ()
278
278
if (FINUFFT_USE_CUDA)
279
- install (DIRECTORY ${PROJECT_SOURCE_DIR} /examples/cuda
280
- DESTINATION ${CMAKE_INSTALL_DATAROOTDIR} /finufft/examples
281
- PATTERN "README" EXCLUDE
282
- PATTERN "CMakeLists.txt" EXCLUDE
283
- )
284
- endif ()
279
+ install (DIRECTORY ${PROJECT_SOURCE_DIR} /examples/cuda
280
+ DESTINATION ${CMAKE_INSTALL_DATAROOTDIR} /finufft/examples
281
+ PATTERN "README" EXCLUDE
282
+ PATTERN "CMakeLists.txt" EXCLUDE
283
+ )
284
+ endif ()
0 commit comments