CMakeLists.txt 1018 B

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