CMakeLists.txt 930 B

123456789101112131415161718192021222324252627
  1. # create the MathFunctions library
  2. add_library(MathFunctions MathFunctions.cxx)
  3. # state that anybody linking to us needs to include the current source dir
  4. # to find MathFunctions.h, while we don't.
  5. target_include_directories(MathFunctions
  6. INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}
  7. )
  8. # should we use our own math functions
  9. option(USE_MYMATH "Use tutorial provided math implementation" ON)
  10. if (USE_MYMATH)
  11. target_compile_definitions(MathFunctions PRIVATE "USE_MYMATH")
  12. # library that just does sqrt
  13. add_library(SqrtLibrary STATIC
  14. mysqrt.cxx
  15. )
  16. # link SqrtLibrary to tutorial_compiler_flags
  17. target_link_libraries(SqrtLibrary PUBLIC tutorial_compiler_flags)
  18. target_link_libraries(MathFunctions PRIVATE SqrtLibrary)
  19. endif()
  20. # link MathFunctions to tutorial_compiler_flags
  21. target_link_libraries(MathFunctions PUBLIC tutorial_compiler_flags)