forked from Themaister/muFFT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
89 lines (78 loc) · 3.77 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
cmake_minimum_required(VERSION 3.5)
set(CMAKE_C_STANDARD 99)
project(muFFT LANGUAGES C)
if (CMAKE_COMPILER_IS_GNUCC OR (${CMAKE_C_COMPILER_ID} MATCHES "Clang"))
# Cannot safely use -ffast-math, breaks on GCC due to reliance on -0.0f behavior.
set(MUFFT_C_FLAGS -Wall -Wextra)
elseif (MSVC)
set(MUFFT_C_FLAGS /fp:precise /D_CRT_SECURE_NO_WARNINGS /wd4267 /wd4244 /wd4309 /wd4005 /MP /DNOMINMAX)
endif()
message("Processor: ${CMAKE_SYSTEM_PROCESSOR}")
option(MUFFT_SIMD_SSE "Enable SSE support if present" ON)
option(MUFFT_SIMD_SSE3 "Enable SSE3 support if present" ON)
option(MUFFT_SIMD_AVX "Enable AVX support if present" ON)
option(MUFFT_ENABLE_FFTW "Enable FFTW support" ON)
if (ANDROID)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
add_library(muFFT STATIC fft.c kernel.c cpu.c)
target_compile_options(muFFT PRIVATE ${MUFFT_C_FLAGS})
target_include_directories(muFFT PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
if (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)")
target_compile_definitions(muFFT PRIVATE MUFFT_HAVE_X86)
target_sources(muFFT PRIVATE x86/kernel.h)
message("Enabling x86 SIMD support.")
if (MUFFT_SIMD_SSE)
add_library(muFFT-sse OBJECT x86/kernel.sse.c)
if (CMAKE_COMPILER_IS_GNUCC OR (${CMAKE_C_COMPILER_ID} MATCHES "Clang"))
target_compile_options(muFFT-sse PRIVATE -msse -mno-sse3 -mno-avx)
endif()
target_compile_options(muFFT-sse PRIVATE ${MUFFT_C_FLAGS})
target_compile_definitions(muFFT PRIVATE MUFFT_HAVE_SSE)
target_link_libraries(muFFT PRIVATE muFFT-sse)
endif()
if (MUFFT_SIMD_SSE3)
add_library(muFFT-sse3 OBJECT x86/kernel.sse3.c)
if (CMAKE_COMPILER_IS_GNUCC OR (${CMAKE_C_COMPILER_ID} MATCHES "Clang"))
target_compile_options(muFFT-sse3 PRIVATE -msse -msse3 -mno-avx)
endif()
target_compile_options(muFFT-sse3 PRIVATE ${MUFFT_C_FLAGS})
target_compile_definitions(muFFT PRIVATE MUFFT_HAVE_SSE3)
target_link_libraries(muFFT PRIVATE muFFT-sse3)
endif()
if (MUFFT_SIMD_AVX)
add_library(muFFT-avx OBJECT x86/kernel.avx.c)
if (CMAKE_COMPILER_IS_GNUCC OR (${CMAKE_C_COMPILER_ID} MATCHES "Clang"))
target_compile_options(muFFT-avx PRIVATE -msse -msse3 -mavx)
endif()
target_compile_options(muFFT-avx PRIVATE ${MUFFT_C_FLAGS})
target_compile_definitions(muFFT PRIVATE MUFFT_HAVE_AVX)
target_link_libraries(muFFT PRIVATE muFFT-avx)
endif()
endif()
if (NOT MSVC)
target_link_libraries(muFFT PRIVATE m)
endif()
if (MUFFT_ENABLE_FFTW)
include(FindPkgConfig)
pkg_check_modules(FFTW3f fftw3f)
if (FFTW3f_FOUND)
message("Found FFTW, enabling bench and testing.")
message("FFTW3f libraries: ${FFTW3f_LIBRARIES}")
message("FFTW3f include directories: ${FFTW3f_INCLUDE_DIRS}")
message("FFTW3f CFLAGS: ${FFTW3f_CFLAGS_OTHER}")
message("FFTW3f link directory: ${FFTW3f_LIBRARY_DIRS}")
# target_link_directories is 3.13 apparently.
link_directories(${FFTW3f_LIBRARY_DIRS})
add_executable(muFFT-bench bench.c)
target_link_libraries(muFFT-bench PRIVATE muFFT ${FFTW3f_LIBRARIES})
target_include_directories(muFFT-bench PRIVATE ${FFTW3f_INCLUDE_DIRS})
target_compile_options(muFFT-bench PRIVATE ${MUFFT_C_FLAGS} ${FFTW3f_CFLAGS_OTHER})
#target_link_directories(muFFT-bench PRIVATE ${FFTW3f_LIBRARY_DIRS})
add_executable(muFFT-test test.c)
target_link_libraries(muFFT-test PRIVATE muFFT ${FFTW3f_LIBRARIES})
target_include_directories(muFFT-test PRIVATE ${FFTW3f_INCLUDE_DIRS})
target_compile_options(muFFT-test PRIVATE ${MUFFT_C_FLAGS} ${FFTW3f_CFLAGS_OTHER})
#target_link_directories(muFFT-test PRIVATE ${FFTW3f_LIBRARY_DIRS})
endif()
endif()