1macro ( ADD_FLUID_TEST _test )
2    ADD_EXECUTABLE(${_test} ${_test}.c $<TARGET_OBJECTS:libfluidsynth-OBJ> )
3
4    # only build this unit test when explicitly requested by "make check"
5    set_target_properties(${_test} PROPERTIES EXCLUDE_FROM_ALL TRUE)
6
7    # import necessary compile flags and dependency libraries
8    if ( FLUID_CPPFLAGS )
9        set_target_properties ( ${_test} PROPERTIES COMPILE_FLAGS ${FLUID_CPPFLAGS} )
10    endif ( FLUID_CPPFLAGS )
11    TARGET_LINK_LIBRARIES(${_test} $<TARGET_PROPERTY:libfluidsynth,INTERFACE_LINK_LIBRARIES>)
12
13    # use the local include path to look for fluidsynth.h, as we cannot be sure fluidsynth is already installed
14    target_include_directories(${_test}
15    PUBLIC
16    $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include> # include auto generated headers
17    $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include> # include "normal" public (sub-)headers
18    $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/src> # include private headers
19    $<TARGET_PROPERTY:libfluidsynth,INCLUDE_DIRECTORIES> # include all other header search paths needed by libfluidsynth (esp. glib)
20    )
21
22    # add the test to ctest
23    ADD_TEST(NAME ${_test} COMMAND ${_test})
24
25    # append the current unit test to check-target as dependency
26    add_dependencies(check ${_test})
27
28endmacro ( ADD_FLUID_TEST )
29
30macro ( ADD_FLUID_TEST_UTIL _util )
31    ADD_EXECUTABLE(${_util} ${_util}.c $<TARGET_OBJECTS:libfluidsynth-OBJ> )
32
33    # only build this unit test when explicitly requested by "make check"
34    set_target_properties(${_util} PROPERTIES EXCLUDE_FROM_ALL TRUE)
35
36    # append no-op generator expression to avoid VS or XCode from adding per-config subdirectories
37    set_target_properties(${_util} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/test/utils/$<0:>)
38
39    # import necessary compile flags and dependency libraries
40    if ( FLUID_CPPFLAGS )
41        set_target_properties ( ${_util} PROPERTIES COMPILE_FLAGS ${FLUID_CPPFLAGS} )
42    endif ( FLUID_CPPFLAGS )
43    TARGET_LINK_LIBRARIES(${_util} $<TARGET_PROPERTY:libfluidsynth,INTERFACE_LINK_LIBRARIES>)
44
45    # use the local include path to look for fluidsynth.h, as we cannot be sure fluidsynth is already installed
46    target_include_directories(${_util}
47    PUBLIC
48    $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include> # include auto generated headers
49    $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include> # include "normal" public (sub-)headers
50    $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/src> # include private headers
51    $<TARGET_PROPERTY:libfluidsynth,INCLUDE_DIRECTORIES> # include all other header search paths needed by libfluidsynth (esp. glib)
52    )
53
54    # append the current unit test to check-target as dependency
55    add_dependencies(check ${_util})
56
57endmacro ( ADD_FLUID_TEST_UTIL )
58
59# This macro adds a test that writes its output to a file called
60# <test>.output (in the current working dir) and then compares
61# the content with the file given in _expected_output
62macro ( ADD_FLUID_SF_DUMP_TEST _sfname)
63
64    set( test_args "${CMAKE_SOURCE_DIR}/sf2/${_sfname} ${_sfname}.yml" )
65
66    ADD_TEST(${_sfname}_dump_test
67        ${CMAKE_COMMAND}
68        -Dtest_cmd=${CMAKE_BINARY_DIR}/test/utils/dump_sfont${CMAKE_EXECUTABLE_SUFFIX}
69        -Dtest_args=${test_args}
70        -Dtest_output=${_sfname}.yml
71        -Dexpected_output=${CMAKE_SOURCE_DIR}/sf2/${_sfname}.yml
72        -P ${CMAKE_SOURCE_DIR}/cmake_admin/RunOutputTest.cmake
73    )
74
75endmacro ( ADD_FLUID_SF_DUMP_TEST )
76
77macro ( ADD_FLUID_DEMO _demo )
78    ADD_EXECUTABLE(${_demo} ${_demo}.c )
79
80    # only build this unit test when explicitly requested by "make check"
81    set_target_properties(${_demo} PROPERTIES EXCLUDE_FROM_ALL TRUE)
82
83    # import necessary compile flags and dependency libraries
84    if ( FLUID_CPPFLAGS )
85        set_target_properties ( ${_demo} PROPERTIES COMPILE_FLAGS ${FLUID_CPPFLAGS} )
86    endif ( FLUID_CPPFLAGS )
87    TARGET_LINK_LIBRARIES(${_demo} libfluidsynth)
88
89    # use the local include path to look for fluidsynth.h, as we cannot be sure fluidsynth is already installed
90    target_include_directories(${_demo}
91    PUBLIC
92    $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include> # include auto generated headers
93    $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include> # include "normal" public (sub-)headers
94    $<TARGET_PROPERTY:libfluidsynth,INCLUDE_DIRECTORIES> # include all other header search paths needed by libfluidsynth (esp. glib)
95    )
96
97    # append the current unit test to check-target as dependency
98    add_dependencies(demo ${_demo})
99
100endmacro ( ADD_FLUID_DEMO )
101