Skip to content

Commit 8c6ab2d

Browse files
committed
docs: add test based modifier to readme [skip ci]
1 parent 49de1cc commit 8c6ab2d

File tree

1 file changed

+39
-5
lines changed

1 file changed

+39
-5
lines changed

README.md

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,55 @@ include(${_project_options_SOURCE_DIR}/Index.cmake)
3131
# Set the project name and language
3232
project(myproject LANGUAGES CXX C)
3333
34+
# Build Features
35+
option(FEATURE_TESTS "Enable the tests" OFF)
36+
if(FEATURE_TESTS)
37+
list(APPEND VCPKG_MANIFEST_FEATURES "tests")
38+
endif()
39+
40+
option(FEATURE_DOCS "Enable the docs" OFF)
41+
42+
# Enable sanitizers and static analyzers when running the tests
43+
set(ENABLE_CLANG_TIDY OFF)
44+
set(ENABLE_CPPCHECK OFF)
45+
set(ENABLE_SANITIZER_ADDRESS OFF)
46+
47+
if(FEATURE_TESTS)
48+
set(ENABLE_CLANG_TIDY "ENABLE_CLANG_TIDY")
49+
set(ENABLE_CPPCHECK "ENABLE_CPPCHECK")
50+
51+
string(FIND "$ENV{PATH}" "$ENV{VSINSTALLDIR}" index_of_vs_install_dir)
52+
if(# not windows
53+
NOT
54+
"${CMAKE_SYSTEM_NAME}"
55+
STREQUAL
56+
"Windows"
57+
# or is MSVC and has run vcvarsall
58+
OR (MSVC AND "${index_of_vs_install_dir}" STREQUAL "-1"))
59+
set(ENABLE_SANITIZER_ADDRESS "ENABLE_SANITIZER_ADDRESS")
60+
endif()
61+
endif()
62+
63+
if(FEATURE_DOCS)
64+
set(ENABLE_DOXYGEN "ENABLE_DOXYGEN")
65+
else()
66+
set(ENABLE_DOXYGEN OFF)
67+
endif()
68+
3469
# Initialize project_options variable related to this project
3570
# This overwrites `project_options` and sets `project_warnings`
3671
# uncomment to enable the options. Some of them accept one or more inputs:
3772
project_options(
3873
ENABLE_CACHE
39-
ENABLE_CPPCHECK
40-
ENABLE_CLANG_TIDY
74+
${ENABLE_CPPCHECK}
75+
${ENABLE_CLANG_TIDY}
4176
ENABLE_VS_ANALYSIS
4277
# ENABLE_CONAN
4378
# ENABLE_INTERPROCEDURAL_OPTIMIZATION
4479
# ENABLE_NATIVE_OPTIMIZATION
45-
# ENABLE_DOXYGEN
80+
${ENABLE_DOXYGEN}
4681
# ENABLE_COVERAGE
47-
# ENABLE_SANITIZER_ADDRESS
48-
# ENABLE_SANITIZER_LEAK
82+
${ENABLE_SANITIZER_ADDRESS}
4983
# ENABLE_SANITIZER_UNDEFINED_BEHAVIOR
5084
# ENABLE_SANITIZER_THREAD
5185
# ENABLE_SANITIZER_MEMORY

0 commit comments

Comments
 (0)