CMakeLists.txt 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # TODO 4: Update the minimum required version to 3.15
  2. cmake_minimum_required(VERSION 3.10)
  3. # set the project name and version
  4. project(Tutorial VERSION 1.0)
  5. # TODO 1: Replace the following code by:
  6. # * Creating an interface library called tutorial_compiler_flags
  7. # Hint: use add_library() with the INTERFACE signature
  8. # * Add compiler feature cxx_std_11 to tutorial_compiler_flags
  9. # Hint: Use target_compile_features()
  10. # specify the C++ standard
  11. set(CMAKE_CXX_STANDARD 11)
  12. set(CMAKE_CXX_STANDARD_REQUIRED True)
  13. # TODO 5: Create helper variables to determine which compiler we are using:
  14. # * Create a new variable gcc_like_cxx that is true if we are using CXX and
  15. # any of the following compilers: ARMClang, AppleClang, Clang, GNU, LCC
  16. # * Create a new variable msvc_cxx that is true if we are using CXX and MSVC
  17. # Hint: Use set() and COMPILE_LANG_AND_ID
  18. # TODO 6: Add warning flag compile options to the interface library
  19. # tutorial_compiler_flags.
  20. # * For gcc_like_cxx, add flags -Wall;-Wextra;-Wshadow;-Wformat=2;-Wunused
  21. # * For msvc_cxx, add flags -W3
  22. # Hint: Use target_compile_options()
  23. # TODO 7: With nested generator expressions, only use the flags for the
  24. # build-tree
  25. # Hint: Use BUILD_INTERFACE
  26. # should we use our own math functions
  27. option(USE_MYMATH "Use tutorial provided math implementation" ON)
  28. # configure a header file to pass some of the CMake settings
  29. # to the source code
  30. configure_file(TutorialConfig.h.in TutorialConfig.h)
  31. # add the MathFunctions library
  32. if(USE_MYMATH)
  33. add_subdirectory(MathFunctions)
  34. list(APPEND EXTRA_LIBS MathFunctions)
  35. endif()
  36. # add the executable
  37. add_executable(Tutorial tutorial.cxx)
  38. # TODO 2: Link to tutorial_compiler_flags
  39. target_link_libraries(Tutorial PUBLIC ${EXTRA_LIBS})
  40. # add the binary tree to the search path for include files
  41. # so that we will find TutorialConfig.h
  42. target_include_directories(Tutorial PUBLIC
  43. "${PROJECT_BINARY_DIR}"
  44. )