Skip to content

Commit

Permalink
MSVC: do not link with -lm
Browse files Browse the repository at this point in the history
...because the Internet says that math functions are directly in MSVCR.
  • Loading branch information
jktjkt authored and michalvasko committed Dec 16, 2021
1 parent f1960dc commit a3fe12a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,10 @@ endif()

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)
Expand Down
5 changes: 4 additions & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ function(ly_add_utest)

# 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}")
Expand Down
5 changes: 4 additions & 1 deletion tests/perf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ set(format_sources

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)

0 comments on commit a3fe12a

Please sign in to comment.