CMakeLists.txt 1008 B

1234567891011121314151617181920212223242526272829303132
  1. add_library(MathFunctions mysqrt.cxx)
  2. # state that anybody linking to us needs to include the current source dir
  3. # to find MathFunctions.h, while we don't.
  4. target_include_directories(MathFunctions
  5. INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}
  6. )
  7. # does this system provide the log and exp functions?
  8. include(CheckSymbolExists)
  9. check_symbol_exists(log "math.h" HAVE_LOG)
  10. check_symbol_exists(exp "math.h" HAVE_EXP)
  11. if(NOT (HAVE_LOG AND HAVE_EXP))
  12. unset(HAVE_LOG CACHE)
  13. unset(HAVE_EXP CACHE)
  14. set(CMAKE_REQUIRED_LIBRARIES "m")
  15. check_symbol_exists(log "math.h" HAVE_LOG)
  16. check_symbol_exists(exp "math.h" HAVE_EXP)
  17. if(HAVE_LOG AND HAVE_EXP)
  18. target_link_libraries(MathFunctions PRIVATE m)
  19. endif()
  20. endif()
  21. # add compile definitions
  22. if(HAVE_LOG AND HAVE_EXP)
  23. target_compile_definitions(MathFunctions
  24. PRIVATE "HAVE_LOG" "HAVE_EXP")
  25. endif()
  26. # install rules
  27. install(TARGETS MathFunctions DESTINATION lib)
  28. install(FILES MathFunctions.h DESTINATION include)