From 79457b8712d95bba6dd3c595e1ed23a0c945e351 Mon Sep 17 00:00:00 2001 From: Dominik Berner Date: Sun, 23 Jun 2024 17:50:52 +0000 Subject: [PATCH] Add simple example for chapter2 --- chapter02/CMakeLists.txt | 2 +- chapter02/simple_example/CMakeLists.txt | 19 +++++++++++++++++++ chapter02/simple_example/src/main.cpp | 6 ++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 chapter02/simple_example/CMakeLists.txt create mode 100644 chapter02/simple_example/src/main.cpp diff --git a/chapter02/CMakeLists.txt b/chapter02/CMakeLists.txt index 66ace2a..6211aa5 100644 --- a/chapter02/CMakeLists.txt +++ b/chapter02/CMakeLists.txt @@ -27,7 +27,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows") set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) endif() - +add_subdirectory(simple_example) add_subdirectory(component_interface) add_subdirectory(component1) add_subdirectory(component2) diff --git a/chapter02/simple_example/CMakeLists.txt b/chapter02/simple_example/CMakeLists.txt new file mode 100644 index 0000000..8885e9d --- /dev/null +++ b/chapter02/simple_example/CMakeLists.txt @@ -0,0 +1,19 @@ + +# CMakeLists file for the Chapter 2 example illustrating how to create a simple executable +# +# SPDX-License-Identifier: MIT + +cmake_minimum_required(VERSION 3.23) + +# Define a CMake project +project( + ch2_simple_example + VERSION 1.0 + DESCRIPTION "A simple C++ project to demonstrate basic CMake usage" + LANGUAGES CXX) + +# Add an executable target named `chapter2_simple_example` +add_executable(chapter2_simple_example) +# Add sources to the target `chapter2_simple_example` +target_sources(chapter2_simple_example PRIVATE src/main.cpp) + diff --git a/chapter02/simple_example/src/main.cpp b/chapter02/simple_example/src/main.cpp new file mode 100644 index 0000000..b1dae1c --- /dev/null +++ b/chapter02/simple_example/src/main.cpp @@ -0,0 +1,6 @@ +#include + +int main(int, char **) { + std::cout << "Welcome to CMake Best Practices\n"; + return 0; +} \ No newline at end of file