From e2564d1ea83d327a94c503643e480def682564a0 Mon Sep 17 00:00:00 2001 From: Nigel Date: Mon, 30 Oct 2023 09:38:09 +0100 Subject: [PATCH] Excercise 3 - Step 1 --- Step1/CMakeLists.txt | 15 ++++++--------- Step1/TutorialConfig.h.in | 2 ++ Step1/tutorial.cxx | 5 ++--- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/Step1/CMakeLists.txt b/Step1/CMakeLists.txt index 9b2f09e..34b1011 100644 --- a/Step1/CMakeLists.txt +++ b/Step1/CMakeLists.txt @@ -1,14 +1,11 @@ cmake_minimum_required(VERSION 3.10) -project(Tutorial) -# TODO 7: Set the project version number as 1.0 in the above project command - -# TODO 6: Set the variable CMAKE_CXX_STANDARD to 11 -# and the variable CMAKE_CXX_STANDARD_REQUIRED to True +project( + Tutorial + VERSION 1.0 +) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED True) -# TODO 8: Use configure_file to configure and copy TutorialConfig.h.in to -# TutorialConfig.h - +configure_file(TutorialConfig.h.in TutorialConfig.h) add_executable(Tutorial tutorial.cxx) -# TODO 9: Use target_include_directories to include ${PROJECT_BINARY_DIR} +target_include_directories(Tutorial PUBLIC ${PROJECT_BINARY_DIR}) \ No newline at end of file diff --git a/Step1/TutorialConfig.h.in b/Step1/TutorialConfig.h.in index 990bfbd..c881068 100644 --- a/Step1/TutorialConfig.h.in +++ b/Step1/TutorialConfig.h.in @@ -1,2 +1,4 @@ // the configured options and settings for Tutorial // TODO 10: Define Tutorial_VERSION_MAJOR and Tutorial_VERSION_MINOR +#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@ +#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@ \ No newline at end of file diff --git a/Step1/tutorial.cxx b/Step1/tutorial.cxx index 1c4977e..30f1608 100644 --- a/Step1/tutorial.cxx +++ b/Step1/tutorial.cxx @@ -4,13 +4,12 @@ #include #include -// TODO 11: Include TutorialConfig.h +#include "TutorialConfig.h" int main(int argc, char* argv[]) { if (argc < 2) { - // TODO 12: Create a print statement using Tutorial_VERSION_MAJOR - // and Tutorial_VERSION_MINOR + std::cout << argv[0] << " V " << Tutorial_VERSION_MAJOR << "." << Tutorial_VERSION_MINOR << std::endl; std::cout << "Usage: " << argv[0] << " number" << std::endl; return 1; }