1
0

CMakeLists.txt 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. add_library(MathFunctions MathFunctions.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. # should we use our own math functions
  8. option(USE_MYMATH "Use tutorial provided math implementation" ON)
  9. if (USE_MYMATH)
  10. target_compile_definitions(MathFunctions PRIVATE "USE_MYMATH")
  11. # generate Table.h
  12. include(MakeTable.cmake)
  13. # library that just does sqrt
  14. add_library(SqrtLibrary STATIC
  15. mysqrt.cxx
  16. ${CMAKE_CURRENT_BINARY_DIR}/Table.h
  17. )
  18. # state that we depend on our binary dir to find Table.h
  19. target_include_directories(SqrtLibrary PRIVATE
  20. ${CMAKE_CURRENT_BINARY_DIR}
  21. )
  22. # link SqrtLibrary to tutorial_compiler_flags
  23. target_link_libraries(SqrtLibrary PUBLIC tutorial_compiler_flags)
  24. target_link_libraries(MathFunctions PRIVATE SqrtLibrary)
  25. endif()
  26. # link MathFunctions to tutorial_compiler_flags
  27. target_link_libraries(MathFunctions PUBLIC tutorial_compiler_flags)
  28. # install libs
  29. set(installable_libs MathFunctions tutorial_compiler_flags)
  30. if(TARGET SqrtLibrary)
  31. list(APPEND installable_libs SqrtLibrary)
  32. endif()
  33. install(TARGETS ${installable_libs} DESTINATION lib)
  34. # install include headers
  35. install(FILES MathFunctions.h DESTINATION include)