@@ -25,19 +25,34 @@ print_message("-------------------- COMPUTER SCIENCE --------------------")
2525project (computer-science
2626 VERSION 1.0
2727 DESCRIPTION "Computer Science (c) 2023-2025 Dmitry Savchenkov"
28+ HOMEPAGE_URL "https://github.com/dvsav/computer-science"
2829 LANGUAGES CXX )
2930
30- # Require at least C++17
31- set (CMAKE_CXX_STANDARD 17) # Sets the desired C++ standard (e.g., 17 for C++17).
32- set (CMAKE_CXX_STANDARD_REQUIRED ON ) # Ensures the compiler must support the specified standard, not an older one.
33- set (CMAKE_CXX_EXTENSIONS OFF ) # Optional: disables compiler-specific extensions like GNU++17
34-
35- # the repository's root is two folders higher than this CMakeLists file
31+ # # Sets the required C++ standard (C++17 in our case) across all of the targets in this CMakeLists file
32+ # Sets the desired C++ standard (e.g., 17 for C++17)
33+ # (https://cmake.org/cmake/help/latest/variable/CMAKE_CXX_STANDARD.html#cmake-cxx-standard).
34+ set (CMAKE_CXX_STANDARD 17)
35+ # Ensures the compiler must support the specified standard, not an older one
36+ # (https://cmake.org/cmake/help/latest/prop_tgt/CXX_STANDARD_REQUIRED.html).
37+ set (CMAKE_CXX_STANDARD_REQUIRED ON )
38+ # Optional: disables compiler-specific extensions like GNU++17
39+ # (https://cmake.org/cmake/help/latest/variable/CMAKE_CXX_EXTENSIONS.html#cmake-cxx-extensions)
40+ set (CMAKE_CXX_EXTENSIONS OFF )
41+
42+ # Alternatively we could have set the required C++ standard for a particular build target
43+ # target_compile_features(${PROJECT_NAME} PUBLIC c_std_17)
44+
45+ # Store the paths to some interesting directories in variables
46+ # (the repository's root is two folders higher than this CMakeLists file)
3647set (ROOT_DIR "${PROJECT_SOURCE_DIR} /../.." )
3748set (SRC_DIR "${ROOT_DIR} /src" )
3849set (TEST_DIR "${ROOT_DIR} /test" )
3950
40- # collect the source and header files
51+ # Collect the source and header files.
52+ # Without CONFIGURE_DEPENDS CMake doesn't rerun file globbing procedure during build time (cmake --build),
53+ # So without CONFIGURE_DEPENDS you need to manually regenerate (cmake -B) whenever you add any new source files
54+ # (https://cmake.org/cmake/help/latest/command/file.html).
55+ # Note that we are collecting both source and header files to be able to see them, for example, in Visual Studio project explorer.
4156file (GLOB SOURCE_FILES CONFIGURE_DEPENDS
4257 "${SRC_DIR} /*.cpp"
4358 "${SRC_DIR} /*.h" )
@@ -46,7 +61,7 @@ foreach (file ${SOURCE_FILES})
4661 print_message ("source file = ${file} " )
4762endforeach ()
4863
49- # defines the executable file name (target) and its dependencies
64+ # Defines a build target - the executable file and its dependencies (the source files collected above)
5065add_executable (${PROJECT_NAME} ${SOURCE_FILES} )
5166
5267if (VISUAL_STUDIO)
0 commit comments