Skip to content

Commit c7820c7

Browse files
committed
update CMakeLists.txt, README.md and docs/index.md
1 parent 0262601 commit c7820c7

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

CMakeLists.txt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ include(GenerateExportHeader)
1212
include(FetchContent)
1313
include(CTest)
1414

15-
cmake_dependent_option(BUILD_TESTING
16-
"Build the unit tests when BUILD_TESTING is enabled and we are the root project" OFF
17-
"BUILD_TESTING;CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR" OFF)
18-
1915
message("Generated with config types: ${CMAKE_CONFIGURATION_TYPES}")
2016

2117
set(CMAKE_CONFIGURATION_TYPES=Debug;Release)
@@ -94,8 +90,14 @@ endif()
9490
target_include_directories(raii AFTER PUBLIC
9591
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
9692
target_link_libraries(coroutine PUBLIC raii)
97-
if(BUILD_TESTING)
98-
add_subdirectory(examples)
93+
94+
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
95+
option(BUILD_EXAMPLES "whether or not examples should be built" ON)
96+
97+
if(BUILD_EXAMPLES)
98+
enable_testing()
99+
add_subdirectory(examples)
100+
endif()
99101
endif()
100102

101103
set(_fmt TGZ)

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ The build system uses **cmake**, that produces _single_ **static** library store
744744
```shell
745745
mkdir build
746746
cd build
747-
cmake .. -DCMAKE_BUILD_TYPE=Debug/Release -DBUILD_TESTING=ON # use to build files in examples folder
747+
cmake .. -DCMAKE_BUILD_TYPE=Debug/Release -DBUILD_EXAMPLES=ON # use to build files in examples folder
748748
cmake --build .
749749
```
750750

@@ -753,7 +753,7 @@ cmake --build .
753753
```shell
754754
mkdir build
755755
cd build
756-
cmake .. -D BUILD_TESTING=ON # use to build files in examples folder
756+
cmake .. -D BUILD_EXAMPLES=ON # use to build files in examples folder
757757
cmake --build . --config Debug/Release
758758
```
759759

docs/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,7 @@ The build system uses **cmake**, that produces _single_ **static** library store
10271027
```shell
10281028
mkdir build
10291029
cd build
1030-
cmake .. -DCMAKE_BUILD_TYPE=Debug/Release -DBUILD_TESTING=ON # use to build files in examples folder
1030+
cmake .. -DCMAKE_BUILD_TYPE=Debug/Release -DBUILD_EXAMPLES=ON # use to build files in examples folder
10311031
cmake --build .
10321032
```
10331033

@@ -1036,7 +1036,7 @@ cmake --build .
10361036
```shell
10371037
mkdir build
10381038
cd build
1039-
cmake .. -D BUILD_TESTING=ON # use to build files in examples folder
1039+
cmake .. -D BUILD_EXAMPLES=ON # use to build files in examples folder
10401040
cmake --build . --config Debug/Release
10411041
```
10421042

0 commit comments

Comments
 (0)