MSVC: do not link with -lm
...because the Internet says that math functions are directly in MSVCR.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c3ce0c9..272dd00 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -372,8 +372,10 @@
set_target_properties(yang PROPERTIES VERSION ${LIBYANG_SOVERSION_FULL} SOVERSION ${LIBYANG_SOVERSION})
-# link math
-target_link_libraries(yang m)
+if(NOT WIN32)
+ # link math
+ target_link_libraries(yang m)
+endif()
# find pthreads
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 1736abf..b68d934 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -17,7 +17,10 @@
# Set common attributes of all tests
set_target_properties(${TEST_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/tests")
- target_link_libraries(${TEST_NAME} ${CMOCKA_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${PCRE2_LIBRARIES} ${CMAKE_DL_LIBS} m)
+ target_link_libraries(${TEST_NAME} ${CMOCKA_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${PCRE2_LIBRARIES} ${CMAKE_DL_LIBS})
+ if (NOT WIN32)
+ target_link_libraries(${TEST_NAME} m)
+ endif()
if (NOT APPLE)
if (ADDTEST_WRAP)
set_target_properties(${TEST_NAME} PROPERTIES LINK_FLAGS "${ADDTEST_WRAP}")
diff --git a/tests/perf/CMakeLists.txt b/tests/perf/CMakeLists.txt
index b7f325c..ec1dfb5 100644
--- a/tests/perf/CMakeLists.txt
+++ b/tests/perf/CMakeLists.txt
@@ -5,7 +5,10 @@
add_executable(ly_perf ${CMAKE_CURRENT_SOURCE_DIR}/perf.c $<TARGET_OBJECTS:yangobj>)
set_target_properties(ly_perf PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/tests")
-target_link_libraries(ly_perf ${CMAKE_THREAD_LIBS_INIT} ${PCRE2_LIBRARIES} ${CMAKE_DL_LIBS} m)
+target_link_libraries(ly_perf ${CMAKE_THREAD_LIBS_INIT} ${PCRE2_LIBRARIES} ${CMAKE_DL_LIBS})
+if (NOT WIN32)
+ target_link_libraries(ly_perf m)
+endif()
add_test(NAME ly_perf_1000 COMMAND ly_perf 1000 10)
add_test(NAME ly_perf_100000 COMMAND ly_perf 100000 3)