Skip to content

Commit

Permalink
force include math library for each target
Browse files Browse the repository at this point in the history
  • Loading branch information
kvedala committed May 29, 2020
1 parent e7b4a8c commit d4f202c
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 9 deletions.
6 changes: 0 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion conversions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
5 changes: 5 additions & 0 deletions misc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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} )
6 changes: 5 additions & 1 deletion numerical_methods/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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} )
6 changes: 5 additions & 1 deletion project_euler/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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} )
5 changes: 5 additions & 0 deletions searching/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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} )
5 changes: 5 additions & 0 deletions sorting/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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} )

0 comments on commit d4f202c

Please sign in to comment.