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