forked from sudara/melatonin_blur
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
98 lines (81 loc) · 3.36 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
98
cmake_minimum_required(VERSION 3.20)
project(MelatoninBlur VERSION 1.0.0 LANGUAGES CXX
DESCRIPTION "Fast Blurs for JUCE"
HOMEPAGE_URL "https://github.com/sudara/melatonin_blur")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
include(FetchContent)
if (MelatoninBlur_IS_TOP_LEVEL)
message(STATUS "Cloning JUCE...")
FetchContent_Declare(JUCE
GIT_REPOSITORY https://github.com/juce-framework/JUCE.git
GIT_TAG 7.0.8
GIT_PROGRESS TRUE
)
FetchContent_MakeAvailable(JUCE)
FetchContent_Declare(Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_PROGRESS TRUE
GIT_SHALLOW TRUE
GIT_TAG v3.4.0)
FetchContent_MakeAvailable(Catch2) # find_package equivalent
enable_testing()
add_executable(Tests)
add_executable(Benchmarks)
target_compile_features(Tests PUBLIC cxx_std_17)
target_compile_features(Benchmarks PUBLIC cxx_std_17)
file(GLOB_RECURSE BlurTests CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/tests/*.cpp")
target_sources(Tests PRIVATE ${BlurTests})
target_sources(Benchmarks PRIVATE "benchmarks/benchmarks.cpp")
# Our executables need to know about our plugin code...
target_include_directories(Tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/source)
target_include_directories(Benchmarks PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/source)
juce_add_module("${CMAKE_CURRENT_SOURCE_DIR}")
target_link_libraries(Tests PRIVATE
melatonin_blur
Catch2::Catch2WithMain
juce::juce_graphics # Image, etc
juce::juce_gui_basics # Colour, etc
juce::juce_audio_basics # FloatVectorOperations
juce::juce_recommended_config_flags
juce::juce_recommended_lto_flags
juce::juce_recommended_warning_flags)
target_link_libraries(Benchmarks PRIVATE
melatonin_blur
Catch2::Catch2WithMain
juce::juce_graphics # Image, etc
juce::juce_gui_basics # Colour, etc
juce::juce_audio_basics # FloatVectorOperations
juce::juce_recommended_config_flags
juce::juce_recommended_lto_flags
juce::juce_recommended_warning_flags)
# Enable this once tests are happy fundamentally in CI
# set_target_properties("${TARGET_NAME}" PROPERTIES COMPILE_WARNING_AS_ERROR ON)
target_compile_definitions(Tests PRIVATE
PROJECT_ROOT="${CMAKE_SOURCE_DIR}"
JUCE_WEB_BROWSER=0
JUCE_USE_CURL=0
)
target_compile_definitions(Benchmarks PRIVATE
PROJECT_ROOT="${CMAKE_SOURCE_DIR}"
JUCE_WEB_BROWSER=0
JUCE_USE_CURL=0
)
include(${Catch2_SOURCE_DIR}/extras/Catch.cmake)
catch_discover_tests(Tests)
catch_discover_tests(Benchmarks)
if (MSVC)
# https://learn.microsoft.com/en-us/cpp/build/reference/fp-specify-floating-point-behavior?view=msvc-170#fast
target_compile_options(Benchmarks PUBLIC $<$<CONFIG:RELEASE>:/fp:fast>)
else ()
# See the implications here:
# https://stackoverflow.com/q/45685487
target_compile_options(Benchmarks PUBLIC $<$<CONFIG:RELEASE>:-Ofast>)
target_compile_options(Benchmarks PUBLIC $<$<CONFIG:RelWithDebInfo>:-Ofast>)
endif ()
else ()
if (NOT COMMAND juce_add_module)
message(FATAL_ERROR "JUCE must be added to your project before melatonin_blur!")
endif ()
juce_add_module("${CMAKE_CURRENT_SOURCE_DIR}")
endif ()