Skip to content

Commit bb3ba31

Browse files
committed
updated conanfile for newer syntax, added test options
1 parent 9ce38a4 commit bb3ba31

File tree

4 files changed

+66
-14
lines changed

4 files changed

+66
-14
lines changed

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,43 @@ For example:
283283
cmake --preset test-unixlike-clang-15-debug
284284

285285

286+
## Possible option
287+
288+
| Option | Comment | Default |
289+
| ------- | -------- | -------- |
290+
| ENABLE_PCH | Enable Precompiled Headers | OFF |
291+
| _**Static analyzers**_ |
292+
| ENABLE_CPPCHECK | Enable static analysis with cppcheck | OFF |
293+
| ENABLE_CLANG_TIDY | Enable static analysis with clang-tidy | OFF |
294+
| ENABLE_INCLUDE_WHAT_YOU_USE | Enable static analysis with include-what-you-use | OFF |
295+
| _**Tooling**_ |
296+
| ENABLE_CACHE | Enable cache if available | ON |
297+
| ENABLE_DOXYGEN | Enable doxygen doc builds of source | OFF |
298+
| _**Sanitizers**_ |
299+
| ENABLE_SANITIZER_UNDEFINED_BEHAVIOR | Enable undefined behavior sanitizer | OFF |
300+
| ENABLE_SANITIZER_THREAD | Enable thread sanitizer | OFF |
301+
| ENABLE_SANITIZER_MEMORY | Enable memory sanitizer | OFF |
302+
| ENABLE_SANITIZER_ADDRESS | Enable address sanitizer | OFF |
303+
| ENABLE_SANITIZER_LEAK | Enable leak sanitizer | OFF |
304+
| _**Others**_ |
305+
| ENABLE_COVERAGE | Enable coverage reporting for gcc/clang | OFF |
306+
| ENABLE_IPO | Enable Interprocedural Optimization, aka Link Time Optimization (LTO) | OFF |
307+
| WARNINGS_AS_ERRORS | Treat compiler warnings as errors | ON |
308+
| BUILD_SHARED_LIBS | Enable compilation of shared libraries | OFF |
309+
| ENABLE_TESTING | Enable Test Builds | ON |
310+
| ENABLE_FUZZING | Enable Fuzzing Builds | OFF |
311+
| _**Examples**_ |
312+
| CPP_STARTER_USE_SML | Enable compilation of SML sample | OFF |
313+
| CPP_STARTER_USE_BOOST_BEAST | Enable compilation of boost beast sample | OFF |
314+
| CPP_STARTER_USE_CROW | Enable compilation of crow sample | OFF |
315+
| CPP_STARTER_USE_CPPZMQ_PROTO | Enable compilation of protobuf and cppzmq sample | OFF |
316+
| CPP_STARTER_USE_EMBEDDED_TOOLCHAIN | Enable compilation of an example cortex m4 project | OFF |
317+
| CPP_STARTER_USE_QT | Enable compilation of an example QT project | | OFF |
318+
| _**Test frameworks**_ |
319+
| CPP_STARTER_USE_CATCH2 | Enable compilation of an example test project using catch2 | ON |
320+
| CPP_STARTER_USE_GTEST | Enable compilation of an example test project using googletest | ON |
321+
322+
286323
## Troubleshooting
287324

288325
### Update Conan

cmake/Options.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,7 @@ OPTION(CPP_STARTER_USE_CROW "Enable compilation of crow sample" OFF)
3636
OPTION(CPP_STARTER_USE_CPPZMQ_PROTO "Enable compilation of protobuf and cppzmq sample" OFF)
3737
OPTION(CPP_STARTER_USE_EMBEDDED_TOOLCHAIN "Enable compilation of an example cortex m4 project" OFF)
3838
OPTION(CPP_STARTER_USE_QT "Enable compilation of an example QT project" OFF)
39+
40+
# test frameworks
41+
OPTION(CPP_STARTER_USE_CATCH2 "Enable compilation of an example test project using catch2" ON)
42+
OPTION(CPP_STARTER_USE_GTEST "Enable compilation of an example test project using googletest" ON)

conanfile.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import os
22

3-
import conans.model.requires
43
from conan import ConanFile
54
from conan.tools.cmake import CMakeToolchain
65

@@ -10,22 +9,29 @@ class HelloConan(ConanFile):
109
generators = 'CMakeDeps', 'CMakeToolchain'
1110
default_options = {'fmt/*:header_only': True, 'spdlog/*:header_only': True, 'qt/*:with_fontconfig': False}
1211

13-
def configure(self):
14-
cmake = CMakeToolchain(self)
15-
cmake.user_presets_path = None
12+
def requirements(self):
1613
if self.settings.get_safe('arch') == 'armv7':
17-
self.requires = conans.model.requires.Requirements(['fmt/11.0.2', 'sml/1.1.11'])
14+
self.requires('fmt/11.1.3')
15+
self.requires('sml/1.1.11')
1816
return
1917

18+
self.requires('catch2/3.8.0')
19+
self.requires('gtest/1.15.0')
20+
self.requires('docopt.cpp/0.6.3')
21+
self.requires('spdlog/1.15.0')
2022
if os.getenv("CONFIGURE_QT") == '1':
21-
self.requires = conans.model.requires.Requirements(['catch2/3.7.1', 'docopt.cpp/0.6.3', 'gtest/1.15.0',
22-
'qt/6.7.3', 'spdlog/1.15.0'])
23+
self.requires('qt/6.7.3')
2324
else:
24-
requirement = ['catch2/3.7.1', 'gtest/1.15.0', 'docopt.cpp/0.6.3',
25-
'spdlog/1.15.0', 'sml/1.1.11', 'nlohmann_json/3.11.3',
26-
'boost/1.86.0', 'crowcpp-crow/1.2.0', 'cppzmq/4.10.0',
27-
'protobuf/5.27.0']
28-
self.requires = conans.model.requires.Requirements(requirement)
25+
self.requires('sml/1.1.11')
26+
self.requires('nlohmann_json/3.11.3')
27+
self.requires('boost/1.87.0')
28+
self.requires('crowcpp-crow/1.2.0')
29+
self.requires('cppzmq/4.10.0')
30+
self.requires('protobuf/5.29.3')
31+
32+
def configure(self):
33+
cmake = CMakeToolchain(self)
34+
cmake.user_presets_path = None
2935

3036
def build(self):
3137
cmake = CMakeToolchain(self)

test/CMakeLists.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
1-
ADD_SUBDIRECTORY(catch2)
2-
ADD_SUBDIRECTORY(gtest)
1+
IF(CPP_STARTER_USE_CATCH2)
2+
ADD_SUBDIRECTORY(catch2)
3+
ENDIF()
4+
5+
IF(CPP_STARTER_USE_GTEST)
6+
ADD_SUBDIRECTORY(gtest)
7+
ENDIF()

0 commit comments

Comments
 (0)