From 6d537f97bf2d0aea8c24cba22e11b75dfb63bfed Mon Sep 17 00:00:00 2001 From: HJA Bird Date: Mon, 9 Sep 2019 17:04:42 +0100 Subject: [PATCH] Linking stdmaths with Clang --- CMakeLists.txt | 4 ++-- test/CMakeLists.txt | 11 +++-------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a93781d..9dc6d0d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,8 +53,8 @@ find_package(bsv CONFIG REQUIRED) target_link_libraries(cvortex PUBLIC bsv) target_include_directories(cvortex PUBLIC bsv) -if (${CMAKE_C_COMPILER_ID} STREQUAL "GNU") - link_libraries(cvortex m) # Maths std library. +if (${CMAKE_C_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_C_COMPILER_ID} STREQUAL "Clang") + target_link_libraries(cvortex PUBLIC m) # Maths std library. endif() set_property(TARGET cvortex PROPERTY FOLDER "libraries") diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8067b26..d3b053d 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,19 +1,14 @@ cmake_minimum_required(VERSION 3.1) -link_libraries(cvortex) -link_libraries(bsv) -if (${CMAKE_C_COMPILER_ID} STREQUAL "GNU") - link_libraries(m) # Maths std library. -endif() - # Find all of our tests sources file (GLOB TESTCVTX_SOURCE "*.[ch]") source_group("cvtx_test_source" FILES ${TESTCVTX_SOURCE}) +add_executable(all_tests ${TESTCVTX_SOURCE}) +target_link_libraries(all_tests PUBLIC cvortex) +target_link_libraries(all_tests PUBLIC bsv) -# And add the main as an executable ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ enable_testing() -add_executable(all_tests ${TESTCVTX_SOURCE}) target_compile_definitions(all_tests PRIVATE _CRT_SECURE_NO_WARNINGS)