CMakeLists.txt 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. # TODO 1: 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. # specify the C++ standard
  6. add_library(tutorial_compiler_flags INTERFACE)
  7. target_compile_features(tutorial_compiler_flags INTERFACE cxx_std_11)
  8. # TODO 2: Create helper variables to determine which compiler we are using:
  9. # * Create a new variable gcc_like_cxx that is true if we are using CXX and
  10. # any of the following compilers: ARMClang, AppleClang, Clang, GNU, LCC
  11. # * Create a new variable msvc_cxx that is true if we are using CXX and MSVC
  12. # Hint: Use set() and COMPILE_LANG_AND_ID
  13. # TODO 3: Add warning flag compile options to the interface library
  14. # tutorial_compiler_flags.
  15. # * For gcc_like_cxx, add flags -Wall;-Wextra;-Wshadow;-Wformat=2;-Wunused
  16. # * For msvc_cxx, add flags -W3
  17. # Hint: Use target_compile_options()
  18. # TODO 4: With nested generator expressions, only use the flags for the
  19. # build-tree
  20. # Hint: Use BUILD_INTERFACE
  21. # configure a header file to pass some of the CMake settings
  22. # to the source code
  23. configure_file(TutorialConfig.h.in TutorialConfig.h)
  24. # add the MathFunctions library
  25. add_subdirectory(MathFunctions)
  26. # add the executable
  27. add_executable(Tutorial tutorial.cxx)
  28. target_link_libraries(Tutorial PUBLIC MathFunctions tutorial_compiler_flags)
  29. # add the binary tree to the search path for include files
  30. # so that we will find TutorialConfig.h
  31. target_include_directories(Tutorial PUBLIC
  32. "${PROJECT_BINARY_DIR}"
  33. )