diff --git a/CMakeLists.txt b/CMakeLists.txt index 34104262..03e5371d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,12 +46,6 @@ if(MSVC) add_compile_options(/Za) endif(MSVC) -if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - link_libraries(m) -elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - link_libraries(m) -endif() - add_subdirectory(conversions) add_subdirectory(misc) add_subdirectory(project_euler) diff --git a/conversions/CMakeLists.txt b/conversions/CMakeLists.txt index cf43f94f..d48b58a6 100644 --- a/conversions/CMakeLists.txt +++ b/conversions/CMakeLists.txt @@ -16,7 +16,11 @@ foreach( testsourcefile ${APP_SOURCES} ) if(OpenMP_C_FOUND) target_link_libraries(${testname} OpenMP::OpenMP_C) endif() - target_link_libraries(${testname} m) + if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + target_link_libraries(${testname} m) + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + target_link_libraries(${testname} m) + endif() install(TARGETS ${testname} DESTINATION "bin/conversions") diff --git a/misc/CMakeLists.txt b/misc/CMakeLists.txt index 2e335ccd..b2500be6 100644 --- a/misc/CMakeLists.txt +++ b/misc/CMakeLists.txt @@ -16,6 +16,11 @@ 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) + endif() install(TARGETS ${testname} DESTINATION "bin/misc") endforeach( testsourcefile ${APP_SOURCES} ) diff --git a/numerical_methods/CMakeLists.txt b/numerical_methods/CMakeLists.txt index 16757ce1..81000766 100644 --- a/numerical_methods/CMakeLists.txt +++ b/numerical_methods/CMakeLists.txt @@ -24,7 +24,11 @@ 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) + endif() install(TARGETS ${testname} DESTINATION "bin/numerical_methods") endforeach( testsourcefile ${APP_SOURCES} ) diff --git a/project_euler/CMakeLists.txt b/project_euler/CMakeLists.txt index bf86cca9..70f18faf 100644 --- a/project_euler/CMakeLists.txt +++ b/project_euler/CMakeLists.txt @@ -19,7 +19,11 @@ foreach( testsourcefile ${APP_SOURCES} ) if(OpenMP_C_FOUND) target_link_libraries(${testname} OpenMP::OpenMP_C) endif() - set_target_properties(${testname} PROPERTIES LINKER_LANGUAGE C) + if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + target_link_libraries(${testname} m) + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + target_link_libraries(${testname} m) + endif() install(TARGETS ${testname} DESTINATION "bin/misc") endforeach( testsourcefile ${APP_SOURCES} ) diff --git a/searching/CMakeLists.txt b/searching/CMakeLists.txt index 29e18413..3d29def6 100644 --- a/searching/CMakeLists.txt +++ b/searching/CMakeLists.txt @@ -16,6 +16,11 @@ 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) + endif() install(TARGETS ${testname} DESTINATION "bin/searching") endforeach( testsourcefile ${APP_SOURCES} ) diff --git a/sorting/CMakeLists.txt b/sorting/CMakeLists.txt index 91f35524..e361d575 100644 --- a/sorting/CMakeLists.txt +++ b/sorting/CMakeLists.txt @@ -16,6 +16,11 @@ 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) + endif() install(TARGETS ${testname} DESTINATION "bin/sorting") endforeach( testsourcefile ${APP_SOURCES} )