1
0

CMakeLists.txt 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # first we add the executable that generates the table
  2. add_executable(MakeTable MakeTable.cxx)
  3. # add the command to generate the source code
  4. add_custom_command(
  5. OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Table.h
  6. COMMAND MakeTable ${CMAKE_CURRENT_BINARY_DIR}/Table.h
  7. DEPENDS MakeTable
  8. )
  9. # add the main library
  10. add_library(MathFunctions
  11. mysqrt.cxx
  12. ${CMAKE_CURRENT_BINARY_DIR}/Table.h
  13. )
  14. # state that anybody linking to us needs to include the current source dir
  15. # to find MathFunctions.h, while we don't.
  16. # state that we depend on Tutorial_BINARY_DIR but consumers don't, as the
  17. # TutorialConfig.h include is an implementation detail
  18. # state that we depend on our binary dir to find Table.h
  19. target_include_directories(MathFunctions
  20. INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}
  21. PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
  22. )
  23. # does this system provide the log and exp functions?
  24. include(CheckSymbolExists)
  25. set(CMAKE_REQUIRED_LIBRARIES "m")
  26. check_symbol_exists(log "math.h" HAVE_LOG)
  27. check_symbol_exists(exp "math.h" HAVE_EXP)
  28. if(HAVE_LOG AND HAVE_EXP)
  29. target_compile_definitions(MathFunctions
  30. PRIVATE "HAVE_LOG" "HAVE_EXP")
  31. endif()
  32. # install rules
  33. install(TARGETS MathFunctions DESTINATION lib)
  34. install(FILES MathFunctions.h DESTINATION include)