check if math library is available and include if present

This commit is contained in:
Krishna Vedala 2020-05-29 14:04:14 -04:00
parent 9165932928
commit b1e1923580
7 changed files with 16 additions and 25 deletions

View File

@ -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)

View File

@ -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} )

View File

@ -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")

View File

@ -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")

View File

@ -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")

View File

@ -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")

View File

@ -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")