Skip to content

Commit e96d591

Browse files
committed
Move examples from dev only to the general area
Consumers of the libraries might want to build the examples themselves to play around with, so it's better to them to the general area of the CML. It's still guarded by an option whose value depends on the dev mode by default, i.e. they are enabled the first time the project is configured in dev mode.
1 parent 219a567 commit e96d591

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

cmake-init/templates/header/CMakeLists.txt

+11-7
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,16 @@ target_compile_features(%(name)s_%(name)s INTERFACE cxx_std_%(std)s)
3434

3535
# ---- Install rules ----
3636

37-
include(cmake/install-rules.cmake)
37+
include(cmake/install-rules.cmake){if examples}
38+
39+
# ---- Examples ----
40+
41+
if(PROJECT_IS_TOP_LEVEL)
42+
option(BUILD_EXAMPLES "Build examples tree." "${%(name)s_DEVELOPER_MODE}")
43+
if(BUILD_EXAMPLES)
44+
add_subdirectory(example)
45+
endif()
46+
endif(){end}
3847

3948
# ---- Developer mode ----
4049

@@ -50,12 +59,7 @@ endif()
5059
include(CTest)
5160
if(BUILD_TESTING)
5261
add_subdirectory(test)
53-
endif(){if examples}
54-
55-
option(BUILD_EXAMPLES "Build examples tree." ON)
56-
if(BUILD_EXAMPLES)
57-
add_subdirectory(example)
58-
endif(){end}
62+
endif()
5963

6064
option(BUILD_DOCUMENTATION "Build documentation using Doxygen and m.css" OFF)
6165
if(BUILD_DOCUMENTATION)

cmake-init/templates/shared/CMakeLists.txt

+11-7
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,16 @@ target_compile_features(%(name)s_%(name)s PUBLIC cxx_std_%(std)s)
5555

5656
# ---- Install rules ----
5757

58-
include(cmake/install-rules.cmake)
58+
include(cmake/install-rules.cmake){if examples}
59+
60+
# ---- Examples ----
61+
62+
if(PROJECT_IS_TOP_LEVEL)
63+
option(BUILD_EXAMPLES "Build examples tree." "${%(name)s_DEVELOPER_MODE}")
64+
if(BUILD_EXAMPLES)
65+
add_subdirectory(example)
66+
endif()
67+
endif(){end}
5968

6069
# ---- Developer mode ----
6170

@@ -71,12 +80,7 @@ endif()
7180
include(CTest)
7281
if(BUILD_TESTING)
7382
add_subdirectory(test)
74-
endif(){if examples}
75-
76-
option(BUILD_EXAMPLES "Build examples tree." ON)
77-
if(BUILD_EXAMPLES)
78-
add_subdirectory(example)
79-
endif(){end}
83+
endif()
8084

8185
option(BUILD_DOCUMENTATION "Build documentation using Doxygen and m.css" OFF)
8286
if(BUILD_DOCUMENTATION)

0 commit comments

Comments
 (0)