-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
65 lines (58 loc) · 3.03 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
# add this project to your cmake project using add_subdirectory
# after that you can optionally specify the architecture to build by calling something like
# target_compile_options(oversimple PUBLIC /arch:AVX)
# see test/CMakeLists.txt for an example
cmake_minimum_required(VERSION 3.14.0)
project(Oversimple)
# on MacOS, by default unplug will build an universal binary. you can set oversimple_override_macos_arch to the architecture
# you want to build by uncommenting one of the next two lines. It can be useful because Compiler Explorer does not support
# universal binaries.
# Note: CMake sometimes does not update this when you reload the project without deleting the build folder manually.
set(oversimple_override_macos_arch "")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
add_library(oversimple STATIC)
target_include_directories(oversimple PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
target_include_directories(oversimple PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/r8brain")
target_include_directories(oversimple PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/avec")
target_include_directories(oversimple PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/avec/vectorclass")
target_sources(oversimple PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/r8brain/r8bbase.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/r8brain/pffft_double/pffft_double.c"
"${CMAKE_CURRENT_SOURCE_DIR}/oversimple/FirOversampling.cpp")
target_compile_definitions(oversimple PUBLIC R8B_PFFFT_DOUBLE=1)
if (UNIX)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
target_link_libraries(oversimple Threads::Threads)
#universal binary if building on arm64
if (APPLE)
if (oversimple_override_macos_arch STREQUAL "arm64")
set(CMAKE_OSX_ARCHITECTURES "arm64" CACHE STRING "")
message(STATUS "Supported architectures: arm64 (forced by user)")
elseif (oversimple_override_macos_arch STREQUAL "x86_64")
set(CMAKE_OSX_ARCHITECTURES "x86_64" CACHE STRING "")
message(STATUS "Supported architectures: x86_64 (forced by user)")
else ()
execute_process(
COMMAND uname -m
RESULT_VARIABLE result
OUTPUT_VARIABLE MACHINE_ARCHITECTURE
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if (MACHINE_ARCHITECTURE STREQUAL "arm64")
set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE STRING "")
message(STATUS "Supported architectures: x86_64, arm64")
else ()
message(STATUS "Supported architectures: ${MACHINE_ARCHITECTURE}")
endif ()
endif ()
else ()
target_compile_options(oversimple PUBLIC -march=native)
endif ()
endif (UNIX)
if (WIN32)
# default to sse2 on windows, can be overridden in your own cmake if you are including this with add_subdirectory
# otherwise set it by uncommenting the next line and eventually change it to the desired architecture to build for
# target_compile_options(oversimple PUBLIC /arch:AVX)
endif (WIN32)