diff --git a/CMakeLists.txt b/CMakeLists.txt index 8773c35f..3581cdde 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,6 +50,7 @@ add_custom_target(clap-tests) if (${CLAP_BUILD_TESTS}) message(STATUS "Including CLAP tests, compile tests, and versions") + include(CheckIncludeFile) macro(clap_compile_cpp SUFFIX EXT STDC STDCPP) add_executable(clap-compile-${SUFFIX} EXCLUDE_FROM_ALL src/main.${EXT}) @@ -84,11 +85,17 @@ if (${CLAP_BUILD_TESTS}) clap_compile_cpp(cpp17 cc 17 17) clap_compile_cpp(cpp20 cc 17 20) + check_include_file(threads.h CLAP_HAS_THREADS_H) + add_library(clap-plugin-template MODULE EXCLUDE_FROM_ALL src/plugin-template.c) target_link_libraries(clap-plugin-template PRIVATE clap) set_target_properties(clap-plugin-template PROPERTIES C_STANDARD 11) add_dependencies(clap-tests clap-plugin-template) + if(CLAP_HAS_THREADS_H) + target_compile_definitions(clap-plugin-template PRIVATE CLAP_HAS_THREADS_H) + endif() + if(CMAKE_SYSTEM_NAME STREQUAL "Linux") target_link_libraries(clap-plugin-template PRIVATE -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/src/linux-my_plug.version) target_link_libraries(clap-plugin-template PRIVATE -Wl,-z,defs) diff --git a/src/plugin-template.c b/src/plugin-template.c index de9620b2..8436815c 100644 --- a/src/plugin-template.c +++ b/src/plugin-template.c @@ -8,7 +8,7 @@ #include #include -#if __STDC_VERSION__ >= 201112L && !defined(__STDC_NO_THREADS__) && !defined(_MSC_VER) +#if __STDC_VERSION__ >= 201112L && !defined (__STDC_NO_THREADS__) && defined (CLAP_HAS_THREADS_H) # define CLAP_HAS_THREAD # include #endif