Skip to content

Commit

Permalink
check if math library is available and include if present
Browse files Browse the repository at this point in the history
  • Loading branch information
kvedala committed May 29, 2020
1 parent 9165932 commit b1e1923
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 25 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 2 additions & 5 deletions conversions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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} )
6 changes: 2 additions & 4 deletions misc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
7 changes: 3 additions & 4 deletions numerical_methods/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
7 changes: 3 additions & 4 deletions project_euler/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
6 changes: 2 additions & 4 deletions searching/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
6 changes: 2 additions & 4 deletions sorting/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down

0 comments on commit b1e1923

Please sign in to comment.