diff --git a/CMakeLists.txt b/CMakeLists.txt index 03e5371d..20ab85a0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,6 +46,8 @@ if(MSVC) add_compile_options(/Za) endif(MSVC) +find_library(MATH_LIBRARY m) + add_subdirectory(conversions) add_subdirectory(misc) add_subdirectory(project_euler) diff --git a/conversions/CMakeLists.txt b/conversions/CMakeLists.txt index d48b58a6..6ff51c3f 100644 --- a/conversions/CMakeLists.txt +++ b/conversions/CMakeLists.txt @@ -16,12 +16,9 @@ foreach( testsourcefile ${APP_SOURCES} ) if(OpenMP_C_FOUND) target_link_libraries(${testname} OpenMP::OpenMP_C) endif() - if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - target_link_libraries(${testname} m) - elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - target_link_libraries(${testname} m) + if(MATH_LIBRARY) + target_link_libraries(${testname} ${MATH_LIBRARY}) endif() - install(TARGETS ${testname} DESTINATION "bin/conversions") endforeach( testsourcefile ${APP_SOURCES} ) diff --git a/misc/CMakeLists.txt b/misc/CMakeLists.txt index b2500be6..6a7dd981 100644 --- a/misc/CMakeLists.txt +++ b/misc/CMakeLists.txt @@ -16,10 +16,8 @@ foreach( testsourcefile ${APP_SOURCES} ) if(OpenMP_C_FOUND) target_link_libraries(${testname} OpenMP::OpenMP_C) endif() - if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - target_link_libraries(${testname} m) - elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - target_link_libraries(${testname} m) + if(MATH_LIBRARY) + target_link_libraries(${testname} ${MATH_LIBRARY}) endif() install(TARGETS ${testname} DESTINATION "bin/misc") diff --git a/numerical_methods/CMakeLists.txt b/numerical_methods/CMakeLists.txt index 81000766..945fd99f 100644 --- a/numerical_methods/CMakeLists.txt +++ b/numerical_methods/CMakeLists.txt @@ -24,10 +24,9 @@ foreach( testsourcefile ${APP_SOURCES} ) if(OpenMP_C_FOUND) target_link_libraries(${testname} OpenMP::OpenMP_C) endif() - if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - target_link_libraries(${testname} m) - elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - target_link_libraries(${testname} m) + + if(MATH_LIBRARY) + target_link_libraries(${testname} ${MATH_LIBRARY}) endif() install(TARGETS ${testname} DESTINATION "bin/numerical_methods") diff --git a/project_euler/CMakeLists.txt b/project_euler/CMakeLists.txt index 70f18faf..1e896582 100644 --- a/project_euler/CMakeLists.txt +++ b/project_euler/CMakeLists.txt @@ -19,10 +19,9 @@ foreach( testsourcefile ${APP_SOURCES} ) if(OpenMP_C_FOUND) target_link_libraries(${testname} OpenMP::OpenMP_C) endif() - if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - target_link_libraries(${testname} m) - elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - target_link_libraries(${testname} m) + + if(MATH_LIBRARY) + target_link_libraries(${testname} ${MATH_LIBRARY}) endif() install(TARGETS ${testname} DESTINATION "bin/misc") diff --git a/searching/CMakeLists.txt b/searching/CMakeLists.txt index 3d29def6..f51852b5 100644 --- a/searching/CMakeLists.txt +++ b/searching/CMakeLists.txt @@ -16,10 +16,8 @@ foreach( testsourcefile ${APP_SOURCES} ) if(OpenMP_C_FOUND) target_link_libraries(${testname} OpenMP::OpenMP_C) endif() - if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - target_link_libraries(${testname} m) - elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - target_link_libraries(${testname} m) + if(MATH_LIBRARY) + target_link_libraries(${testname} ${MATH_LIBRARY}) endif() install(TARGETS ${testname} DESTINATION "bin/searching") diff --git a/sorting/CMakeLists.txt b/sorting/CMakeLists.txt index e361d575..e3ff0d66 100644 --- a/sorting/CMakeLists.txt +++ b/sorting/CMakeLists.txt @@ -16,10 +16,8 @@ foreach( testsourcefile ${APP_SOURCES} ) if(OpenMP_C_FOUND) target_link_libraries(${testname} OpenMP::OpenMP_C) endif() - if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - target_link_libraries(${testname} m) - elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - target_link_libraries(${testname} m) + if(MATH_LIBRARY) + target_link_libraries(${testname} ${MATH_LIBRARY}) endif() install(TARGETS ${testname} DESTINATION "bin/sorting")