CMakeLists.txt 1.1 KB

123456789101112131415161718192021222324252627282930313233
  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. # library that just does sqrt
  12. add_library(SqrtLibrary STATIC
  13. mysqrt.cxx
  14. )
  15. target_link_libraries(SqrtLibrary PUBLIC tutorial_compiler_flags)
  16. target_link_libraries(MathFunctions PRIVATE SqrtLibrary)
  17. endif()
  18. # link our compiler flags interface library
  19. target_link_libraries(MathFunctions PUBLIC tutorial_compiler_flags)
  20. # install libs
  21. set(installable_libs MathFunctions tutorial_compiler_flags)
  22. if(TARGET SqrtLibrary)
  23. list(APPEND installable_libs SqrtLibrary)
  24. endif()
  25. install(TARGETS ${installable_libs} DESTINATION lib)
  26. # install include headers
  27. install(FILES MathFunctions.h DESTINATION include)