CMakeLists.txt 846 B

12345678910111213141516171819202122232425262728293031323334
  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(CheckCXXSourceCompiles)
  9. check_cxx_source_compiles("
  10. #include <cmath>
  11. int main() {
  12. std::log(1.0);
  13. return 0;
  14. }
  15. " HAVE_LOG)
  16. check_cxx_source_compiles("
  17. #include <cmath>
  18. int main() {
  19. std::exp(1.0);
  20. return 0;
  21. }
  22. " HAVE_EXP)
  23. # add compile definitions
  24. if(HAVE_LOG AND HAVE_EXP)
  25. target_compile_definitions(MathFunctions
  26. PRIVATE "HAVE_LOG" "HAVE_EXP")
  27. endif()
  28. # install rules
  29. install(TARGETS MathFunctions DESTINATION lib)
  30. install(FILES MathFunctions.h DESTINATION include)