CMakeLists.txt 974 B

12345678910111213141516171819202122232425262728293031323334353637
  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. target_link_libraries(MathFunctions tutorial_compiler_flags)
  8. # does this system provide the log and exp functions?
  9. include(CheckCXXSourceCompiles)
  10. check_cxx_source_compiles("
  11. #include <cmath>
  12. int main() {
  13. std::log(1.0);
  14. return 0;
  15. }
  16. " HAVE_LOG)
  17. check_cxx_source_compiles("
  18. #include <cmath>
  19. int main() {
  20. std::exp(1.0);
  21. return 0;
  22. }
  23. " HAVE_EXP)
  24. # add compile definitions
  25. if(HAVE_LOG AND HAVE_EXP)
  26. target_compile_definitions(MathFunctions
  27. PRIVATE "HAVE_LOG" "HAVE_EXP")
  28. endif()
  29. # install rules
  30. set(installable_libs MathFunctions tutorial_compiler_flags)
  31. install(TARGETS ${installable_libs} DESTINATION lib)
  32. install(FILES MathFunctions.h DESTINATION include)