Skip to content

Commit a3fe12a

Browse files
jktjktmichalvasko
authored andcommitted
MSVC: do not link with -lm
...because the Internet says that math functions are directly in MSVCR.
1 parent f1960dc commit a3fe12a

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

CMakeLists.txt

+4-2
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,10 @@ endif()
372372

373373
set_target_properties(yang PROPERTIES VERSION ${LIBYANG_SOVERSION_FULL} SOVERSION ${LIBYANG_SOVERSION})
374374

375-
# link math
376-
target_link_libraries(yang m)
375+
if(NOT WIN32)
376+
# link math
377+
target_link_libraries(yang m)
378+
endif()
377379

378380
# find pthreads
379381
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)

tests/CMakeLists.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ function(ly_add_utest)
1717

1818
# Set common attributes of all tests
1919
set_target_properties(${TEST_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/tests")
20-
target_link_libraries(${TEST_NAME} ${CMOCKA_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${PCRE2_LIBRARIES} ${CMAKE_DL_LIBS} m)
20+
target_link_libraries(${TEST_NAME} ${CMOCKA_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${PCRE2_LIBRARIES} ${CMAKE_DL_LIBS})
21+
if (NOT WIN32)
22+
target_link_libraries(${TEST_NAME} m)
23+
endif()
2124
if (NOT APPLE)
2225
if (ADDTEST_WRAP)
2326
set_target_properties(${TEST_NAME} PROPERTIES LINK_FLAGS "${ADDTEST_WRAP}")

tests/perf/CMakeLists.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ set(format_sources
55

66
add_executable(ly_perf ${CMAKE_CURRENT_SOURCE_DIR}/perf.c $<TARGET_OBJECTS:yangobj>)
77
set_target_properties(ly_perf PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/tests")
8-
target_link_libraries(ly_perf ${CMAKE_THREAD_LIBS_INIT} ${PCRE2_LIBRARIES} ${CMAKE_DL_LIBS} m)
8+
target_link_libraries(ly_perf ${CMAKE_THREAD_LIBS_INIT} ${PCRE2_LIBRARIES} ${CMAKE_DL_LIBS})
9+
if (NOT WIN32)
10+
target_link_libraries(ly_perf m)
11+
endif()
912

1013
add_test(NAME ly_perf_1000 COMMAND ly_perf 1000 10)
1114
add_test(NAME ly_perf_100000 COMMAND ly_perf 100000 3)

0 commit comments

Comments
 (0)