...

/

Solution: Creating Our Professional Project

Solution: Creating Our Professional Project

Let's see the implementation of your professional project.

Task 1 Solution: Specify basic project details and add the src and test directories

Press + to interact
cmake_minimum_required(VERSION 3.25.1)
project(Calc VERSION 1.0.0 LANGUAGES CXX)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
include(NoInSourceBuilds)
add_subdirectory(src bin)
add_subdirectory(test)
include(Install)
  1. list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake"): This line appends a directory path ${CMAKE_SOURCE_DIR}/cmake to the CMAKE_MODULE_PATH variable. It's common to use this variable to specify additional paths where CMake should look for module files used in the project.

  2. include(NoInSourceBuilds): This line includes the NoInSourceBuilds module. This module likely provides functionality to prevent building the project directly in the source directory, promoting out-of-source builds. It's a good practice to build CMake projects in separate build directories to keep the source directory clean.

  3. add_subdirectory(src bin): This line adds the src and bin directories as subdirectories to the project. This means that CMake will search for CMakeLists.txt files in these directories and include them in the build process.

  4. add_subdirectory(test): This line adds the test directory as a subdirectory to the project. Similarly to the previous line, it includes the CMakeLists.txt file in the test directory in the build process.

  5. include(Install): This line includes the Install module, which likely contains installation-related commands and configurations. This module defines what files should be installed and where during the installation process. ...

Task 2 Solution: Add code for enabling test utility usage by two target