forked from aubio/aubio
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
97 lines (83 loc) · 2.13 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
cmake_minimum_required(VERSION 3.8)
project(aubio C)
include (CheckIncludeFile)
if (WIN32)
if (MSVC)
add_definitions(
-D_CRT_SECURE_NO_WARNINGS=1
)
endif()
add_definitions(
-DHAVE_WIN_HACKS
)
endif()
if (APPLE)
set(BLA_VENDOR Apple)
find_package(BLAS REQUIRED MODULE)
set(BLAS_FLAG -DHAVE_ACCELERATE=1)
else()
set(BLA_VENDOR OpenBLAS)
find_package(BLAS MODULE)
if (BLAS_FOUND)
CHECK_INCLUDE_FILE(openblas/cblas.h STANDARD_OPENBLAS)
CHECK_INCLUDE_FILE(cblas-openblas.h UBUNTU_OPENBLAS)
if (UBUNTU_OPENBLAS AND NOT STANDARD_OPENBLAS)
set(BLAS_FLAG -DHAVE_BLAS=1 -DHAVE_CBLAS_H=1)
else()
set(BLAS_FLAG -DHAVE_BLAS=1 -DHAVE_OPENBLAS_CBLAS_H=1)
endif()
else()
set(BLA_VENDOR ATLAS)
# put as required as it is mandatory to have a blas library and
# this is the last chance to get one
find_package(BLAS REQUIRED MODULE)
if (BLAS_FOUND)
set(BLAS_FLAG -DHAVE_BLAS=1 -DHAVE_ATLAS_CBLAS_H=1)
endif()
endif()
endif()
find_package(FFTW3 COMPONENTS single REQUIRED MODULE)
message("Detected Blas library: " ${BLA_VENDOR})
set(CMAKE_DEBUG_POSTFIX d)
file(GLOB_RECURSE AUBIO_SOURCES src/*.c)
add_library(aubio STATIC ${AUBIO_SOURCES})
target_link_libraries(aubio PUBLIC
"${BLAS_LIBRARIES}"
"${FFTW3F_LIBRARY}"
)
if(MSVC)
find_package(pthreads REQUIRED)
target_link_libraries(aubio PUBLIC PThreads4W::PThreads4W)
else()
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
target_link_libraries(aubio PUBLIC Threads::Threads)
endif()
#We need both HAVE_FFTW3 and HAVE_FFTW3F; using only the latter does nothing, using only the former is double-precision mode.
target_compile_definitions (aubio
PUBLIC HAVE_FFTW3=1
HAVE_FFTW3F=1
${BLAS_FLAG}
HAVE_STDLIB_H=1
HAVE_STDIO_H=1
HAVE_MATH_H=1
HAVE_STRING_H=1
HAVE_LIMITS_H=1
HAVE_STDARG_H=1
HAVE_C99_VARARGS_MACROS=1
)
file (COPY DIRECTORY src/
DESTINATION "include/aubio"
FILES_MATCHING
PATTERN "*.h"
PATTERN "*_priv.h" EXCLUDE
PATTERN "config.h" EXCLUDE
)
target_include_directories(aubio BEFORE PRIVATE
src
"${FFTW3_INCLUDE_DIR}"
)
target_include_directories(aubio BEFORE PUBLIC
"${CMAKE_CURRENT_BINARY_DIR}/include"
"${FFTW3_INCLUDE_DIR}"
)