From 45b750a09af3ee2d3d5cac1cbb304a124d536566 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Schl=C3=B6mer?= Date: Wed, 22 Sep 2021 17:18:00 +0200 Subject: [PATCH 1/2] Update CMakeLists.txt Fix CMake 3.18 MSVC build issues described here https://github.com/microsoft/Azure-Kinect-Sensor-SDK/issues/1363 following this https://gitlab.kitware.com/cmake/cmake/-/issues/22356 Also removed the empty .lib appended to the linker. --- CMakeLists.txt | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6541f1b4..2bb464ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -199,11 +199,12 @@ set(LIBSOUNDIO_LIBS if(MSVC) set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Wall") - set(LIB_CFLAGS "/TP /W4") + set(LIB_CFLAGS "/W4") + set_property(SOURCE ${LIBSOUNDIO_SOURCES} PROPERTY LANGUAGE CXX) set(EXAMPLE_CFLAGS "/W4") set(TEST_CFLAGS "${LIB_CFLAGS}") set(TEST_LDFLAGS " ") - set(LIBM " ") + set(LIBM "") else() set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Werror -pedantic") set(LIB_CFLAGS "-std=c11 -fvisibility=hidden -Wall -Werror=strict-prototypes -Werror=old-style-definition -Werror=missing-prototypes -D_REENTRANT -D_POSIX_C_SOURCE=200809L -Wno-missing-braces") @@ -308,11 +309,20 @@ if(BUILD_TESTS) ) add_executable(latency "${libsoundio_SOURCE_DIR}/test/latency.c" ${LIBSOUNDIO_SOURCES}) + if(MSVC) + set_property(SOURCE "${libsoundio_SOURCE_DIR}/test/latency.c" PROPERTY LANGUAGE CXX) + endif() target_link_libraries(latency LINK_PUBLIC ${LIBSOUNDIO_LIBS} ${LIBM}) set_target_properties(latency PROPERTIES LINKER_LANGUAGE C COMPILE_FLAGS ${LIB_CFLAGS} ) + if(BUILD_DYNAMIC_LIBS) + target_link_libraries(latency libsoundio_shared ${LIBM}) + else() + target_link_libraries(latency libsoundio_static ${LIBSOUNDIO_LIBS} ${LIBM}) + endif() + add_executable(underflow test/underflow.c) set_target_properties(underflow PROPERTIES From 50aa5e89af09adde3017a0e83f93314af139830c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Schl=C3=B6mer?= Date: Wed, 22 Sep 2021 17:24:07 +0200 Subject: [PATCH 2/2] Update CMakeLists.txt --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2bb464ff..c8425f17 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -312,7 +312,6 @@ if(BUILD_TESTS) if(MSVC) set_property(SOURCE "${libsoundio_SOURCE_DIR}/test/latency.c" PROPERTY LANGUAGE CXX) endif() - target_link_libraries(latency LINK_PUBLIC ${LIBSOUNDIO_LIBS} ${LIBM}) set_target_properties(latency PROPERTIES LINKER_LANGUAGE C COMPILE_FLAGS ${LIB_CFLAGS}