-
Notifications
You must be signed in to change notification settings - Fork 27
/
cmake.tests.txt
106 lines (91 loc) · 3.33 KB
/
cmake.tests.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
99
100
101
102
103
104
105
106
# -*- cmake -*-
# Copyright 2021 Jean Pierre Cimalando
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#
include(CTest)
include(CheckCSourceCompiles)
find_package(PkgConfig)
# sndfile
# ------------------------------------------------------------------------------
find_package(SndFile)
if(TARGET SndFile::sndfile)
add_library(sndfile INTERFACE)
target_link_libraries(sndfile INTERFACE SndFile::sndfile)
else()
pkg_check_modules(SndFileViaPkgConfig "sndfile" IMPORTED_TARGET)
if(TARGET PkgConfig::SndFileViaPkgConfig)
add_library(sndfile INTERFACE)
target_link_libraries(sndfile INTERFACE PkgConfig::SndFileViaPkgConfig)
endif()
endif()
# extra check for macOS, which can fail if build is universal but library is not
function(ysfx_check_sndfile_works VAR)
if(NOT TARGET sndfile)
set("${VAR}" FALSE)
endif()
set(CMAKE_REQUIRED_LIBRARIES sndfile)
check_c_source_compiles("#include <sndfile.h>
int main() { sf_close((SNDFILE *)0); }" "${VAR}")
endfunction()
ysfx_check_sndfile_works(YSFX_TESTS_HAVE_SNDFILE)
# catch
# ------------------------------------------------------------------------------
include(FetchContent)
FetchContent_Declare(catch
URL "https://github.com/catchorg/Catch2/archive/refs/tags/v2.13.7.tar.gz"
URL_HASH "SHA512=1c3cbdecc6a3b59360a97789c4784d79d027e1b63bdc42b0e152c3272f7bad647fcd1490aa5caf67f968a6311dc9624b5a70d5eb3fbc1d5179d520e09b76c9ed")
FetchContent_GetProperties(catch)
if(NOT catch_POPULATED)
FetchContent_Populate(catch)
endif()
add_library(catch INTERFACE)
target_include_directories(catch INTERFACE "${catch_SOURCE_DIR}/single_include/catch2")
list(APPEND CMAKE_MODULE_PATH "${catch_SOURCE_DIR}/contrib")
include(Catch)
# tests
# ------------------------------------------------------------------------------
add_executable(ysfx_tests
"tests/ysfx_test_parse.cpp"
"tests/ysfx_test_serialization.cpp"
"tests/ysfx_test_slider.cpp"
"tests/ysfx_test_midi.cpp"
"tests/ysfx_test_audio_wav.cpp"
"tests/ysfx_test_audio_flac.cpp"
"tests/ysfx_test_filesystem.cpp"
"tests/ysfx_test_preset.cpp"
"tests/ysfx_test_c_api.c"
"tests/ysfx_test_utils.hpp"
"tests/ysfx_test_utils.cpp"
"tests/ysfx_test_main.cpp")
target_link_libraries(ysfx_tests
PRIVATE
ysfx-private
eel2
eel2nasm
wdl-base
catch)
if(YSFX_GFX)
target_link_libraries(ysfx_tests PUBLIC lice)
endif()
if(YSFX_TESTS_HAVE_SNDFILE)
target_compile_definitions(ysfx_tests PRIVATE "YSFX_TESTS_HAVE_SNDFILE")
target_link_libraries(ysfx_tests PRIVATE sndfile)
endif()
catch_discover_tests(ysfx_tests)
# test tools
# ------------------------------------------------------------------------------
add_executable(ysfx_parse_menu "tests/tools/ysfx_parse_menu.cpp")
target_link_libraries(ysfx_parse_menu PRIVATE ysfx::ysfx)