CMakeLists.txt 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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 our binary dir to find Table.h
  17. target_include_directories(MathFunctions
  18. INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}
  19. PRIVATE ${CMAKE_CURRENT_BINARY_DIR}
  20. )
  21. # use compile definitions to state if we have enabled USE_MYMATH
  22. # and that anything that links to use will get this define
  23. target_compile_definitions(MathFunctions INTERFACE "USE_MYMATH")
  24. # does this system provide the log and exp functions?
  25. include(CheckSymbolExists)
  26. set(CMAKE_REQUIRED_LIBRARIES "m")
  27. check_symbol_exists(log "math.h" HAVE_LOG)
  28. check_symbol_exists(exp "math.h" HAVE_EXP)
  29. if(HAVE_LOG AND HAVE_EXP)
  30. target_compile_definitions(MathFunctions
  31. PRIVATE "HAVE_LOG" "HAVE_EXP")
  32. endif()
  33. # install rules
  34. install(TARGETS MathFunctions DESTINATION lib)
  35. install(FILES MathFunctions.h DESTINATION include)