CMakeLists.txt 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  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. 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)