Skip to content

Commit

Permalink
Add more comments to chapter 14 example
Browse files Browse the repository at this point in the history
  • Loading branch information
bernedom committed Apr 30, 2022
1 parent 9c971be commit 3fd7488
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
8 changes: 5 additions & 3 deletions chapter14/precompiled_headers/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# CMakeLists creating a simple executable
# Chapter 14 example to illustrate the creation and use of precompiled headers
#
# SPDX-License-Identifier: MIT

Expand All @@ -8,19 +8,21 @@ project(
ch14_precompiled_headers
VERSION 1.0
DESCRIPTION
"A simple C++ project to demonstrate creating a standalone executables"
"A simple C++ project to demonstrate creating precompiled headers"
LANGUAGES CXX
)


# Create an executable target
add_executable(ch14_precompiled_headers)

# Add sources to the executable target
target_sources(ch14_precompiled_headers PRIVATE
src/main.cpp
src/fibonacci.cpp
src/eratosthenes.cpp
src/pythagoras.cpp
)

# Add headers to the generated precompiled header for target ch14_precompiled_headers
target_precompile_headers(ch14_precompiled_headers PRIVATE
src/fibonacci.h <cstdint> <vector> src/eratosthenes.h)
9 changes: 6 additions & 3 deletions chapter14/unity_build/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# CMakeLists creating a simple executable
# Chapter 14 example to illustrate unity builds in batch mode
#
# SPDX-License-Identifier: MIT

Expand All @@ -8,11 +8,11 @@ project(
ch14_unity_build
VERSION 1.0
DESCRIPTION
"A simple C++ project to demonstrate creating a standalone executables"
"A simple C++ project to demonstrate unity-builds"
LANGUAGES CXX
)


# Create an executable target
add_executable(ch14_unity_build)
target_compile_features(ch14_unity_build PRIVATE cxx_std_11)

Expand All @@ -21,6 +21,9 @@ target_sources(ch14_unity_build PRIVATE
src/fibonacci.cpp
src/eratosthenes.cpp
)
# Enable unity build for the target, by default BATCH mode is used
set_target_properties(ch14_unity_build PROPERTIES UNITY_BUILD True)

# exclude eratosthenes.cpp from the unity build
set_source_files_properties(src/eratosthenes.cpp PROPERTIES
SKIP_UNITY_BUILD_INCLUSION YES)
12 changes: 9 additions & 3 deletions chapter14/unity_build_group/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# CMakeLists creating a simple executable
# Chapter 14, example to illustrate group mode for unity builds
#
# SPDX-License-Identifier: MIT

Expand All @@ -8,7 +8,7 @@ project(
ch14_unity_build_group
VERSION 1.0
DESCRIPTION
"A simple C++ project to demonstrate creating a standalone executables"
"A simple C++ project to demonstrate unity build group modes"
LANGUAGES CXX
)

Expand All @@ -23,8 +23,14 @@ target_sources(ch14_unity_build_group PRIVATE
)
target_compile_features(ch14_unity_build_group PRIVATE cxx_std_11)

set_target_properties(ch14_unity_build_group PROPERTIES UNITY_BUILD_MODE GROUP)
# Enable unity build for the target
# by default BATCH mode is used for unity builds, so the build mode is changed to GROUP
set_target_properties(ch14_unity_build_group PROPERTIES
UNITY_BUILD True
UNITY_BUILD_MODE GROUP)

# Add main.cpp and fibonacci.cpp to the unuty group1
set_source_files_properties(src/main.cpp src/fibonacci.cpp PROPERTIES UNITY_GROUP group1)

# add erathostenes.cpp and pythagoras.cpp to group2
set_source_files_properties(src/erathostenes.cpp src/pythagoras.cpp PROPERTIES UNITY_GROUP group2)

0 comments on commit 3fd7488

Please sign in to comment.