Skip to content

Commit d0cd359

Browse files
committed
Scoped CMake options
1 parent 67ff040 commit d0cd359

File tree

1 file changed

+47
-45
lines changed

1 file changed

+47
-45
lines changed

CMakeLists.txt

Lines changed: 47 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -63,61 +63,63 @@ function(discover_specs spec_folder)
6363
endforeach()
6464
endfunction(discover_specs)
6565

66-
option(BUILD_TESTS "Build tests" OFF)
66+
# OPTIONS
67+
option(CPPSPEC_BUILD_TESTS "Build C++Spec tests" OFF)
68+
option(CPPSPEC_BUILD_EXAMPLES "Build C++Spec examples" OFF)
69+
option(CPPSPEC_BUILD_DOCS "Build C++Spec documentation" OFF)
6770

68-
if(BUILD_TESTS)
71+
if(CPPSPEC_BUILD_TESTS)
6972
enable_testing()
7073

7174
# Tests
7275
discover_specs(spec)
73-
endif(BUILD_TESTS)
76+
endif(CPPSPEC_BUILD_TESTS)
7477

75-
option(BUILD_EXAMPLES "Build examples" OFF)
76-
77-
if(BUILD_EXAMPLES)
78+
if(CPPSPEC_BUILD_EXAMPLES)
7879
add_subdirectory(examples)
79-
endif(BUILD_EXAMPLES)
80+
endif(CPPSPEC_BUILD_EXAMPLES)
8081

81-
# ##### Documentation generation #######
82-
# check if Doxygen is installed
83-
find_package(Doxygen
82+
##### Documentation generation #######
83+
if(CPPSPEC_BUILD_DOCS)
84+
find_package(Doxygen
8485
OPTIONAL_COMPONENTS dot mscgen dia
85-
)
86+
)
8687

87-
if(DOXYGEN_FOUND)
88-
if(NOT ${DOXYGEN_HAVE_DOT})
89-
message(
90-
"Can't find GraphViz DOT tool for generating images."
91-
"Make sure it's on your PATH or install GraphViz")
92-
endif()
88+
if(DOXYGEN_FOUND)
89+
if(NOT ${DOXYGEN_HAVE_DOT})
90+
message(
91+
"Can't find GraphViz DOT tool for generating images."
92+
"Make sure it's on your PATH or install GraphViz")
93+
endif()
9394

94-
FetchContent_Declare(doxygen-awesome-css
95+
FetchContent_Declare(doxygen-awesome-css
9596
URL https://github.com/jothepro/doxygen-awesome-css/archive/refs/tags/v2.2.1.tar.gz
9697
URL_HASH MD5=340d3a206794ac01a91791c2a513991f
97-
)
98-
FetchContent_MakeAvailable(doxygen-awesome-css)
99-
100-
set(DOXYGEN_PROJECT_NAME "C++Spec")
101-
set(DOXYGEN_PROJECT_BRIEF "BDD testing for C++")
102-
set(DOXYGEN_RECURSIVE YES)
103-
set(DOXYGEN_EXAMPLE_RECURSIVE YES)
104-
set(DOXYGEN_EXCLUDE_PATTERNS "*/cxx-prettyprint/*")
105-
set(DOXYGEN_NUM_PROC_THREADS ${HOST_NUM_CORES})
106-
107-
# From doxygen-awesome
108-
set(DOXYGEN_GENERATE_TREEVIEW YES)
109-
set(DOXYGEN_DISABLE_INDEX NO)
110-
set(DOXYGEN_FULL_SIDEBAR NO)
111-
set(DOXYGEN_HTML_COLORSTYLE LIGHT)
112-
set(DOXYGEN_HTML_EXTRA_STYLESHEET "${doxygen-awesome-css_SOURCE_DIR}/doxygen-awesome.css")
113-
114-
set(DOXYGEN_USE_MDFILE_AS_MAINPAGE README.md)
115-
116-
file(GLOB markdown_SOURCES *.md)
117-
118-
doxygen_add_docs(doxygen ${markdown_SOURCES} include)
119-
else(DOXYGEN_FOUND)
120-
message(WARNING
121-
"Doxygen needs to be installed to generate documentation."
122-
"Please install from https://github.com/doxygen/doxygen/releases")
123-
endif(DOXYGEN_FOUND)
98+
)
99+
FetchContent_MakeAvailable(doxygen-awesome-css)
100+
101+
set(DOXYGEN_PROJECT_NAME "C++Spec")
102+
set(DOXYGEN_PROJECT_BRIEF "BDD testing for C++")
103+
set(DOXYGEN_RECURSIVE YES)
104+
set(DOXYGEN_EXAMPLE_RECURSIVE YES)
105+
set(DOXYGEN_EXCLUDE_PATTERNS "*/cxx-prettyprint/*")
106+
set(DOXYGEN_NUM_PROC_THREADS ${HOST_NUM_CORES})
107+
108+
# From doxygen-awesome
109+
set(DOXYGEN_GENERATE_TREEVIEW YES)
110+
set(DOXYGEN_DISABLE_INDEX NO)
111+
set(DOXYGEN_FULL_SIDEBAR NO)
112+
set(DOXYGEN_HTML_COLORSTYLE LIGHT)
113+
set(DOXYGEN_HTML_EXTRA_STYLESHEET "${doxygen-awesome-css_SOURCE_DIR}/doxygen-awesome.css")
114+
115+
set(DOXYGEN_USE_MDFILE_AS_MAINPAGE README.md)
116+
117+
file(GLOB markdown_SOURCES *.md)
118+
119+
doxygen_add_docs(doxygen ${markdown_SOURCES} include)
120+
else(DOXYGEN_FOUND)
121+
message(WARNING
122+
"Doxygen needs to be installed to generate documentation."
123+
"Please install from https://github.com/doxygen/doxygen/releases")
124+
endif(DOXYGEN_FOUND)
125+
endif(CPPSPEC_BUILD_DOCS)

0 commit comments

Comments
 (0)