CMakeLists.txt (4918B)
1 function(cp_script script_name) 2 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${script_name} 3 ${CMAKE_CURRENT_BINARY_DIR}/${script_name} COPYONLY) 4 endfunction() 5 6 function(quick_test test_name link) 7 add_executable(${test_name} "${test_name}.cpp") 8 add_test(NAME ${test_name} 9 COMMAND ${test_name}) 10 target_link_libraries(${test_name} ${link} ${ARGN}) 11 if(Werror) 12 if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24) 13 set_target_properties(${test_name} PROPERTIES COMPILE_WARNINGS_AS_ERRORS ON) 14 else() 15 if(NOT WIN32) # For Windows, just allow warnings for now 16 target_compile_options(${test_name} PUBLIC -Werror) 17 endif() 18 endif() 19 endif() 20 endfunction() 21 22 #for tests looking for files stored in the source dir 23 add_definitions(-DSOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}") 24 25 #Extra libraries added to make test and full compilation use the same library 26 #links for quirky compilers 27 set(test_lib zynaddsubfx_core ${GUI_LIBRARIES} ${ZLIB_LIBRARY} ${FFTW3F_LIBRARIES} 28 ${MXML_LIBRARIES} pthread ) 29 30 message(STATUS "Linking tests with: ${test_lib}") 31 32 quick_test(AdNoteTest ${test_lib}) 33 quick_test(AllocatorTest ${test_lib}) 34 quick_test(ControllerTest ${test_lib}) 35 quick_test(EchoTest ${test_lib}) 36 quick_test(EffectTest ${test_lib}) 37 quick_test(KitTest ${test_lib}) 38 quick_test(MemoryStressTest ${test_lib}) 39 quick_test(MicrotonalTest ${test_lib}) 40 quick_test(MsgParseTest ${test_lib}) 41 quick_test(OscilGenTest ${test_lib}) 42 quick_test(PadNoteTest ${test_lib}) 43 quick_test(PortamentoTest ${test_lib}) 44 quick_test(RandTest ${test_lib}) 45 quick_test(SubNoteTest ${test_lib}) 46 quick_test(TriggerTest ${test_lib}) 47 quick_test(UnisonTest ${test_lib}) 48 quick_test(WatchTest ${test_lib}) 49 quick_test(XMLwrapperTest ${test_lib}) 50 quick_test(ReverseTest ${test_lib}) 51 52 quick_test(PluginTest zynaddsubfx_core zynaddsubfx_nio 53 zynaddsubfx_gui_bridge 54 ${GUI_LIBRARIES} ${NIO_LIBRARIES} ${AUDIO_LIBRARIES} 55 ${PLATFORM_LIBRARIES}) 56 quick_test(MiddlewareTest zynaddsubfx_core zynaddsubfx_nio 57 zynaddsubfx_gui_bridge 58 ${GUI_LIBRARIES} ${NIO_LIBRARIES} ${AUDIO_LIBRARIES} 59 ${PLATFORM_LIBRARIES}) 60 61 #Testbed app 62 63 if(NOT (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")) 64 65 #std::thread issues with mingw vvvvv 66 quick_test(MqTest ${test_lib}) 67 #same std::thread mingw issue 68 quick_test(MessageTest zynaddsubfx_core zynaddsubfx_nio 69 zynaddsubfx_gui_bridge 70 ${GUI_LIBRARIES} ${NIO_LIBRARIES} ${AUDIO_LIBRARIES} 71 ${PLATFORM_LIBRARIES}) 72 73 add_executable(ins-test InstrumentStats.cpp) 74 target_link_libraries(ins-test ${test_lib}) 75 if(HAVE_LIBRT) 76 target_link_libraries(ins-test rt) 77 endif() 78 79 if(LIBLO_FOUND) 80 quick_test(PortChecker lo-server zynaddsubfx_core zynaddsubfx_nio 81 zynaddsubfx_gui_bridge 82 ${GUI_LIBRARIES} ${NIO_LIBRARIES} ${AUDIO_LIBRARIES} 83 ${PLATFORM_LIBRARIES}) 84 target_include_directories(PortChecker PRIVATE ${RTOSC_TEST_INCLUDE_DIR}) 85 target_link_directories(PortChecker PRIVATE ${RTOSC_TEST_LIB_DIR}) 86 endif() 87 88 add_executable(save-osc SaveOSC.cpp) 89 if(LIBGIT2_FOUND) 90 target_include_directories(save-osc PRIVATE ${LIBGIT2_INCLUDE_DIRS}) 91 target_link_libraries(save-osc 92 zynaddsubfx_core zynaddsubfx_nio 93 zynaddsubfx_gui_bridge 94 ${GUI_LIBRARIES} ${NIO_LIBRARIES} ${AUDIO_LIBRARIES} 95 ${LIBGIT2_LIBRARIES} 96 ${PLATFORM_LIBRARIES}) 97 else() 98 target_compile_definitions(save-osc PRIVATE -DZYN_GIT_WORKTREE="${CMAKE_SOURCE_DIR}") 99 target_link_libraries(save-osc 100 zynaddsubfx_core zynaddsubfx_nio 101 zynaddsubfx_gui_bridge 102 ${GUI_LIBRARIES} ${NIO_LIBRARIES} ${AUDIO_LIBRARIES} 103 ${PLATFORM_LIBRARIES}) 104 endif() 105 # test all presets 106 add_test(SaveOscPresets save-osc) 107 # test the most insane XIZ file 108 add_test(SaveOscBigFile save-osc ${CMAKE_CURRENT_SOURCE_DIR}/../../instruments/banks/olivers-100/0032-Drum\ Kit.xiz) 109 # not realized, because it takes 15 minutes each time: 110 if (CompileExtensiveTests) 111 add_test(SaveOscAllFiles save-osc test-all) 112 endif() 113 114 endif() 115 116 if(CMAKE_SYSTEM_NAME STREQUAL "Linux") 117 execute_process( 118 COMMAND git rev-parse --is-inside-work-tree 119 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} 120 OUTPUT_VARIABLE IS_GIT_REPO 121 ERROR_QUIET 122 OUTPUT_STRIP_TRAILING_WHITESPACE 123 ) 124 if(IS_GIT_REPO STREQUAL "true") 125 add_test(TrailingWhitespace ${CMAKE_SOURCE_DIR}/src/Tests/trailing-whitespace) 126 endif() 127 endif() 128