Skip to content

Commit 6548107

Browse files
committed
Merge branch 'main' into bugfix/dev-container
2 parents 605f863 + 413f1b9 commit 6548107

21 files changed

Lines changed: 87 additions & 201 deletions

.github/workflows/build_cmake.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
- name: Install conan
6161
shell: bash
6262
run: |
63-
python3 -m pip install --upgrade pip setuptools conan==1.59
63+
python3 -m pip install --upgrade pip setuptools conan
6464
source ~/.profile
6565
6666
- name: Install dependencies
@@ -108,7 +108,7 @@ jobs:
108108
- name: Install conan
109109
shell: bash
110110
run: |
111-
python3 -m pip install --upgrade pip setuptools conan==1.59
111+
python3 -m pip install --upgrade pip setuptools conan
112112
source ~/.profile
113113
114114
- name: Install dependencies
@@ -164,7 +164,7 @@ jobs:
164164
- name: Install conan
165165
shell: bash
166166
run: |
167-
python3 -m pip install --upgrade pip setuptools conan==1.59
167+
python3 -m pip install --upgrade pip setuptools conan
168168
source ~/.profile
169169
170170
- name: Install dependencies
@@ -218,7 +218,7 @@ jobs:
218218
- name: Install conan
219219
shell: bash
220220
run: |
221-
python3 -m pip install --upgrade pip setuptools conan==1.59
221+
python3 -m pip install --upgrade pip setuptools conan
222222
source ~/.profile
223223
224224
- name: Install dependencies

CMakeLists.txt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
CMAKE_MINIMUM_REQUIRED(VERSION 3.21)
22

3+
INCLUDE(cmake/Conan.cmake)
4+
35
# strongly encouraged to enable this globally to avoid conflicts between
46
# -Wpedantic being enabled and -std=c++20 and -std=gnu++20 for example
57
# when compiling with PCH enabled
@@ -62,9 +64,6 @@ INCLUDE(cmake/StaticAnalyzers.cmake)
6264
INCLUDE(cmake/PrecompiledHeader.cmake)
6365
ENABLE_PCH()
6466

65-
INCLUDE(cmake/Conan.cmake)
66-
RUN_CONAN()
67-
6867
ADD_SUBDIRECTORY(src)
6968

7069
IF(CMAKE_CROSSCOMPILING)

CMakePresets.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@
301301
"name": "win32-gcc-x64-mingw-debug",
302302
"inherits": "conf-common",
303303
"environment": {
304-
"PATH": "C:/msys64/mingw64/bin;$penv{PATH}"
304+
"PATH": "C:/msys64/mingw64/bin;C:/msys64/mingw64/usr/bin;$penv{PATH}"
305305
},
306306
"cacheVariables": {
307307
"CMAKE_C_COMPILER": "gcc.exe",
@@ -345,8 +345,7 @@
345345
"CPP_STARTER_USE_EMBEDDED_TOOLCHAIN": "ON",
346346
"CMAKE_BUILD_TYPE": "Debug",
347347
"CMAKE_SYSTEM_NAME": "Linux",
348-
"CONAN_ARCHITECTURE": "armv7",
349-
"CMAKE_SYSTEM_PROCESSOR": "arm",
348+
"CMAKE_SYSTEM_PROCESSOR": "armv7l",
350349
"CMAKE_TRY_COMPILE_TARGET_TYPE": "STATIC_LIBRARY",
351350
"CMAKE_CROSSCOMPILING": "TRUE"
352351
}
@@ -361,8 +360,7 @@
361360
"CPP_STARTER_USE_EMBEDDED_TOOLCHAIN": "ON",
362361
"CMAKE_BUILD_TYPE": "Release",
363362
"CMAKE_SYSTEM_NAME": "Linux",
364-
"CONAN_ARCHITECTURE": "armv7",
365-
"CMAKE_SYSTEM_PROCESSOR": "arm",
363+
"CMAKE_SYSTEM_PROCESSOR": "armv7l",
366364
"CMAKE_TRY_COMPILE_TARGET_TYPE": "STATIC_LIBRARY",
367365
"CMAKE_CROSSCOMPILING": "TRUE"
368366
}

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
# cpp_example_project
22

3-
> **Warning**
4-
> Until now only conan 1.x is supported. Support for conan 2.x will come soon.
5-
63
Ongoing project of the Zühlke Germany **Modern C++ Topic Group**.
74

85
With this project, we want to provide an example and starting point for C++ projects (embedded and otherwise), especially regarding tooling.

cmake/Conan.cmake

Lines changed: 8 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,8 @@
1-
MACRO(RUN_CONAN)
2-
# Download automatically, you can also just copy the conan.cmake file
3-
IF(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
4-
MESSAGE(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
5-
FILE(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/develop/conan.cmake" "${CMAKE_BINARY_DIR}/conan.cmake" TLS_VERIFY ON)
6-
ENDIF()
7-
8-
SET(ENV{CONAN_REVISIONS_ENABLED} 1)
9-
LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR})
10-
LIST(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR})
11-
12-
INCLUDE(${CMAKE_BINARY_DIR}/conan.cmake)
13-
14-
# Add (or remove) remotes as needed
15-
# conan_add_remote(NAME conan-center URL https://center.conan.io)
16-
CONAN_ADD_REMOTE(
17-
NAME
18-
conancenter
19-
URL
20-
https://center.conan.io
21-
INDEX
22-
0)
23-
24-
IF(NOT CONAN_EXPORTED)
25-
# For multi configuration generators, like VS and XCode
26-
IF(NOT CMAKE_CONFIGURATION_TYPES)
27-
MESSAGE(STATUS "Single configuration build!")
28-
SET(LIST_OF_BUILD_TYPES ${CMAKE_BUILD_TYPE})
29-
ELSE()
30-
MESSAGE(STATUS "Multi-configuration build: '${CMAKE_CONFIGURATION_TYPES}'!")
31-
SET(LIST_OF_BUILD_TYPES ${CMAKE_CONFIGURATION_TYPES})
32-
ENDIF()
33-
34-
FOREACH(TYPE ${LIST_OF_BUILD_TYPES})
35-
MESSAGE(STATUS "Running Conan for build type '${TYPE}'")
36-
37-
IF("${ProjectOptions_CONAN_PROFILE}" STREQUAL "")
38-
# Detects current build settings to pass into conan
39-
CONAN_CMAKE_AUTODETECT(settings BUILD_TYPE ${TYPE})
40-
SET(CONAN_SETTINGS SETTINGS ${settings})
41-
SET(CONAN_ENV ENV "CC=${CMAKE_C_COMPILER}" "CXX=${CMAKE_CXX_COMPILER}")
42-
ELSE()
43-
# Derive all conan settings from a conan profile
44-
SET(CONAN_SETTINGS
45-
PROFILE
46-
${ProjectOptions_CONAN_PROFILE}
47-
SETTINGS
48-
"build_type=${TYPE}")
49-
# CONAN_ENV should be redundant, since the profile can set CC & CXX
50-
ENDIF()
51-
52-
IF("${ProjectOptions_CONAN_PROFILE}" STREQUAL "")
53-
SET(CONAN_DEFAULT_PROFILE "default")
54-
ELSE()
55-
SET(CONAN_DEFAULT_PROFILE ${ProjectOptions_CONAN_PROFILE})
56-
ENDIF()
57-
IF("${ProjectOptions_CONAN_BUILD_PROFILE}" STREQUAL "")
58-
SET(CONAN_BUILD_PROFILE ${CONAN_DEFAULT_PROFILE})
59-
ELSE()
60-
SET(CONAN_BUILD_PROFILE ${ProjectOptions_CONAN_BUILD_PROFILE})
61-
ENDIF()
62-
63-
IF("${ProjectOptions_CONAN_HOST_PROFILE}" STREQUAL "")
64-
SET(CONAN_HOST_PROFILE ${CONAN_DEFAULT_PROFILE})
65-
ELSE()
66-
SET(CONAN_HOST_PROFILE ${ProjectOptions_CONAN_HOST_PROFILE})
67-
ENDIF()
68-
69-
IF(CMAKE_CROSSCOMPILING AND NOT CONAN_ARCHITECTURE)
70-
MESSAGE(FATAL_ERROR "The variable CONAN_ARCHITECTURE must be specified for cross-compiling")
71-
ENDIF()
72-
73-
IF(CMAKE_CROSSCOMPILING)
74-
CONAN_CMAKE_RUN(
75-
CONANFILE conanfile_embedded.txt
76-
BASIC_SETUP
77-
ARCH ${CONAN_ARCHITECTURE}
78-
ENV CC=${CMAKE_C_COMPILER}
79-
ENV CXX=${CMAKE_CXX_COMPILER}
80-
ENV CFLAGS=${CMAKE_C_FLAGS}
81-
ENV CXXFLAGS=${CMAKE_CXX_FLAGS}
82-
PROFILE_AUTO ALL
83-
BUILD missing
84-
)
85-
ELSE()
86-
CONAN_CMAKE_INSTALL(
87-
PATH_OR_REFERENCE
88-
${CMAKE_SOURCE_DIR}
89-
BUILD
90-
missing
91-
# Pass compile-time configured options into conan
92-
OPTIONS
93-
${ProjectOptions_CONAN_OPTIONS}
94-
# Pass CMake compilers to Conan
95-
${CONAN_ENV}
96-
PROFILE_HOST
97-
${CONAN_HOST_PROFILE}
98-
PROFILE_BUILD
99-
${CONAN_BUILD_PROFILE}
100-
# Pass either autodetected settings or a conan profile
101-
${CONAN_SETTINGS}
102-
${OUTPUT_QUIET})
103-
ENDIF()
104-
ENDFOREACH()
105-
106-
ENDIF()
107-
# standard conan installation, in which deps will be defined in conanfile. It is not necessary to call conan again, as it is already running.
108-
IF(EXISTS "${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
109-
INCLUDE(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
110-
ELSE()
111-
MESSAGE(FATAL_ERROR "Could not set up conan because \"${CMAKE_BINARY_DIR}/conanbuildinfo.cmake\" does not exist")
112-
ENDIF()
113-
CONAN_BASIC_SETUP(TARGETS)
114-
ENDMACRO()
1+
# Download automatically, you can also just copy the conan.cmake file
2+
IF(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
3+
MESSAGE(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
4+
FILE(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/develop2/conan_provider.cmake" "${CMAKE_BINARY_DIR}/conan.cmake" TLS_VERIFY ON)
5+
ENDIF()
6+
7+
LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR})
8+
SET(CMAKE_PROJECT_TOP_LEVEL_INCLUDES "${CMAKE_BINARY_DIR}/conan.cmake")

conanfile.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import conans.model.requires
2+
from conan import ConanFile
3+
from conan.tools.cmake import CMakeToolchain
4+
5+
6+
class HelloConan(ConanFile):
7+
settings = 'os', 'compiler', 'build_type', 'arch'
8+
generators = 'CMakeDeps', 'CMakeToolchain'
9+
default_options = {'fmt/*:header_only': True, 'spdlog/*:header_only': True}
10+
11+
def configure(self):
12+
cmake = CMakeToolchain(self)
13+
cmake.user_presets_path = None
14+
if self.settings.get_safe('arch') == 'armv7':
15+
self.requires = conans.model.requires.Requirements(['fmt/10.0.0', 'sml/1.1.6'])
16+
else:
17+
self.requires = conans.model.requires.Requirements(['catch2/3.4.0', 'gtest/1.14.0', 'docopt.cpp/0.6.3',
18+
'spdlog/1.12.0', 'sml/1.1.8', 'nlohmann_json/3.11.2',
19+
'boost/1.83.0', 'crowcpp-crow/1.0+5', 'cppzmq/4.9.0',
20+
'protobuf/3.21.12'])
21+
22+
def build(self):
23+
cmake = CMakeToolchain(self)
24+
cmake.configure()
25+
cmake.build()

conanfile.txt

Lines changed: 0 additions & 19 deletions
This file was deleted.

conanfile_embedded.txt

Lines changed: 0 additions & 10 deletions
This file was deleted.

docker/Dockerfile

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Build and test environment for CI
33
# =================================
44

5-
FROM ubuntu:22.10 as cpp-docker-common
5+
FROM ubuntu:23.04 as cpp-docker-common
66

77
ARG DEBIAN_FRONTEND=noninteractive
88
ARG CLANG_COMPILER_VERSION=15
@@ -20,8 +20,11 @@ RUN apt-get update && apt-get -y dist-upgrade && apt-get -y install --fix-missin
2020
git \
2121
lsb-release \
2222
ninja-build \
23+
pipx \
2324
python3 \
2425
python3-pip \
26+
python3-setuptools \
27+
python3-venv \
2528
shellcheck \
2629
ssh \
2730
software-properties-common \
@@ -61,8 +64,8 @@ RUN apt-get -y install --fix-missing vim \
6164
&& apt-get autoremove -y && apt-get clean
6265

6366
# Dev user for inside the container
64-
RUN groupadd -g 1000 ${DEV_USER} && \
65-
useradd -m -u 1000 -g 1000 -d /home/${DEV_USER} -s /bin/bash ${DEV_USER} && \
67+
RUN groupadd -f -g 1000 ${DEV_USER} && \
68+
useradd --non-unique -m -u 1000 -g 1000 -d /home/${DEV_USER} -s /bin/bash ${DEV_USER} && \
6669
usermod -a -G adm,cdrom,sudo,dip,plugdev ${DEV_USER} && \
6770
echo "${DEV_USER}:${DEV_USER}" | chpasswd && \
6871
echo "${DEV_USER} ALL=(ALL:ALL) ALL" >> /etc/sudoers
@@ -79,7 +82,7 @@ WORKDIR /home/${DEV_USER}
7982
RUN sed -i 's/\\h/docker/;s/01;32m/01;33m/' /home/${DEV_USER}/.bashrc \
8083
&& mkdir /home/${DEV_USER}/git
8184

82-
RUN pip install --user conan==1.59
85+
RUN pipx install conan
8386

8487

8588
FROM cpp-docker-common as cpp-docker-ci
@@ -88,13 +91,13 @@ ARG CI_USER=ci
8891
ENV PATH="${PATH}:/home/${CI_USER}/.local/bin/"
8992

9093
# Dev user for inside the container
91-
RUN groupadd -g 1000 ${CI_USER} && \
92-
useradd -m -u 1000 -g 1000 -d /home/${CI_USER} -s /bin/bash ${CI_USER} && \
94+
RUN groupadd -f -g 1000 ${CI_USER} && \
95+
useradd --non-unique -m -u 1000 -g 1000 -d /home/${CI_USER} -s /bin/bash ${CI_USER} && \
9396
usermod -a -G adm,cdrom,sudo,dip,plugdev ${CI_USER} && \
9497
echo "${CI_USER}:${CI_USER}" | chpasswd && \
9598
echo "${CI_USER} ALL=(ALL:ALL) ALL" >> /etc/sudoers
9699

97100
COPY ccache.conf /etc/.
98101
USER ${CI_USER}
99-
RUN pip install conan==1.59
102+
RUN pipx install conan
100103
WORKDIR /home/${CI_USER}

fuzz_test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ TARGET_LINK_LIBRARIES(
66
fuzz_tester
77
PRIVATE project_options
88
project_warnings
9-
CONAN_PKG::fmt
9+
fmt::fmt-header-only
1010
-coverage
1111
-fsanitize=fuzzer,undefined,address)
1212
TARGET_COMPILE_OPTIONS(fuzz_tester PRIVATE -fsanitize=fuzzer,undefined,address)

0 commit comments

Comments
 (0)