diff --git a/.github/workflows/build-cloe.yaml b/.github/workflows/build-cloe.yaml index 48145b5c0..e0a3f27b8 100644 --- a/.github/workflows/build-cloe.yaml +++ b/.github/workflows/build-cloe.yaml @@ -35,7 +35,16 @@ jobs: - "cloe-normal" package_target: # 1. Build each test configuration in Conan cache and run all tests - - "export export-vendor smoketest-deps smoketest" + - "export-vendor export-all smoketest-deps smoketest" + + # 2. Build cloe super-package in editable mode and run tests + - "export-vendor editable all smoketest TEST_CONANFILES=tests/conanfile_superbuild.py" + + # 3. TODO: Build individual packages in editable mode and run tests + # This cannot be currently enabled because of a Conan deficiency in v1. + # Once all build tooling is based on Conan v2, we can re-enable this use-case. + # Until then, use the previous target for this use-case. + # - "export-vendor editable-select build-all smoketest TEST_CONANFILES=tests/conanfile_deployment.py" env: CONAN_NON_INTERACTIVE: "yes" DEBIAN_FRONTEND: noninteractive diff --git a/.gitignore b/.gitignore index be2327278..6cd13c76c 100644 --- a/.gitignore +++ b/.gitignore @@ -30,6 +30,7 @@ CMakeFiles/ compile_commands.json # Files generated by Clang: +.cache/ .clangd/ .cache/ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..d50488e7d --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,40 @@ +# This CMakeLists.txt configures a super-build containing everything +# from this repo. +# +# It is currently experimental. +# + +cmake_minimum_required(VERSION 3.15...3.27 FATAL_ERROR) + +project(cloe LANGUAGES CXX) + +option(CLOE_WITH_ESMINI "Build simulator_esmini plugin?" ON) +option(CLOE_WITH_VTD "Build simulator_vtd plugin?" OFF) + +set(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/runtime/cmake") + +# Since a super-build does not export packages individually via Conan, +# we cannot depend on Conan-generated CMake config files, instead we +# use the CMake targets directly as if they were already found. +set(CLOE_FIND_PACKAGES OFF CACHE BOOL "Call find_package() for cloe packages" FORCE) + +# Ensure output goes to one place so cloe-launch can find the plugins +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin) + +# Ensure we can test from this level. +set(CMAKE_CTEST_ARGUMENTS "--output-on-failure") +include(CTest) + +# Order matters: +add_subdirectory(fable) +add_subdirectory(runtime) +add_subdirectory(models) +add_subdirectory(osi) +add_subdirectory(oak) +add_subdirectory(engine) +add_subdirectory(plugins) + +if(CLOE_WITH_VTD) + add_subdirectory(optional/vtd) +endif() diff --git a/Makefile b/Makefile index ee93372a1..bf3731a7d 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,11 @@ # This file contains Makefile targets for the cloe project. # +# Make configuration: +SHELL := /bin/bash +GNUMAKEFLAGS := --no-print-directory +SUBMAKEFLAGS := + CLOE_ROOT := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) CLOE_LAUNCH := PYTHONPATH="${CLOE_ROOT}/cli" python3 -m cloe_launch @@ -20,78 +25,98 @@ AG := $(or \ # Build configuration: BUILD_DIR := build -LOCKFILE_SOURCE := conanfile.py -BUILD_LOCKFILE := ${BUILD_DIR}/conan.lock -LOCKFILE_OPTION := --lockfile="${CLOE_ROOT}/${BUILD_LOCKFILE}" INSTALL_DIR := /usr/local +DEPLOY_DIR := deploy CONAN_OPTIONS := +# Lockfile for cloe-deployment: +DEPLOY_LOCKFILE_SOURCE := tests/conanfile_deployment.py +DEPLOY_BUILD_LOCKFILE := ${DEPLOY_DIR}/conan.lock +DEPLOY_LOCKFILE_OPTION := --lockfile="${CLOE_ROOT}/${DEPLOY_BUILD_LOCKFILE}" + .DEFAULT_GOAL := help .PHONY: help .SILENT: help help:: $(call print_help_usage) echo + $(call print_help_section, "Default target") + $(call print_help_target, help, "show this help on available targets") + echo # Setup targets --------------------------------------------------------------- include Makefile.setup +${DEPLOY_BUILD_LOCKFILE}: + mkdir -p "${DEPLOY_DIR}" + conan lock create --lockfile-out "${DEPLOY_BUILD_LOCKFILE}" --build -- "${DEPLOY_LOCKFILE_SOURCE}" + +.PHONY: lockfile +lockfile: ${DEPLOY_BUILD_LOCKFILE} + # Workspace targets ----------------------------------------------------------- help:: $(call print_help_section, "Available workspace targets") - $(call print_help_target, status, "show status of each of the Conan packages") - $(call print_help_target, smoketest-deps, "build system test pre-requisites") - $(call print_help_target, smoketest, "run system tests") - $(call print_help_target, docs, "generate documentation") - $(call print_help_target, deploy, "deploy Cloe to INSTALL_DIR [=${INSTALL_DIR}]") - $(call print_help_target, deploy-cli, "install ${_yel}cloe-launch${_rst} with ${_dim}${PIPX}${_rst}") - $(call print_help_target, export-cli, "export ${_yel}cloe-launch-profile${_rst} Conan recipe") + $(call print_help_target, docs, "generate Doxygen and Sphinx documentation") echo -${BUILD_LOCKFILE}: - ${MAKE} -f Makefile.package SOURCE_CONANFILE=/dev/null LOCKFILE_SOURCE=${LOCKFILE_SOURCE} ${BUILD_LOCKFILE} - -.PHONY: lockfile -lockfile: ${BUILD_LOCKFILE} +.PHONY: docs +docs: + $(call print_header, "Generating Doxygen documentation...") + ${MAKE} -C docs doxygen + $(call print_header, "Generating Sphinx documentation...") + ${MAKE} -C docs html -.PHONY: status -status: ${BUILD_LOCKFILE} - @for pkg in ${ALL_PKGS}; do \ - [ -d $${pkg} ] || continue; \ - ${MAKE} LOCKFILE_SOURCE="" LOCKFILE_OPTION=${LOCKFILE_OPTION} -C $${pkg} status || true; \ - done +help:: + $(call print_help_target, export-cli, "export ${_yel}cloe-launch-profile${_rst} Conan recipe") + $(call print_help_target, deploy-cli, "install ${_yel}cloe-launch${_rst} with ${_dim}${PIPX}${_rst}") + echo -.PHONY: deploy -deploy: - $(call print_header, "Deploying binaries to ${INSTALL_DIR}...") - conan install ${CONAN_OPTIONS} --install-folder ${BUILD_DIR}/deploy -g deploy . - mkdir -p ${INSTALL_DIR} - cp -r ${BUILD_DIR}/deploy/cloe-*/* ${INSTALL_DIR}/ +.PHONY: export-cli +export-cli: + ${MAKE} -C cli export .PHONY: deploy-cli deploy-cli: $(call print_header, "Deploying cloe-launch binary with pip...") ${MAKE} -C cli install -.PHONY: export-cli -export-cli: - ${MAKE} -C cli export +help:: + $(call print_help_target, lockfile, "create a lockfile for cloe deployment packages") + $(call print_help_target, package-all, "package all cloe deployment packages") + $(call print_help_target, status-all, "show status of each of the Conan packages") + $(call print_help_target, export-all, "export all package sources to Conan cache") + $(call print_help_target, build-all, "build individual packages locally in-source") + $(call print_help_target, deploy-all, "deploy Cloe to INSTALL_DIR [=${INSTALL_DIR}]") + $(call print_help_target, clean-all, "clean entire repository of temporary files") + $(call print_help_target, purge-all, "remove all cloe packages (in any version) from Conan cache") + echo -export: export-cli -package: export-cli +.PHONY: build-all +build-all: lockfile + ${MAKE} all-select CONAN_OPTIONS="${CONAN_OPTIONS} ${DEPLOY_LOCKFILE_OPTION}" -.PHONY: docs -docs: - $(call print_header, "Generating Doxygen documentation...") - ${MAKE} -C docs doxygen - $(call print_header, "Generating Sphinx documentation...") - ${MAKE} -C docs html +.PHONY: status-all +status-all: ${DEPLOY_BUILD_LOCKFILE} + @for pkg in ${ALL_PKGS}; do \ + ${MAKE} LOCKFILE_SOURCE="" LOCKFILE_OPTION=${DEPLOY_LOCKFILE_OPTION} -C $${pkg} status || true; \ + done -.PHONY: smoketest-deps -smoketest-deps: export-cli smoketest-deps-select +.PHONY: export-all +export-all: + $(call print_header, "Exporting all cloe Conan packages...") + ${MAKE} export-select export-cli export + +.PHONY: deploy-all +deploy-all: + $(call print_header, "Deploying binaries to ${INSTALL_DIR}...") + conan install ${CONAN_OPTIONS} --install-folder ${DEPLOY_DIR} -g deploy . + mkdir -p ${INSTALL_DIR} + cp -r ${DEPLOY_DIR}/cloe-*/* ${INSTALL_DIR}/ -.PHONY: smoketest -smoketest: smoketest-select +.PHONY: clean-all +clean-all: + ${MAKE} clean clean-select .PHONY: purge-all purge-all: @@ -100,6 +125,10 @@ purge-all: conan remove -f 'cloe' conan remove -f 'fable' +.PHONY: package-all +package-all: + conan install ${CONAN_OPTIONS} --install-folder ${DEPLOY_DIR} --build=missing --build=outdated ${DEPLOY_LOCKFILE_SOURCE} + # Development targets --------------------------------------------------------- help:: $(call print_help_section, "Available development targets") @@ -122,10 +151,15 @@ todos: ${AG} FIXME ${AG} XXX +# Hidden development targets -------------------------------------------------- + .PHONY: grep-uuids grep-uuids: ${AG} "\b[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\b" +grep-conan-requires: + @rg -t py '^.*requires\(f?["](.+/[0-9]+\.[^)]+)["].*\).*$$' -r '$$1' -I --no-heading --no-line-number | sort | uniq + .PHONY: find-missing-eol find-missing-eol: find . -type f -size +0 -exec gawk 'ENDFILE{if ($0 == "") print FILENAME}' {} \; @@ -134,5 +168,12 @@ find-missing-eol: sanitize-files: git grep --cached -Ilz '' | while IFS= read -rd '' f; do tail -c1 < "$$f" | read -r _ || echo >> "$$f"; done -# Build targets --------------------------------------------------------------- +# Micro-packages build targets ------------------------------------------------ include Makefile.all + +# Mono-package build targets -------------------------------------------------- +DISABLE_HELP_PREAMBLE := true +help:: + @printf "Available $(_yel)cloe$(_rst) package targets:\n" + +include Makefile.package diff --git a/Makefile.all b/Makefile.all index fbf633780..2e294a6f6 100644 --- a/Makefile.all +++ b/Makefile.all @@ -35,9 +35,25 @@ SHELL := /bin/bash GNUMAKEFLAGS := --no-print-directory SUBMAKEFLAGS := -META_PKG := cloe -PLUGIN_PKGS := $(wildcard plugins/*) -ALL_PKGS := fable runtime models oak osi engine ${PLUGIN_PKGS} ${META_PKG} +PLUGIN_PKGS := \ + plugins/basic \ + plugins/clothoid_fit \ + plugins/esmini \ + plugins/frustum_culling \ + plugins/gndtruth_extractor \ + plugins/minimator \ + plugins/mocks \ + plugins/noisy_sensor \ + plugins/speedometer \ + plugins/virtue +ALL_PKGS := \ + fable \ + runtime \ + models \ + osi \ + oak \ + engine \ + ${PLUGIN_PKGS} WITHOUT_PKGS := UNSELECT_PKGS := ${WITHOUT_PKGS} WITH_PKGS := @@ -59,11 +75,11 @@ SELECT_VENDOR := $(call uniq, $(filter-out ${UNSELECT_VENDOR}, ${ALL_VENDOR}) ${ fable: runtime: fable models: runtime +osi: runtime models oak: runtime engine: models oak -osi: runtime models vendor/open-simulation-interface ${PLUGIN_PKGS}: runtime models -plugins/esmini: vendor/open-simulation-interface vendor/esmini +plugins/esmini: osi vendor/esmini: vendor/open-simulation-interface vendor/esmini-data: @@ -112,18 +128,9 @@ ${1}-each: ${4} endef REGEX_TARGET := 's/(-vendor|-select)?-each//' -$(filter-out ${META_PKG}, ${ALL_PKGS} ${ALL_VENDOR}): +${ALL_PKGS} ${ALL_VENDOR}: ${MAKE} -C $@ $(shell echo ${MAKECMDGOALS} | sed -re ${REGEX_TARGET}) -# Re-define ${META_PKG} target to use Makefile.package, and only run for targets -# where it makes sense, since "${META_PKG}" is a Conan meta-package. -${META_PKG}: - for case in export package package-outdated list purge clean smoketest smoketest-deps; do \ - if [ "$$(echo '${MAKECMDGOALS}' | sed -re ${REGEX_TARGET})" == "$${case}" ]; then \ - ${MAKE} -f Makefile.package CONAN_OPTIONS="${CONAN_OPTIONS}" $${case} || exit 1; \ - fi \ - done - # Usage: $(call make_vendor_target, TARGET-NAME, HELP-DESCRIPTION, HELP-CATEGORY) define make_vendor_target $(eval $(call _make_target_rules,${1},${2},${3},${SELECT_VENDOR})) @@ -145,19 +152,16 @@ endef .PHONY: help .SILENT: help help:: - $(call print_help_section, "Available build targets") + $(call print_help_section, "Available multi-package targets") +ifneq "${ALL_VENDOR}" "" +help:: $(call make_vendor_target, export-vendor, "export all vendor packages", "[conan-cache]") $(call make_vendor_target, package-vendor, "create all vendor packages", "[conan-cache]") $(call make_vendor_target, download-vendor, "download or build vendor packages", "[conan-cache]") - help:: echo - -$(call make_every_target, export, "export all package recipes", "[conan-cache]") -help:: - $(call print_help_target, package, "create ${META_PKG} package and plugins", "[conan-cache]") - echo +endif $(call make_select_target, export-select, "export selected packages", "[conan-cache]") $(call make_select_target, package-select, "create selected packages with policy", "[conan-cache]") @@ -185,34 +189,19 @@ $(call make_select_target, clean-select, "remove build artifacts", "[in-source]" help:: echo $(call print_help_subsection, "Options") +ifneq "${ALL_VENDOR}" "" $(call print_help_option, WITH_VENDOR, "", "include optional vendor packages from ${_grn}UNSELECT_VENDOR${_rst}") +endif $(call print_help_option, WITH_PKGS, "", "include optional packages from ${_grn}UNSELECT_PKGS${_rst}") $(call print_help_option, LOCKFILE_SOURCE, "", "use specified conanfile as lockfile source for build") echo $(call print_help_subsection, "Defines") $(call print_help_option, BUILD_POLICY, ${BUILD_POLICY}) $(call print_help_define, CONAN_OPTIONS, ${CONAN_OPTIONS}) +ifneq "${ALL_VENDOR}" "" $(call print_help_define_lines, UNSELECT_VENDOR, ${UNSELECT_VENDOR}) $(call print_help_define_lines, SELECT_VENDOR, ${SELECT_VENDOR}) +endif $(call print_help_define_lines, UNSELECT_PKGS, ${UNSELECT_PKGS}) $(call print_help_define_lines, SELECT_PKGS, ${SELECT_PKGS}) echo - -.PHONY: package -package: export-select - # Build cloe with all targets and options together. - # - # This is different from the package target in that it always builds the - # packages from this workspace, the ones in SELECT_PKGS. - # This is different from the package-select target in that it builds them - # all together and thereby uses the correct dependency resolution with - # overrides and options. - TARGETS=$$( \ - for pkg in ${SELECT_PKGS}; do \ - if [ ! -d $${pkg} ]; then \ - continue; \ - fi; \ - echo -n "--build=$$(make --no-print-directory -C $${pkg} info-name) "; \ - done; \ - ) && \ - ${MAKE} -f Makefile.package CONAN_OPTIONS="${CONAN_OPTIONS} $$TARGETS" package diff --git a/Makefile.package b/Makefile.package index 8d94a9372..84a812220 100644 --- a/Makefile.package +++ b/Makefile.package @@ -191,8 +191,6 @@ help:: parse-info parse-editable $(call print_help_target, export, "export recipe and sources", "[conan-cache]") $(call print_help_target, download, "download or create package", "[conan-cache]") $(call print_help_target, package, "create package with build policy", "[conan-cache]") - $(call print_help_target, package-all, "create package and dependencies", "[conan-cache]") - $(call print_help_target, package-outdated, "create package if outdated", "[conan-cache]") $(call print_help_target, list, "list installed package files", "[conan-cache]") $(call print_help_target, purge, "remove package from cache", "[conan-cache]") echo @@ -379,25 +377,6 @@ package: ${BUILD_LOCKFILE} conan create . ${PACKAGE_FQN} \ --build=${BUILD_POLICY} --build=${PACKAGE_NAME} ${ALL_OPTIONS} -.PHONY: package-all -package-all: ${BUILD_LOCKFILE} - # Build the package in Conan cache unconditionally. - # - # Conan will retrieve and build all dependencies unconditionally. - # Note that this cannot be called if the package is currently in editable mode. - # - conan create . ${PACKAGE_FQN} --build ${ALL_OPTIONS} - -.PHONY: package-outdated -package-outdated: ${BUILD_LOCKFILE} - # Build the package in Conan cache if it is outdated. - # - # Note that this does not take dependencies of ${PACKAGE_NAME} into account. - # Rebuilds will occur if package info has changed or a hash of the source - # code changes. Timestamps are not taken into account. - # - conan create . ${PACKAGE_FQN} --build=outdated ${ALL_OPTIONS} - .PHONY: purge purge: # Remove all instances of this package in the Conan cache. diff --git a/README.md b/README.md index c5bfc46ca..add2bc3a1 100644 --- a/README.md +++ b/README.md @@ -84,14 +84,15 @@ See the Conan [documentation][6] for more information on how to do this. To build all packages, you should run the following: - make export-vendor package + make export-vendor export-all + make -C meta package This will export all Conan recipes from this repository and create the cloe package. Conan will download and build all necessary dependencies. Should any errors occur during the build, you may have to force Conan to build all packages instead of re-using packages it finds: ``` - make package CONAN_OPTIONS="--build" + make -C meta package CONAN_OPTIONS="--build" ``` Run `make help` to get an overview of the available targets we expect you to use. For more details on how this is done, have a look at the Makefiles in the @@ -166,7 +167,7 @@ Note that the above examples show the verbose output of the `cloe-launch` tool. Integration and system tests can be run to ensure that all the packages built are working together as expected: - make smoketest-deps + make export-all smoketest-deps make smoketest This will build packages in the required configurations as defined by the @@ -258,6 +259,22 @@ Note that this build requires the use of docker buildx, which has been available for some time. This allows us to mount secrets in at build time and also speeds up the build by the strategic use of caches. +Known Issues +------------ + +### Build-require 'protobuf' cannot be found in lockfile + +When using `build-all`, `cloe-osi` fails to build with: + + ERROR: Build-require 'protobuf' cannot be found in lockfile + +See the [upstream issue](https://github.com/conan-io/conan/issues/10544). +In Conan 1, a dependency in a lockfile is only in host or build context, not +both. Unfortunately, this is only fixed in Conan 2. + +The use-case for build-all is to build everything in editable mode. +For that, use the new super-build instead of building individual packages. + [1]: https://conan.io [2]: https://docs.microsoft.com/en-us/windows/wsl/about [3]: https://ubuntu.com diff --git a/conanfile.py b/conanfile.py index b1b17d121..ba702bc55 100644 --- a/conanfile.py +++ b/conanfile.py @@ -1,7 +1,9 @@ # mypy: ignore-errors # pylint: skip-file +import os from pathlib import Path +from semver import SemVer from conan import ConanFile from conan.tools import cmake, files, scm @@ -16,19 +18,55 @@ class Cloe(ConanFile): description = "Closed-loop automated driving simulation environment" topics = ["simulation"] settings = "os", "compiler", "build_type", "arch" + provides = ( + "fable", + "cloe-runtime", + "cloe-models", + "cloe-oak", + "cloe-engine", + "cloe-plugin-basic", + "cloe-plugin-clothoid-fit", + "cloe-plugin-esmini", + "cloe-plugin-frustum-culling", + "cloe-plugin-gndtruth-extractor", + "cloe-plugin-minimator", + "cloe-plugin-mocks", + "cloe-plugin-noisy-sensor", + "cloe-plugin-speedometer", + "cloe-plugin-virtue", + "cloe-plugins-core", + ) options = { - "with_vtd": [True, False], + "shared": [True, False], + "fPIC": [True, False], + "fable_allow_comments": [True, False], + "engine_server": [True, False], "with_esmini": [True, False], - "with_engine": [True, False], + "with_vtd": [True, False], } default_options = { - "with_vtd": False, + "shared": True, + "fPIC": True, + "fable_allow_comments": True, + "engine_server": True, "with_esmini": True, - "with_engine": True, - - "cloe-engine:server": True, + "with_vtd": False, } + generators = "CMakeDeps", "VirtualRunEnv" no_copy_source = True + exports_sources = [ + "**/CMakeLists.txt", + "**/cmake/*", + "**/include/*", + "**/src/*", + "**/ui/*", + + "fable/examples/*", + + "engine/webui/*", + + "CMakelists.txt" + ] def set_version(self): version_file = Path(self.recipe_folder) / "VERSION" @@ -39,33 +77,123 @@ def set_version(self): self.version = git.run("describe --dirty=-dirty")[1:] def requirements(self): - def cloe_requires(dep): - self.requires(f"{dep}/{self.version}@cloe/develop") - - cloe_requires("cloe-runtime") - cloe_requires("cloe-models") - cloe_requires("cloe-plugin-basic") - cloe_requires("cloe-plugin-clothoid-fit") - cloe_requires("cloe-plugin-frustum-culling") - cloe_requires("cloe-plugin-gndtruth-extractor") - cloe_requires("cloe-plugin-minimator") - cloe_requires("cloe-plugin-mocks") - cloe_requires("cloe-plugin-noisy-sensor") - cloe_requires("cloe-plugin-speedometer") - cloe_requires("cloe-plugin-virtue") + self.requires("boost/1.74.0") + self.requires("cli11/2.3.2", private=True) + self.requires("eigen/3.4.0") + self.requires("fmt/9.1.0") + self.requires("incbin/cci.20211107"), + self.requires("inja/3.4.0") + self.requires("nlohmann_json/3.11.3") + self.requires("spdlog/1.11.0") + if self.options.engine_server: + self.requires("oatpp/1.3.0", private=True) if self.options.with_esmini: - cloe_requires("cloe-plugin-esmini") + self.requires("esmini/2.37.4@cloe/stable") if self.options.with_vtd: - cloe_requires("cloe-plugin-vtd") - - boost_version = "1.74.0" - if self.options.with_engine: - cloe_requires("cloe-engine") + self.requires("vtd-api/2022.3@cloe/stable", private=True) - # Overrides: self.requires("zlib/1.2.13", override=True) - self.requires("fmt/9.1.0", override=True) - self.requires("inja/3.4.0", override=True) - self.requires("nlohmann_json/3.11.2", override=True) - self.requires("incbin/cci.20211107", override=True), - self.requires(f"boost/{boost_version}", override=True) + + def build_requirements(self): + self.test_requires("gtest/1.14.0") + self.test_requires("sol2/3.3.0") + + def layout(self): + cmake.cmake_layout(self) + self.cpp.build.bindirs = ["bin"] + self.cpp.source.includedirs.append(os.path.join(self.folders.build, "include")) + + def generate(self): + # The version as a single 32-bit number takes the format: + # + # (EPOCH << 24) | (MAJOR_VERSION << 16) | (MINOR_VERSION << 8) | PATCH_VERSION + # + # Each version consists of at most 8 bits, so 256 potential values, including 0. + # The epoch starts with 0, and is bumped after each version naming scheme. + semver = SemVer(self.version, True) + version_u32 = (0<<24) | (semver.major << 16) | (semver.minor << 8) | semver.patch + + tc = cmake.CMakeToolchain(self) + tc.cache_variables["CMAKE_EXPORT_COMPILE_COMMANDS"] = True + tc.cache_variables["CMAKE_MODULE_PATH"] = self.source_folder + "/runtime/cmake" + tc.cache_variables["FABLE_VERSION"] = self.version + tc.cache_variables["FABLE_VERSION_U32"] = version_u32 + tc.cache_variables["FABLE_ALLOW_COMMENTS"] = self.options.fable_allow_comments + tc.cache_variables["CLOE_PROJECT_VERSION"] = self.version + tc.cache_variables["CLOE_VERSION"] = self.version + tc.cache_variables["CLOE_VERSION_U32"] = version_u32 + tc.cache_variables["CLOE_ENGINE_WITH_SERVER"] = self.options.engine_server + tc.cache_variables["CLOE_WITH_ESMINI"] = self.options.with_esmini + tc.cache_variables["CLOE_WITH_VTD"] = self.options.with_vtd + tc.generate() + + def build(self): + cm = cmake.CMake(self) + if self.should_configure: + cm.configure() + if self.should_build: + cm.build() + if self.should_test: + cm.test() + + def package(self): + if self.should_install: + cm = cmake.CMake(self) + cm.install() + + # Package license files for compliance + for meta, dep in self.dependencies.items(): + if dep.package_folder is None: + continue + ref = str(meta.ref) + name = ref[: str(ref).index("/")] + files.copy( + self, + "*", + src=os.path.join(dep.package_folder, "licenses"), + dst=os.path.join(self.package_folder, "licenses", name), + ) + + def package_info(self): + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_file_name", "cloe") + self.cpp_info.set_property("pkg_config_name", "cloe") + + self.cpp_info.components["fable"].libs = ["fable"] + self.cpp_info.components["fable"].set_property("cmake_file_name", "fable") + self.cpp_info.components["fable"].set_property("cmake_target_name", "fable::fable") + self.cpp_info.components["fable"].set_property("pkg_config_name", "fable") + + self.cpp_info.components["runtime"].libs = ["cloe-runtime"] + self.cpp_info.components["runtime"].requires = ["fable"] + self.cpp_info.components["runtime"].set_property("cmake_file_name", "cloe-runtime") + self.cpp_info.components["runtime"].set_property("cmake_target_name", "cloe::runtime") + self.cpp_info.components["runtime"].set_property("pkg_config_name", "cloe-runtime") + + if self.settings.os == "Linux": + self.cpp_info.system_libs.append("pthread") + self.cpp_info.system_libs.append("dl") + + # Linking to libstdc++fs is required on GCC < 9. + # (GCC compilers with version < 7 have no std::filesystem support.) + # No consideration has been made yet for other compilers, + # please add them here as necessary. + if self.settings.get_safe("compiler") == "gcc" and self.settings.get_safe("compiler.version") in ["7", "8"]: + self.cpp_info.system_libs = ["stdc++fs"] + + self.cpp_info.libs = files.collect_libs(self) + if not self.in_local_cache: # editable build + self.cpp_info.builddirs.append(os.path.join(self.source_folder, "cmake")) + self.cpp_info.includedirs.append(os.path.join(self.build_folder, "include")) + bindir = os.path.join(self.build_folder, "bin") + libdir = os.path.join(self.build_folder, "lib"); + else: + self.cpp_info.builddirs.append(os.path.join("lib", "cmake", "cloe")) + bindir = os.path.join(self.package_folder, "bin") + libdir = None + + self.output.info(f"Appending PATH environment variable: {bindir}") + self.runenv_info.prepend_path("PATH", bindir) + if libdir is not None: + self.output.info(f"Appending LD_LIBRARY_PATH environment variable: {libdir}") + self.runenv_info.append_path("LD_LIBRARY_PATH", libdir) diff --git a/docs/develop/building-cloe.rst b/docs/develop/building-cloe.rst index e3c7989b4..bb64847fe 100644 --- a/docs/develop/building-cloe.rst +++ b/docs/develop/building-cloe.rst @@ -29,7 +29,7 @@ directory of every Cloe package (e.g. in ``plugins/basic/``): .. comment: The path below is relative to the project docs folder, not this file. - .. runcmd:: make -C ../models help + .. runcmd:: bash -c "make -C ../models help | sed -e 's/\x1b\[[0-9;]*m//g'" :replace: "PACKAGE_DIR:.*\\//PACKAGE_DIR: \\/" ``conanfile.py`` @@ -61,22 +61,56 @@ Verify that the cloe-plugin-basic package is currently in editable mode:: make status .. note:: - Positive-Example: + Positive-Example:: - .. code-block:: + editable : cloe-plugin-basic/0.18.0-rc5-3-g53c80db@cloe/develop - editable : cloe-plugin-basic/0.18.0-rc5-3-g53c80db@cloe/develop + Negative-Example:: - Negative-Example: - - .. code-block:: - - ok : cloe-plugin-basic/0.18.0-rc5-3-g53c80db@cloe/develop + ok : cloe-plugin-basic/0.18.0-rc5-3-g53c80db@cloe/develop Now, you can build the package binaries in your local working directory:: make clean all +The next time when Conan needs the package ``cloe-plugin-basic`` in +this version, it will resolve the include and library directories +to this local build. It is important to understand that you as a +developer are now responsible for ABI compatibility!! + +.. note:: + Conan can build packages with any constellation of dependencies that + you may require. This means that it is necessary to build an individual + package in a way that is compatible with the final composition. + + For example, it may be that the entire set of packages as defined by + the ``cloe-meta`` package require ``boost/1.65.1``. When building + the ``basic`` plugin as in this example, it has no way of knowing + that this version of Boost will be used when building ``cloe-engine``. + Therefore Conan will use the latest version of the ``boost`` package + it can find, such as ``boost/1.78.0``. + + In normal non-editable builds, Conan tracks these potential + incompatibilities and prevents you from incorrect combinations. + In editable mode however, you are responsible. Combining code + linked to two different versions of Boost is undefined behavior + and will lead to segfaults or worse! + + The solution to this dilemma is to let Conan know when making + a local build to use the final composition configuration for + resolving dependency configurations. This can be done by + generating a lockfile first of the final composition, and + using this lockfile when building a part locally. + + This is common enough that there is a simple mechanism baked + into the Makefiles to use a Conan recipe for automatically + generating and using a lockfile:: + + make clean all LOCKFILE_SOURCE=${CLOE_ROOT}/conanfile-meta.py + + where ``${CLOE_ROOT}`` is the path to the repository root; for + the ``basic`` plugin, this is ``../..``. + Since the package is in editable mode, the binaries will be created in the ``./build/`` directory in your package sub-directory. @@ -91,6 +125,105 @@ Verify the package status:: If you execute the latter command from the top-level directory, you will see the status of all Cloe packages. +Practical Example +""""""""""""""""" + +Let's apply the above to a very practical example involving ``cloe-engine``. +Assume the following situation: I checkout a develop branch, such as +``develop``, with the intention of modifying the ``cloe-engine`` package. + +First, because I am going to make changes, I disable the use of ``git describe`` +for versioning by explicitely setting a version:: + + echo "0.99.0-develop" > VERSION + +Then I make sure the entire project is exported:: + + make export-all + +.. note:: + This is roughtly equivalent to:: + + ( cd fable && conan export conanfile.py fable/0.99.0-develop@cloe/develop) + ( cd runtime && conan export conanfile.py cloe-runtime/0.99.0-develop@cloe/develop) + ... + +If there are any changes in other packages, I want to pick up those as well. +I let Conan know that I want to use ``cloe-engine`` in editable mode:: + + cd engine + make editable + +.. note:: + This is equivalent to:: + + cd engine + conan editable add conanfile cloe-engine/0.99.0-develop@cloe/develop + +TODO: This section + +Now, I need to choose a configuration that I want to use for testing the +entire set of packages. I can use a configuration in the ``tests/`` directory, +such as ``tests/conanfile_deployment.py``. +I use this when building ``cloe-engine`` as the source for creating a lockfile:: + + cd engine + make clean all LOCKFILE_SOURCE=../tests/conanfile_deployment.py + +This will automatically build any missing dependencies that are necessary for +building ``cloe-engine``, after which it will build ``cloe-engine`` locally. + +Before running any tests, I may need to make sure any additional dependencies +not required by ``cloe-engine`` but required for the test execution are +built:: + + cloe-launch prepare tests/conanfile_deployment.py + +.. note:: + This is *approximately* equivalent to:: + + conan install ../tests/conanfile_deployment.py --build=outdated --build=cascade + +Once this is complete, we can launch into a correctly configured shell, +with ``PATH`` and ``LD_LIBRARY_PATH`` set so that the shell can find +``cloe-engine`` and it can find required libraries and plugins. + +.. code-block:: + + cloe-launch shell -c tests/conanfile_deployment.py + +And at this point we are done and can run tests, make modifications +to the editable ``cloe-engine`` package, rebuild, and run tests again:: + + bats tests + $EDITOR engine/src/main.cpp + make -C engine all + bats tests + + +Superbuild +---------- + +The practical example of in-source builds above was one of the easiest +configurations we could choose. It becomes more arduous when we want to +edit packages that other packages in turn depend on, because then we need +to compile multiple packages by hand in the correct order. + +To side-step all of this, we have the ``cloe`` package, which is a +super-build of all other packages. + +You can build in the Conan cache with:: + + make package + +You can build it locally with:: + + make all + +You can then launch a virtual environment with ``cloe-launch``:: + + make editable + cloe-launch shell tests/conanfile_superbuild.py .. _Conan local cache: https://docs.conan.io/en/latest/mastering/custom_cache.html .. _Conan CMake integration: https://docs.conan.io/en/latest/integrations/build_system/cmake.html diff --git a/docs/install.rst b/docs/install.rst index 8d0dc5442..39cd6e4dd 100644 --- a/docs/install.rst +++ b/docs/install.rst @@ -69,14 +69,15 @@ Build Cloe Packages ------------------- To build all packages, you should run the following:: - make export-vendor package + make export-vendor export-all + make -C meta package This will export all Conan recipes from this repository and create the cloe package. Conan will download and build all necessary dependencies. Should any errors occur during the build, you may have to force Conan to build all packages instead of re-using packages it finds:: - make package CONAN_OPTIONS="--build" + make -C meta package CONAN_OPTIONS="--build" .. note:: Depending on your Conan profile, building the Cloe packages can involve @@ -88,16 +89,16 @@ all packages instead of re-using packages it finds:: If you like, you can inspect what a Conan Cloe package looks like by browsing the Conan cache directory under ``~/.conan/data/cloe``. -Run ``make help`` to get an overview of the available targets we expect you to -use. For more details on how this is done, have a look at the Makefiles in the -repository root. +Run ``make help`` to get an overview of the available targets we anticipate you +may want to use. For more details on how this is done, have a look at the +Makefiles in the repository root. Run System Tests ---------------- To check that everything is working as it should, we recommend you run the included test suite once before commencing with anything else:: - make export export-vendor smoketest-deps smoketest + make export-vendor export-all smoketest-deps smoketest .. _Conan: https://conan.io .. _Conan documentation: https://docs.conan.io/en/latest/ diff --git a/engine/CMakeLists.txt b/engine/CMakeLists.txt index ff3e0ad5b..abf653f82 100644 --- a/engine/CMakeLists.txt +++ b/engine/CMakeLists.txt @@ -1,18 +1,17 @@ -cmake_minimum_required(VERSION 3.15 FATAL_ERROR) +cmake_minimum_required(VERSION 3.15...3.27 FATAL_ERROR) project(cloe_engine LANGUAGES CXX) -set(target cloe-engine) -set(output cloe-engine) -set(libstack cloe-stack) - -find_package(cloe-runtime REQUIRED) -find_package(cloe-models REQUIRED) -find_package(fable REQUIRED) -find_package(Boost REQUIRED) -find_package(CLI11 REQUIRED) +set(CLOE_FIND_PACKAGES ON CACHE BOOL "Call find_package() for cloe packages") +if(CLOE_FIND_PACKAGES) + find_package(fable REQUIRED QUIET) + find_package(cloe-runtime REQUIRED QUIET) + find_package(cloe-models REQUIRED QUIET) +endif() +find_package(Boost REQUIRED QUIET) +find_package(CLI11 REQUIRED QUIET) set(THREADS_PREFER_PTHREAD_FLAG ON) -find_package(Threads REQUIRED) +find_package(Threads REQUIRED QUIET) include(TargetLinting) include(GNUInstallDirs) @@ -22,22 +21,34 @@ string(TIMESTAMP CLOE_ENGINE_TIMESTAMP "%Y-%m-%d") set(CLOE_ENGINE_VERSION ${CLOE_PROJECT_VERSION}) set(PROJECT_GIT_REF "unknown") -# Library ------------------------------------------------------------ -add_library(${libstack} +# Library libstack --------------------------------------------------- +message(STATUS "Building cloe-stacklib library.") +add_library(cloe-stacklib STATIC + src/stack.hpp src/stack.cpp + src/plugin.hpp src/plugin.cpp + + # Built-in plugins: + src/plugins/nop_controller.cpp + src/plugins/nop_controller.hpp + src/plugins/nop_simulator.cpp + src/plugins/nop_simulator.hpp ) -set_target_properties(${libstack} PROPERTIES +add_library(cloe::stacklib ALIAS cloe-stacklib) +set_target_properties(cloe-stacklib PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON + OUTPUT_NAME stack ) -target_include_directories(${libstack} +target_include_directories(cloe-stacklib PRIVATE src ) -target_link_libraries(${libstack} +target_link_libraries(cloe-stacklib PUBLIC cloe::runtime + cloe::models fable::fable Boost::headers Threads::Threads @@ -46,91 +57,90 @@ target_link_libraries(${libstack} include(CTest) if(BUILD_TESTING) - find_package(GTest REQUIRED) + find_package(GTest REQUIRED QUIET) include(GoogleTest) - set(test-libstack test-${libstack}) - add_executable(${test-libstack} + message(STATUS "Building test-stacklib executable.") + add_executable(test-stacklib src/stack_test.cpp ) - set_target_properties(${test-libstack} PROPERTIES + set_target_properties(test-stacklib PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON ) - target_link_libraries(${test-libstack} + target_link_libraries(test-stacklib GTest::gtest GTest::gtest_main Boost::boost cloe::models - ${libstack} + cloe::stacklib ) - gtest_add_tests(TARGET ${test-libstack}) + gtest_add_tests(TARGET test-stacklib) endif() # Executable --------------------------------------------------------- -add_executable(${target} +add_executable(cloe-engine src/main.cpp src/main_stack.cpp src/coordinator.cpp - src/plugins/nop_controller.cpp - src/plugins/nop_simulator.cpp src/simulation.cpp src/simulation_context.cpp src/utility/command.cpp ) -set_target_properties(${target} PROPERTIES +set_target_properties(cloe-engine PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON - OUTPUT_NAME ${output} + OUTPUT_NAME cloe-engine ) -target_compile_definitions(${target} +target_compile_definitions(cloe-engine PRIVATE CLOE_ENGINE_VERSION="${CLOE_ENGINE_VERSION}" CLOE_ENGINE_TIMESTAMP="${CLOE_ENGINE_TIMESTAMP}" PROJECT_SOURCE_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}\" ) -set_target_linting(${target}) -target_include_directories(${target} +target_include_directories(cloe-engine PRIVATE src ) -target_link_libraries(${target} +target_link_libraries(cloe-engine PRIVATE CLI11::CLI11 cloe::models - ${libstack} + cloe::stacklib ) option(CLOE_ENGINE_WITH_SERVER "Enable integrated server component?" ON) if(CLOE_ENGINE_WITH_SERVER) message(STATUS "-> Enable server component") - find_package(cloe-oak REQUIRED) - target_sources(${target} + if(CLOE_FIND_PACKAGES) + find_package(cloe-oak REQUIRED QUIET) + endif() + target_sources(cloe-engine PRIVATE src/server.cpp ) - target_link_libraries(${target} + target_link_libraries(cloe-engine PRIVATE cloe::oak ) - target_compile_definitions(${target} + target_compile_definitions(cloe-engine PRIVATE CLOE_ENGINE_WITH_SERVER=1 ) else() message(STATUS "-> Disable server component") - target_sources(${target} + target_sources(cloe-engine PRIVATE src/server_mock.cpp ) - target_compile_definitions(${target} + target_compile_definitions(cloe-engine PRIVATE CLOE_ENGINE_WITH_SERVER=0 ) endif() # Installation ------------------------------------------------------- -install(TARGETS ${target} +install(TARGETS cloe-engine RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) diff --git a/engine/conanfile.py b/engine/conanfile.py index 5e9866f86..6593e1569 100644 --- a/engine/conanfile.py +++ b/engine/conanfile.py @@ -56,10 +56,10 @@ def requirements(self): self.requires(f"cloe-oak/{self.version}@cloe/develop", private=True) self.requires("boost/1.74.0") self.requires("fmt/9.1.0", override=True) - self.requires("nlohmann_json/3.11.2", override=True) + self.requires("nlohmann_json/3.11.3", override=True) def build_requirements(self): - self.test_requires("gtest/1.13.0") + self.test_requires("gtest/1.14.0") def layout(self): cmake.cmake_layout(self) @@ -113,7 +113,8 @@ def package_info(self): self.cpp_info.system_libs.append("dl") if self.in_local_cache: bindir = os.path.join(self.package_folder, "bin") - else: - bindir = os.path.join(self.build_folder, str(self.settings.build_type), "bin") + else: # editable mode + bindir = os.path.join(self.build_folder) + self.output.info(f"Appending PATH environment variable: {bindir}") - self.env_info.PATH.append(bindir) + self.runenv_info.prepend_path("PATH", bindir) diff --git a/fable/CMakeLists.txt b/fable/CMakeLists.txt index b7ee95e1e..e4969f619 100644 --- a/fable/CMakeLists.txt +++ b/fable/CMakeLists.txt @@ -1,7 +1,9 @@ -cmake_minimum_required(VERSION 3.15 FATAL_ERROR) +cmake_minimum_required(VERSION 3.15...3.27 FATAL_ERROR) project(fable LANGUAGES CXX) +option(FABLE_ALLOW_COMMENTS "Allow comments when parsing JSON?" ON) + # NOTE: The variable FABLE_VERSION is used throughout this CMakeLists file # and is supplied from Conan or by hand on the command line. set(FABLE_VERSION "0.0.0-undefined" CACHE STRING "Fable version as MAJOR.MINOR.PATCH string") @@ -10,10 +12,11 @@ set(FABLE_VERSION_U32 0 CACHE STRING "Fable version as (MAJOR<<16)|(MINOR<<8)|PA include(GNUInstallDirs) # Library ------------------------------------------------------------ -find_package(fmt REQUIRED) -find_package(nlohmann_json REQUIRED) +find_package(fmt REQUIRED QUIET) +find_package(nlohmann_json REQUIRED QUIET) file(GLOB fable_PUBLIC_HEADERS "include/**/*.hpp") +message(STATUS "Building fable library [with comments=${FABLE_ALLOW_COMMENTS}].") add_library(fable # find src -type f -name "*.cpp" \! -name "*_test.cpp" src/fable/conf.cpp @@ -55,7 +58,6 @@ target_link_libraries(fable stdc++fs ) -option(FABLE_ALLOW_COMMENTS "Allow comments when parsing JSON?" ON) if(FABLE_ALLOW_COMMENTS) target_compile_definitions(fable PRIVATE PARSE_JSON_WITH_COMMENTS=true) else() @@ -63,14 +65,14 @@ else() endif() # Testing ------------------------------------------------------------ -set(CMAKE_CTEST_ARGUMENTS "--output-on-failure") include(CTest) if(BUILD_TESTING) - find_package(GTest REQUIRED) - find_package(Boost COMPONENTS headers filesystem REQUIRED) - find_package(sol2 REQUIRED) + find_package(GTest REQUIRED QUIET) + find_package(Boost COMPONENTS headers filesystem REQUIRED QUIET) + find_package(sol2 REQUIRED QUIET) include(GoogleTest) + message(STATUS "Building test-fable executable.") add_executable(test-fable # find src -type f -name "*_test.cpp" src/fable/version_test.cpp diff --git a/fable/conanfile.py b/fable/conanfile.py index 047b41c3a..503b19740 100644 --- a/fable/conanfile.py +++ b/fable/conanfile.py @@ -47,10 +47,10 @@ def set_version(self): def requirements(self): self.requires("fmt/9.1.0") - self.requires("nlohmann_json/3.11.2") + self.requires("nlohmann_json/3.11.3") def build_requirements(self): - self.test_requires("gtest/1.13.0") + self.test_requires("gtest/1.14.0") self.test_requires("boost/1.74.0") self.test_requires("sol2/3.3.0") diff --git a/fable/examples/contacts/CMakeLists.txt b/fable/examples/contacts/CMakeLists.txt index a3b1961df..eb04d7f1c 100644 --- a/fable/examples/contacts/CMakeLists.txt +++ b/fable/examples/contacts/CMakeLists.txt @@ -1,21 +1,20 @@ -cmake_minimum_required(VERSION 3.15 FATAL_ERROR) +cmake_minimum_required(VERSION 3.15...3.27 FATAL_ERROR) project(fable_example_contacts LANGUAGES CXX) -find_package(CLI11 REQUIRED) -find_package(fable REQUIRED) -find_package(fmt REQUIRED) +find_package(CLI11 REQUIRED QUIET) +find_package(fable REQUIRED QUIET) +find_package(fmt REQUIRED QUIET) # Executable --------------------------------------------------------- -set(target contacts) -add_executable(${target} +add_executable(contacts src/main.cpp ) -set_target_properties(${target} PROPERTIES +set_target_properties(contacts PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON ) -target_link_libraries(${target} +target_link_libraries(contacts PRIVATE fable::fable fmt::fmt diff --git a/fable/examples/simple_config/CMakeLists.txt b/fable/examples/simple_config/CMakeLists.txt index 51d76b878..7917c1e9a 100644 --- a/fable/examples/simple_config/CMakeLists.txt +++ b/fable/examples/simple_config/CMakeLists.txt @@ -1,20 +1,19 @@ -cmake_minimum_required(VERSION 3.15 FATAL_ERROR) +cmake_minimum_required(VERSION 3.15...3.27 FATAL_ERROR) project(fable_example_simple_config LANGUAGES CXX) -find_package(CLI11 REQUIRED) -find_package(fable REQUIRED) +find_package(CLI11 REQUIRED QUIET) +find_package(fable REQUIRED QUIET) # Executable --------------------------------------------------------- -set(target simple-config) -add_executable(${target} +add_executable(simple-config src/main.cpp ) -set_target_properties(${target} PROPERTIES +set_target_properties(simple-config PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON ) -target_link_libraries(${target} +target_link_libraries(simple-config PRIVATE fable::fable CLI11::CLI11 diff --git a/fable/examples/stress/CMakeLists.txt b/fable/examples/stress/CMakeLists.txt index 0233ff7db..bb462b50d 100644 --- a/fable/examples/stress/CMakeLists.txt +++ b/fable/examples/stress/CMakeLists.txt @@ -1,12 +1,12 @@ -cmake_minimum_required(VERSION 3.15 FATAL_ERROR) +cmake_minimum_required(VERSION 3.15...3.27 FATAL_ERROR) project(fable_stress_test LANGUAGES CXX) set(LARGE_STRUCT_SIZE 1000 CACHE NUMBER "Number of members of Large struct") -find_package(CLI11 REQUIRED) -find_package(fable REQUIRED) -find_package(fmt REQUIRED) +find_package(CLI11 REQUIRED QUIET) +find_package(fable REQUIRED QUIET) +find_package(fmt REQUIRED QUIET) # Executable --------------------------------------------------------- add_custom_command( diff --git a/fable/test_v2_package/CMakeLists.txt b/fable/test_v2_package/CMakeLists.txt index a88553d3b..162cf5168 100644 --- a/fable/test_v2_package/CMakeLists.txt +++ b/fable/test_v2_package/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.15 FATAL_ERROR) +cmake_minimum_required(VERSION 3.15...3.27 FATAL_ERROR) project(fable_examples) diff --git a/models/CMakeLists.txt b/models/CMakeLists.txt index b3d436fce..881d7d09d 100644 --- a/models/CMakeLists.txt +++ b/models/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.15 FATAL_ERROR) +cmake_minimum_required(VERSION 3.15...3.27 FATAL_ERROR) project(cloe-models LANGUAGES CXX) @@ -6,16 +6,16 @@ include(GNUInstallDirs) include(TargetLinting) # Module ------------------------------------------------------------- -set(target cloe-models) -set(alias cloe::models) - -find_package(cloe-runtime REQUIRED) -find_package(Eigen3 REQUIRED) -find_package(Boost COMPONENTS headers REQUIRED) +set(CLOE_FIND_PACKAGES ON CACHE BOOL "Call find_package() for cloe packages") +if(CLOE_FIND_PACKAGES) + find_package(cloe-runtime REQUIRED QUIET) +endif() +find_package(Eigen3 REQUIRED QUIET) +find_package(Boost COMPONENTS headers REQUIRED QUIET) -message(STATUS "-> Building ${output} library.") -file(GLOB ${target}_PUBLIC_HEADERS "include/**/*.hpp") -add_library(${target} +message(STATUS "Building cloe-models library.") +file(GLOB cloe-models_PUBLIC_HEADERS "include/**/*.hpp") +add_library(cloe-models # find src -type f -name "*.cpp" \! -name "*_test.cpp" src/cloe/component/lane_boundary.cpp src/cloe/component/utility/ego_sensor_canon.cpp @@ -23,21 +23,20 @@ add_library(${target} src/cloe/utility/actuation_state.cpp # For IDE integration - ${${target}_PUBLIC_HEADERS} + ${cloe-models_PUBLIC_HEADERS} ) -add_library(${alias} ALIAS ${target}) -set_target_properties(${target} PROPERTIES +add_library(cloe::models ALIAS cloe-models) +set_target_properties(cloe-models PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON VERSION ${CLOE_PROJECT_VERSION} ) -set_target_linting(${target}) -target_include_directories(${target} +target_include_directories(cloe-models PUBLIC "$" "$" ) -target_link_libraries(${target} +target_link_libraries(cloe-models PUBLIC cloe::runtime Boost::headers @@ -47,9 +46,10 @@ target_link_libraries(${target} # Testing ------------------------------------------------------------- include(CTest) if(BUILD_TESTING) - find_package(GTest REQUIRED) + find_package(GTest REQUIRED QUIET) include(GoogleTest) + message(STATUS "Building test-models executable.") add_executable(test-models # find src -type f -name "*_test.cpp" src/cloe/component/gearbox_actuator_test.cpp @@ -68,13 +68,13 @@ if(BUILD_TESTING) GTest::gtest_main Boost::boost cloe::runtime - ${target} + cloe-models ) gtest_add_tests(TARGET test-models) endif() # Installation ------------------------------------------------------- -install(TARGETS ${target} +install(TARGETS cloe-models LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE diff --git a/models/conanfile.py b/models/conanfile.py index e35e7cbf8..f6ab6aa4f 100644 --- a/models/conanfile.py +++ b/models/conanfile.py @@ -46,7 +46,7 @@ def requirements(self): self.requires("eigen/3.4.0") def build_requirements(self): - self.test_requires("gtest/1.13.0") + self.test_requires("gtest/1.14.0") def layout(self): cmake.cmake_layout(self) diff --git a/oak/CMakeLists.txt b/oak/CMakeLists.txt index 4c17f1720..f64491cee 100644 --- a/oak/CMakeLists.txt +++ b/oak/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.15 FATAL_ERROR) +cmake_minimum_required(VERSION 3.15...3.27 FATAL_ERROR) project(cloe-oak LANGUAGES CXX) @@ -6,37 +6,37 @@ include(GNUInstallDirs) include(TargetLinting) # Library ------------------------------------------------------------ -set(target cloe-oak) -set(alias cloe::oak) - -find_package(cloe-runtime REQUIRED) -find_package(oatpp REQUIRED) +set(CLOE_FIND_PACKAGES ON CACHE BOOL "Call find_package() for cloe packages") +if(CLOE_FIND_PACKAGES) + find_package(cloe-runtime REQUIRED QUIET) +endif() +find_package(oatpp REQUIRED QUIET) -file(GLOB ${target}_PUBLIC_HEADERS "include/**/*.hpp") -add_library(${target} +file(GLOB cloe-oak_PUBLIC_HEADERS "include/**/*.hpp") +message(STATUS "Building cloe-oak library.") +add_library(cloe-oak # find src -type f -name "*.cpp" \! -name "*_test.cpp" src/oak/registrar.cpp src/oak/server.cpp # For IDE integration - ${${target}_PUBLIC_HEADERS} + ${cloe-oak_PUBLIC_HEADERS} src/oak/request_stub.hpp src/oak/curl.hpp ) -add_library(${alias} ALIAS ${target}) -set_target_linting(${target}) -set_target_properties(${target} PROPERTIES +add_library(cloe::oak ALIAS cloe-oak) +set_target_properties(cloe-oak PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON ) -target_include_directories(${target} +target_include_directories(cloe-oak PRIVATE "$" PUBLIC "$" "$" ) -target_link_libraries(${target} +target_link_libraries(cloe-oak PUBLIC cloe::runtime oatpp::oatpp @@ -46,9 +46,10 @@ target_link_libraries(${target} # Testing ------------------------------------------------------------ include(CTest) if(BUILD_TESTING) - find_package(GTest REQUIRED) + find_package(GTest REQUIRED QUIET) include(GoogleTest) + message(STATUS "Building test-oak executable.") add_executable(test-oak # find src -type f -name "*_test.cpp" src/oak/route_muxer_test.cpp @@ -65,13 +66,13 @@ if(BUILD_TESTING) target_link_libraries(test-oak GTest::gtest GTest::gtest_main - ${target} + cloe-oak ) gtest_add_tests(TARGET test-oak) endif() # Installation ------------------------------------------------------- -install(TARGETS ${target} +install(TARGETS cloe-oak LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE diff --git a/oak/conanfile.py b/oak/conanfile.py index 2607abab2..abc79318a 100644 --- a/oak/conanfile.py +++ b/oak/conanfile.py @@ -45,7 +45,7 @@ def requirements(self): self.requires("oatpp/1.3.0") def build_requirements(self): - self.test_requires("gtest/1.13.0") + self.test_requires("gtest/1.14.0") def layout(self): cmake.cmake_layout(self) diff --git a/optional/vtd/CMakeLists.txt b/optional/vtd/CMakeLists.txt index 9452257da..847911d79 100644 --- a/optional/vtd/CMakeLists.txt +++ b/optional/vtd/CMakeLists.txt @@ -1,13 +1,13 @@ -cmake_minimum_required(VERSION 3.15 FATAL_ERROR) +cmake_minimum_required(VERSION 3.15...3.27 FATAL_ERROR) project(cloe_plugin_vtd LANGUAGES CXX) # Cloe Plugin -------------------------------------------------------- -find_package(vtd-api REQUIRED) -find_package(cloe-runtime REQUIRED) -find_package(cloe-models REQUIRED) -find_package(cloe-osi REQUIRED) -find_package(Boost REQUIRED) +find_package(vtd-api REQUIRED QUIET) +find_package(cloe-runtime REQUIRED QUIET) +find_package(cloe-models REQUIRED QUIET) +find_package(cloe-osi REQUIRED QUIET) +find_package(Boost REQUIRED QUIET) add_library(vtd-object-lib STATIC src/omni_sensor_component.cpp @@ -51,7 +51,7 @@ cloe_add_plugin( include(CTest) if(BUILD_TESTING) - find_package(GTest REQUIRED) + find_package(GTest REQUIRED QUIET) include(GoogleTest) add_executable(test-vtd-binding diff --git a/optional/vtd/conanfile.py b/optional/vtd/conanfile.py index 9763d6a0c..f955e93e0 100644 --- a/optional/vtd/conanfile.py +++ b/optional/vtd/conanfile.py @@ -50,14 +50,14 @@ def requirements(self): # Overrides, same as in the cloe conanfile.py: self.requires("protobuf/[>=3.9.1]", override=True) - self.requires("zlib/1.2.12", override=True) + self.requires("zlib/1.2.13", override=True) self.requires("fmt/9.1.0", override=True) self.requires("inja/3.4.0", override=True) - self.requires("nlohmann_json/3.11.2", override=True) + self.requires("nlohmann_json/3.11.3", override=True) self.requires("incbin/cci.20211107", override=True), def build_requirements(self): - self.test_requires("gtest/1.13.0") + self.test_requires("gtest/1.14.0") def _compress_and_remove(self, dir): # reset() will remove the packages metadata diff --git a/optional/vtd/vendor/osi-sensor-1.0.0/CMakeLists.txt b/optional/vtd/vendor/osi-sensor-1.0.0/CMakeLists.txt index 4ae722682..d7a209ffe 100644 --- a/optional/vtd/vendor/osi-sensor-1.0.0/CMakeLists.txt +++ b/optional/vtd/vendor/osi-sensor-1.0.0/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.15 FATAL_ERROR) +cmake_minimum_required(VERSION 3.15...3.27 FATAL_ERROR) project(OSMPDummySensor LANGUAGES CXX) @@ -8,8 +8,8 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(VTD_ROOT "" CACHE STRING "Path to VTD root directory") # Dependencies -find_package(open_simulation_interface REQUIRED) -find_package(Protobuf CONFIG REQUIRED) +find_package(open_simulation_interface REQUIRED QUIET) +find_package(Protobuf CONFIG REQUIRED QUIET) find_library(VTD_OSI_LIBRARY NAME libopen_simulation_interface.so PATHS "${VTD_ROOT}/Data/Setups/Standard.OSI3/Bin/" NO_DEFAULT_PATH diff --git a/optional/vtd/vendor/protobuf-2.6.1/test_package/CMakeLists.txt b/optional/vtd/vendor/protobuf-2.6.1/test_package/CMakeLists.txt index c24d54471..bfee412c9 100644 --- a/optional/vtd/vendor/protobuf-2.6.1/test_package/CMakeLists.txt +++ b/optional/vtd/vendor/protobuf-2.6.1/test_package/CMakeLists.txt @@ -1,8 +1,8 @@ -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.15...3.27 FATAL_ERROR) project(test_package LANGUAGES CXX) -find_package(Protobuf CONFIG REQUIRED) +find_package(Protobuf CONFIG REQUIRED QUIET) add_executable(${PROJECT_NAME} test_package.cpp addressbook.proto) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/optional/vtd/vendor/vtd-api-2.2.0/CMakeLists.txt b/optional/vtd/vendor/vtd-api-2.2.0/CMakeLists.txt index d10a2075a..fd4bdd4e7 100644 --- a/optional/vtd/vendor/vtd-api-2.2.0/CMakeLists.txt +++ b/optional/vtd/vendor/vtd-api-2.2.0/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.15 FATAL_ERROR) +cmake_minimum_required(VERSION 3.15...3.27 FATAL_ERROR) project(vtd_api LANGUAGES CXX VERSION 2.2.0) diff --git a/optional/vtd/vendor/vtd-api-2022.3/CMakeLists.txt b/optional/vtd/vendor/vtd-api-2022.3/CMakeLists.txt index 31c0fffb2..e43715364 100644 --- a/optional/vtd/vendor/vtd-api-2022.3/CMakeLists.txt +++ b/optional/vtd/vendor/vtd-api-2022.3/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.15 FATAL_ERROR) +cmake_minimum_required(VERSION 3.15...3.27 FATAL_ERROR) project(vtd_api LANGUAGES CXX VERSION 2022.3) diff --git a/osi/CMakeLists.txt b/osi/CMakeLists.txt index e5a2f5e96..3552594ac 100644 --- a/osi/CMakeLists.txt +++ b/osi/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.15 FATAL_ERROR) +cmake_minimum_required(VERSION 3.15...3.27 FATAL_ERROR) project(cloe-osi LANGUAGES CXX) @@ -6,13 +6,17 @@ include(GNUInstallDirs) include(TargetLinting) # Module ------------------------------------------------------------- -find_package(cloe-models REQUIRED) -find_package(cloe-runtime REQUIRED) -find_package(Eigen3 REQUIRED) -find_package(Boost COMPONENTS headers REQUIRED) -find_package(open_simulation_interface REQUIRED) -message(STATUS "-> Building cloe-osi library.") +set(CLOE_FIND_PACKAGES ON CACHE BOOL "Call find_package() for cloe packages") +if(CLOE_FIND_PACKAGES) + find_package(cloe-models REQUIRED QUIET) + find_package(cloe-runtime REQUIRED QUIET) +endif() +find_package(Eigen3 REQUIRED QUIET) +find_package(Boost COMPONENTS headers REQUIRED QUIET) +find_package(open_simulation_interface REQUIRED QUIET) + +message(STATUS "Building cloe-osi library.") file(GLOB cloe-osi_PUBLIC_HEADERS "include/**/*.hpp") add_library(cloe-osi # find src -type f -name "*.cpp" \! -name "*_test.cpp" @@ -48,9 +52,10 @@ target_link_libraries(cloe-osi # Testing ------------------------------------------------------------- include(CTest) if(BUILD_TESTING) - find_package(GTest REQUIRED) + find_package(GTest REQUIRED QUIET) include(GoogleTest) + message(STATUS "Building test-osi executable.") add_executable(test-osi # find src -type f -name "*_test.cpp" src/cloe/component/osi_sensor_test.cpp diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt new file mode 100644 index 000000000..b3987c5f4 --- /dev/null +++ b/plugins/CMakeLists.txt @@ -0,0 +1,50 @@ +# This CMakeLists.txt configures a super-build of all plugins. +# +# It is currently experimental. +# +# This supports two use-cases: +# +# 1. Creating a cloe-plugins-core package containing all plugins. +# 2. Creating a cloe package containing everything from this repo. +# +# Other use-cases are currently not supported. +# + +cmake_minimum_required(VERSION 3.15...3.27 FATAL_ERROR) + +if(NOT DEFINED PROJECT_NAME) + project(cloe_plugins_core LANGUAGES CXX) + + option(CLOE_WITH_ESMINI "Build simulator_esmini plugin?" ON) + + # Speed up configuration by only finding Cloe packages once + set(CLOE_FIND_PACKAGES ON CACHE BOOL "Call find_package() for cloe packages") + if(CLOE_FIND_PACKAGES) + find_package(cloe-runtime REQUIRED QUIET) + find_package(cloe-models REQUIRED QUIET) + set(CLOE_FIND_PACKAGES OFF FORCE) + endif() + + # Ensure output goes to one place so cloe-launch can find the plugins + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin) +elseif(NOT ${PROJECT_NAME} STREQUAL "cloe") + message(FATAL_ERROR "Building super-project unequal to cloe not suppoorted.") +endif() + +# Ensure we can test from this level. +include(CTest) + +add_subdirectory(basic) +add_subdirectory(clothoid_fit) +add_subdirectory(frustum_culling) +add_subdirectory(gndtruth_extractor) +add_subdirectory(minimator) +add_subdirectory(mocks) +add_subdirectory(noisy_sensor) +add_subdirectory(speedometer) +add_subdirectory(virtue) + +if(CLOE_WITH_ESMINI) + add_subdirectory(esmini) +endif() diff --git a/plugins/Makefile b/plugins/Makefile new file mode 100644 index 000000000..87c6e44df --- /dev/null +++ b/plugins/Makefile @@ -0,0 +1 @@ +include ../Makefile.package diff --git a/plugins/basic/CMakeLists.txt b/plugins/basic/CMakeLists.txt index 35a6c490f..e5851ad8e 100644 --- a/plugins/basic/CMakeLists.txt +++ b/plugins/basic/CMakeLists.txt @@ -1,9 +1,12 @@ -cmake_minimum_required(VERSION 3.15 FATAL_ERROR) +cmake_minimum_required(VERSION 3.15...3.27 FATAL_ERROR) project(cloe_plugin_basic LANGUAGES CXX) -find_package(cloe-runtime REQUIRED) -find_package(cloe-models REQUIRED) +set(CLOE_FIND_PACKAGES ON CACHE BOOL "Call find_package() for cloe packages") +if(CLOE_FIND_PACKAGES) + find_package(cloe-runtime REQUIRED QUIET) + find_package(cloe-models REQUIRED QUIET) +endif() include(CloePluginSetup) cloe_add_plugin( @@ -20,7 +23,7 @@ cloe_add_plugin( include(CTest) if(BUILD_TESTING) - find_package(GTest REQUIRED) + find_package(GTest REQUIRED QUIET) include(GoogleTest) add_executable(test-basic-controller diff --git a/plugins/basic/conanfile.py b/plugins/basic/conanfile.py index 8bfc5b671..d4417de60 100644 --- a/plugins/basic/conanfile.py +++ b/plugins/basic/conanfile.py @@ -1,6 +1,7 @@ # mypy: ignore-errors # pylint: skip-file +import os from pathlib import Path from conan import ConanFile @@ -43,7 +44,7 @@ def requirements(self): self.requires(f"cloe-models/{self.version}@cloe/develop") def build_requirements(self): - self.test_requires("gtest/1.13.0") + self.test_requires("gtest/1.14.0") def layout(self): cmake.cmake_layout(self) @@ -77,3 +78,7 @@ def package_info(self): self.cpp_info.set_property("cmake_find_mode", "both") self.cpp_info.set_property("cmake_file_name", self.name) self.cpp_info.set_property("pkg_config_name", self.name) + + if not self.in_local_cache: # editable mode + libdir = os.path.join(self.build_folder, "lib"); + self.runenv_info.append_path("LD_LIBRARY_PATH", libdir) diff --git a/plugins/clothoid_fit/CMakeLists.txt b/plugins/clothoid_fit/CMakeLists.txt index 64788208a..d4cb3f347 100644 --- a/plugins/clothoid_fit/CMakeLists.txt +++ b/plugins/clothoid_fit/CMakeLists.txt @@ -1,10 +1,13 @@ -cmake_minimum_required(VERSION 3.15 FATAL_ERROR) +cmake_minimum_required(VERSION 3.15...3.27 FATAL_ERROR) project(cloe_plugin_clothoid_fit LANGUAGES CXX) -find_package(cloe-runtime REQUIRED) -find_package(cloe-models REQUIRED) -find_package(Eigen3 REQUIRED) +set(CLOE_FIND_PACKAGES ON CACHE BOOL "Call find_package() for cloe packages") +if(CLOE_FIND_PACKAGES) + find_package(cloe-runtime REQUIRED QUIET) + find_package(cloe-models REQUIRED QUIET) +endif() +find_package(Eigen3 REQUIRED QUIET) add_library(g1-fitting-lib STATIC src/g1_fitting.cpp @@ -31,7 +34,7 @@ cloe_add_plugin( include(CTest) if(BUILD_TESTING) - find_package(GTest REQUIRED) + find_package(GTest REQUIRED QUIET) include(GoogleTest) add_executable(test-clothoid-fit diff --git a/plugins/clothoid_fit/conanfile.py b/plugins/clothoid_fit/conanfile.py index 853b566fd..4ad1f3892 100644 --- a/plugins/clothoid_fit/conanfile.py +++ b/plugins/clothoid_fit/conanfile.py @@ -35,7 +35,7 @@ def requirements(self): self.requires("eigen/3.4.0") def build_requirements(self): - self.test_requires("gtest/1.13.0") + self.test_requires("gtest/1.14.0") def layout(self): cmake.cmake_layout(self) diff --git a/plugins/conanfile.py b/plugins/conanfile.py new file mode 100644 index 000000000..bf301e21a --- /dev/null +++ b/plugins/conanfile.py @@ -0,0 +1,88 @@ +# mypy: ignore-errors +# pylint: skip-file + +import os +from pathlib import Path + +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools import cmake, files, scm, env + +required_conan_version = ">=1.52.0" + + +class CloeControllerBasic(ConanFile): + name = "cloe-plugins-core" + url = "https://github.com/eclipse/cloe" + description = "Cloe core plugins" + license = "Apache-2.0" + settings = "os", "compiler", "build_type", "arch" + generators = "CMakeDeps", "VirtualRunEnv" + no_copy_source = True + provides = [ + "cloe-plugin-basic", + "cloe-plugin-gndtruth-extractor", + "cloe-plugin-minimator", + "cloe-plugin-mocks", + "cloe-plugin-noisy-sensor", + "cloe-plugin-speedometer", + "cloe-plugin-virtue", + ] + exports_sources = [ + "*/src/*", + "*/include/*", + "*/ui/*", + "*/CMakeLists.txt", + ] + + def set_version(self): + version_file = Path(self.recipe_folder) / "../VERSION" + if version_file.exists(): + self.version = files.load(self, version_file).strip() + else: + git = scm.Git(self, self.recipe_folder) + self.version = git.run("describe --dirty=-dirty")[1:] + + def requirements(self): + self.requires(f"cloe-runtime/{self.version}@cloe/develop") + self.requires(f"cloe-models/{self.version}@cloe/develop") + + def build_requirements(self): + self.test_requires("gtest/1.14.0") + + def layout(self): + cmake.cmake_layout(self) + + def generate(self): + tc = cmake.CMakeToolchain(self) + tc.cache_variables["CMAKE_EXPORT_COMPILE_COMMANDS"] = True + tc.cache_variables["CLOE_PROJECT_VERSION"] = self.version + tc.cache_variables["TargetLintingExtended"] = True + tc.generate() + + def build(self): + cm = cmake.CMake(self) + if self.should_configure: + cm.configure() + if self.should_build: + cm.build() + if self.should_test: + cm.test() + + def package(self): + cm = cmake.CMake(self) + if self.should_install: + cm.install() + + def package_id(self): + self.info.requires["boost"].full_package_mode() + del self.info.options.pedantic + + def package_info(self): + self.cpp_info.set_property("cmake_find_mode", "both") + self.cpp_info.set_property("cmake_file_name", self.name) + self.cpp_info.set_property("pkg_config_name", self.name) + + if not self.in_local_cache: + libdir = os.path.join(self.build_folder, "lib"); + self.runenv_info.append_path("LD_LIBRARY_PATH", libdir) diff --git a/plugins/esmini/CMakeLists.txt b/plugins/esmini/CMakeLists.txt index 53edeb3df..3730f1872 100644 --- a/plugins/esmini/CMakeLists.txt +++ b/plugins/esmini/CMakeLists.txt @@ -1,11 +1,14 @@ -cmake_minimum_required(VERSION 3.15 FATAL_ERROR) +cmake_minimum_required(VERSION 3.15...3.27 FATAL_ERROR) project(cloe_plugin_esmini LANGUAGES CXX) -find_package(cloe-runtime REQUIRED) -find_package(cloe-models REQUIRED) -find_package(cloe-osi REQUIRED) -find_package(esmini REQUIRED) +set(CLOE_FIND_PACKAGES ON CACHE BOOL "Call find_package() for cloe packages") +if(CLOE_FIND_PACKAGES) + find_package(cloe-runtime REQUIRED QUIET) + find_package(cloe-models REQUIRED QUIET) + find_package(cloe-osi REQUIRED QUIET) +endif() +find_package(esmini REQUIRED QUIET) include(CloePluginSetup) cloe_add_plugin( @@ -24,7 +27,7 @@ cloe_add_plugin( include(CTest) if(BUILD_TESTING) - find_package(GTest REQUIRED) + find_package(GTest REQUIRED QUIET) include(GoogleTest) add_executable(test-esmini diff --git a/plugins/esmini/conanfile.py b/plugins/esmini/conanfile.py index 487a57bf0..91167f627 100644 --- a/plugins/esmini/conanfile.py +++ b/plugins/esmini/conanfile.py @@ -36,7 +36,7 @@ def requirements(self): self.requires("zlib/1.2.13", override=True) # conflict between boost & protobuf def build_requirements(self): - self.test_requires("gtest/1.13.0") + self.test_requires("gtest/1.14.0") def layout(self): cmake.cmake_layout(self) diff --git a/plugins/frustum_culling/CMakeLists.txt b/plugins/frustum_culling/CMakeLists.txt index da8e22870..4a2c1e2eb 100644 --- a/plugins/frustum_culling/CMakeLists.txt +++ b/plugins/frustum_culling/CMakeLists.txt @@ -1,11 +1,11 @@ -cmake_minimum_required(VERSION 3.15 FATAL_ERROR) +cmake_minimum_required(VERSION 3.15...3.27 FATAL_ERROR) project(cloe_plugin_frustum_culling LANGUAGES CXX) set(CLOE_FIND_PACKAGES ON CACHE BOOL "Call find_package() for cloe packages") if(CLOE_FIND_PACKAGES) - find_package(cloe-runtime REQUIRED) - find_package(cloe-models REQUIRED) + find_package(cloe-runtime REQUIRED QUIET) + find_package(cloe-models REQUIRED QUIET) endif() include(CloePluginSetup) @@ -29,7 +29,7 @@ cloe_add_plugin( set(CMAKE_CTEST_ARGUMENTS "--output-on-failure") include(CTest) if(BUILD_TESTING) - find_package(GTest REQUIRED) + find_package(GTest REQUIRED QUIET) include(GoogleTest) add_executable(test-frustum-culling diff --git a/plugins/frustum_culling/conanfile.py b/plugins/frustum_culling/conanfile.py index d70987b5d..7bacad4ef 100644 --- a/plugins/frustum_culling/conanfile.py +++ b/plugins/frustum_culling/conanfile.py @@ -42,10 +42,10 @@ def requirements(self): self.requires(f"cloe-runtime/{self.version}@cloe/develop") self.requires(f"cloe-models/{self.version}@cloe/develop") self.requires("fmt/9.1.0") - self.requires("nlohmann_json/3.11.2", override=True) + self.requires("nlohmann_json/3.11.3", override=True) def build_requirements(self): - self.test_requires("gtest/1.13.0") + self.test_requires("gtest/1.14.0") def layout(self): cmake.cmake_layout(self) diff --git a/plugins/gndtruth_extractor/CMakeLists.txt b/plugins/gndtruth_extractor/CMakeLists.txt index ba56fac47..099dabd49 100644 --- a/plugins/gndtruth_extractor/CMakeLists.txt +++ b/plugins/gndtruth_extractor/CMakeLists.txt @@ -1,9 +1,12 @@ -cmake_minimum_required(VERSION 3.15 FATAL_ERROR) +cmake_minimum_required(VERSION 3.15...3.27 FATAL_ERROR) project(cloe_plugin_gndtruth_extractor LANGUAGES CXX) -find_package(cloe-runtime REQUIRED) -find_package(cloe-models REQUIRED) +set(CLOE_FIND_PACKAGES ON CACHE BOOL "Call find_package() for cloe packages") +if(CLOE_FIND_PACKAGES) + find_package(cloe-runtime REQUIRED QUIET) + find_package(cloe-models REQUIRED QUIET) +endif() include(CloePluginSetup) cloe_add_plugin( @@ -18,7 +21,7 @@ cloe_add_plugin( include(CTest) if(BUILD_TESTING) - find_package(GTest REQUIRED) + find_package(GTest REQUIRED QUIET) include(GoogleTest) add_executable(test-gndtruth-extractor diff --git a/plugins/gndtruth_extractor/conanfile.py b/plugins/gndtruth_extractor/conanfile.py index 96ff71041..d3b1afcac 100644 --- a/plugins/gndtruth_extractor/conanfile.py +++ b/plugins/gndtruth_extractor/conanfile.py @@ -1,6 +1,7 @@ # mypy: ignore-errors # pylint: skip-file +import os from pathlib import Path from conan import ConanFile @@ -42,7 +43,7 @@ def requirements(self): self.requires(f"cloe-models/{self.version}@cloe/develop") def build_requirements(self): - self.test_requires("gtest/1.13.0") + self.test_requires("gtest/1.14.0") def layout(self): cmake.cmake_layout(self) @@ -76,3 +77,7 @@ def package_info(self): self.cpp_info.set_property("cmake_find_mode", f"both") self.cpp_info.set_property("cmake_file_name", self.name) self.cpp_info.set_property("pkg_config_name", self.name) + + if not self.in_local_cache: # editable mode + libdir = os.path.join(self.build_folder, "lib"); + self.runenv_info.append_path("LD_LIBRARY_PATH", libdir) diff --git a/plugins/minimator/CMakeLists.txt b/plugins/minimator/CMakeLists.txt index 4986e1855..3a084266d 100644 --- a/plugins/minimator/CMakeLists.txt +++ b/plugins/minimator/CMakeLists.txt @@ -1,9 +1,12 @@ -cmake_minimum_required(VERSION 3.15 FATAL_ERROR) +cmake_minimum_required(VERSION 3.15...3.27 FATAL_ERROR) project(cloe_plugin_minimator LANGUAGES CXX) -find_package(cloe-runtime REQUIRED) -find_package(cloe-models REQUIRED) +set(CLOE_FIND_PACKAGES ON CACHE BOOL "Call find_package() for cloe packages") +if(CLOE_FIND_PACKAGES) + find_package(cloe-runtime REQUIRED QUIET) + find_package(cloe-models REQUIRED QUIET) +endif() include(CloePluginSetup) cloe_add_plugin( @@ -20,7 +23,7 @@ cloe_add_plugin( include(CTest) if(BUILD_TESTING) - find_package(GTest REQUIRED) + find_package(GTest REQUIRED QUIET) include(GoogleTest) set(test-minimator test-${PROJECT_NAME}) diff --git a/plugins/minimator/conanfile.py b/plugins/minimator/conanfile.py index b0a59af0f..48b99e813 100644 --- a/plugins/minimator/conanfile.py +++ b/plugins/minimator/conanfile.py @@ -1,6 +1,7 @@ # mypy: ignore-errors # pylint: skip-file +import os from pathlib import Path from conan import ConanFile @@ -43,7 +44,7 @@ def requirements(self): self.requires(f"cloe-models/{self.version}@cloe/develop") def build_requirements(self): - self.test_requires("gtest/1.13.0") + self.test_requires("gtest/1.14.0") def layout(self): cmake.cmake_layout(self) @@ -77,3 +78,7 @@ def package_info(self): self.cpp_info.set_property("cmake_find_mode", "both") self.cpp_info.set_property("cmake_file_name", self.name) self.cpp_info.set_property("pkg_config_name", self.name) + + if not self.in_local_cache: # editable mode + libdir = os.path.join(self.build_folder, "lib"); + self.runenv_info.append_path("LD_LIBRARY_PATH", libdir) diff --git a/plugins/mocks/CMakeLists.txt b/plugins/mocks/CMakeLists.txt index b21f67bb0..afd20059a 100644 --- a/plugins/mocks/CMakeLists.txt +++ b/plugins/mocks/CMakeLists.txt @@ -1,9 +1,12 @@ -cmake_minimum_required(VERSION 3.15 FATAL_ERROR) +cmake_minimum_required(VERSION 3.15...3.27 FATAL_ERROR) project(cloe_plugin_mocks LANGUAGES CXX) -find_package(cloe-runtime REQUIRED) -find_package(cloe-models REQUIRED) +set(CLOE_FIND_PACKAGES ON CACHE BOOL "Call find_package() for cloe packages") +if(CLOE_FIND_PACKAGES) + find_package(cloe-runtime REQUIRED QUIET) + find_package(cloe-models REQUIRED QUIET) +endif() include(CloePluginSetup) cloe_add_plugin( diff --git a/plugins/mocks/conanfile.py b/plugins/mocks/conanfile.py index 27b2ffebb..39667172e 100644 --- a/plugins/mocks/conanfile.py +++ b/plugins/mocks/conanfile.py @@ -1,6 +1,7 @@ # mypy: ignore-errors # pylint: skip-file +import os from pathlib import Path from conan import ConanFile @@ -71,3 +72,7 @@ def package_info(self): self.cpp_info.set_property("cmake_find_mode", "both") self.cpp_info.set_property("cmake_file_name", self.name) self.cpp_info.set_property("pkg_config_name", self.name) + + if not self.in_local_cache: # editable mode + libdir = os.path.join(self.build_folder, "lib"); + self.runenv_info.append_path("LD_LIBRARY_PATH", libdir) diff --git a/plugins/noisy_sensor/CMakeLists.txt b/plugins/noisy_sensor/CMakeLists.txt index 0245e916d..d9e5c48d0 100644 --- a/plugins/noisy_sensor/CMakeLists.txt +++ b/plugins/noisy_sensor/CMakeLists.txt @@ -1,9 +1,12 @@ -cmake_minimum_required(VERSION 3.15 FATAL_ERROR) +cmake_minimum_required(VERSION 3.15...3.27 FATAL_ERROR) project(cloe_plugin_noisy_sensors LANGUAGES CXX) -find_package(cloe-runtime REQUIRED) -find_package(cloe-models REQUIRED) +set(CLOE_FIND_PACKAGES ON CACHE BOOL "Call find_package() for cloe packages") +if(CLOE_FIND_PACKAGES) + find_package(cloe-runtime REQUIRED QUIET) + find_package(cloe-models REQUIRED QUIET) +endif() include(CloePluginSetup) cloe_add_plugin( @@ -25,7 +28,7 @@ cloe_add_plugin( include(CTest) if(BUILD_TESTING) - find_package(GTest REQUIRED) + find_package(GTest REQUIRED QUIET) include(GoogleTest) add_executable(test-noisy-sensor diff --git a/plugins/noisy_sensor/conanfile.py b/plugins/noisy_sensor/conanfile.py index 1ec756da3..ff9a5fbb4 100644 --- a/plugins/noisy_sensor/conanfile.py +++ b/plugins/noisy_sensor/conanfile.py @@ -1,6 +1,7 @@ # mypy: ignore-errors # pylint: skip-file +import os from pathlib import Path from conan import ConanFile @@ -42,7 +43,7 @@ def requirements(self): self.requires(f"cloe-models/{self.version}@cloe/develop") def build_requirements(self): - self.test_requires("gtest/1.13.0") + self.test_requires("gtest/1.14.0") def layout(self): cmake.cmake_layout(self) @@ -76,3 +77,7 @@ def package_info(self): self.cpp_info.set_property("cmake_find_mode", "both") self.cpp_info.set_property("cmake_file_name", self.name) self.cpp_info.set_property("pkg_config_name", self.name) + + if not self.in_local_cache: # editable mode + libdir = os.path.join(self.build_folder, "lib"); + self.runenv_info.append_path("LD_LIBRARY_PATH", libdir) diff --git a/plugins/speedometer/CMakeLists.txt b/plugins/speedometer/CMakeLists.txt index d6465a593..1004d6fd4 100644 --- a/plugins/speedometer/CMakeLists.txt +++ b/plugins/speedometer/CMakeLists.txt @@ -1,9 +1,12 @@ -cmake_minimum_required(VERSION 3.15 FATAL_ERROR) +cmake_minimum_required(VERSION 3.15...3.27 FATAL_ERROR) project(cloe_plugin_speedometer LANGUAGES CXX) -find_package(cloe-runtime REQUIRED) -find_package(cloe-models REQUIRED) +set(CLOE_FIND_PACKAGES ON CACHE BOOL "Call find_package() for cloe packages") +if(CLOE_FIND_PACKAGES) + find_package(cloe-runtime REQUIRED QUIET) + find_package(cloe-models REQUIRED QUIET) +endif() include(CloePluginSetup) cloe_add_plugin( diff --git a/plugins/speedometer/conanfile.py b/plugins/speedometer/conanfile.py index 9ab5e1eda..e9e0ce661 100644 --- a/plugins/speedometer/conanfile.py +++ b/plugins/speedometer/conanfile.py @@ -1,6 +1,7 @@ # mypy: ignore-errors # pylint: skip-file +import os from pathlib import Path from conan import ConanFile @@ -71,3 +72,7 @@ def package_info(self): self.cpp_info.set_property("cmake_find_mode", "both") self.cpp_info.set_property("cmake_file_name", self.name) self.cpp_info.set_property("pkg_config_name", self.name) + + if not self.in_local_cache: # editable mode + libdir = os.path.join(self.build_folder, "lib"); + self.runenv_info.append_path("LD_LIBRARY_PATH", libdir) diff --git a/plugins/virtue/CMakeLists.txt b/plugins/virtue/CMakeLists.txt index 5cecbc970..7b92fc14e 100644 --- a/plugins/virtue/CMakeLists.txt +++ b/plugins/virtue/CMakeLists.txt @@ -1,9 +1,12 @@ -cmake_minimum_required(VERSION 3.15 FATAL_ERROR) +cmake_minimum_required(VERSION 3.15...3.27 FATAL_ERROR) project(cloe_plugin_virtue LANGUAGES CXX) -find_package(cloe-runtime REQUIRED) -find_package(cloe-models REQUIRED) +set(CLOE_FIND_PACKAGES ON CACHE BOOL "Call find_package() for cloe packages") +if(CLOE_FIND_PACKAGES) + find_package(cloe-runtime REQUIRED QUIET) + find_package(cloe-models REQUIRED QUIET) +endif() include(CloePluginSetup) cloe_add_plugin( diff --git a/plugins/virtue/conanfile.py b/plugins/virtue/conanfile.py index 5066a8cb4..3caf9d691 100644 --- a/plugins/virtue/conanfile.py +++ b/plugins/virtue/conanfile.py @@ -1,6 +1,7 @@ # mypy: ignore-errors # pylint: skip-file +import os from pathlib import Path from conan import ConanFile @@ -71,3 +72,7 @@ def package_info(self): self.cpp_info.set_property("cmake_find_mode", "both") self.cpp_info.set_property("cmake_file_name", self.name) self.cpp_info.set_property("pkg_config_name", self.name) + + if not self.in_local_cache: # editable mode + libdir = os.path.join(self.build_folder, "lib"); + self.runenv_info.append_path("LD_LIBRARY_PATH", libdir) diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index e44ba61a9..d49101630 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.15 FATAL_ERROR) +cmake_minimum_required(VERSION 3.15...3.27 FATAL_ERROR) project(cloe-runtime LANGUAGES CXX) @@ -8,23 +8,23 @@ set(CLOE_VERSION "0.0.0-undefined" CACHE STRING "Cloe version as MAJOR.MINOR.PAT set(CLOE_VERSION_U32 0 CACHE STRING "Cloe version as (MAJOR<<16)|(MINOR<<8)|PATCH integer") include(GNUInstallDirs) -include(cmake/TargetLinting.cmake) # Library ------------------------------------------------------------- -set(target cloe-runtime) -set(alias cloe::runtime) - -find_package(fable REQUIRED) -find_package(Boost COMPONENTS headers filesystem iostreams system REQUIRED) -find_package(spdlog REQUIRED) -find_package(inja REQUIRED) +set(CLOE_FIND_PACKAGES ON CACHE BOOL "Call find_package() for cloe packages") +if(CLOE_FIND_PACKAGES) + find_package(fable REQUIRED QUIET) +endif() +find_package(Boost COMPONENTS headers filesystem iostreams system REQUIRED QUIET) +find_package(spdlog REQUIRED QUIET) +find_package(inja REQUIRED QUIET) if(NOT TARGET pantor::inja) add_library(pantor::inja ALIAS inja::inja) endif() -find_package(incbin REQUIRED) +find_package(incbin REQUIRED QUIET) -file(GLOB ${target}_PUBLIC_HEADERS "include/**/*.hpp") -add_library(${target} SHARED +file(GLOB cloe-runtime_PUBLIC_HEADERS "include/**/*.hpp") +message(STATUS "Building cloe-runtime library.") +add_library(cloe-runtime SHARED # find src -type f -name "*.cpp" \! -name "*_test.cpp" src/cloe/core/error.cpp src/cloe/core/duration.cpp @@ -47,23 +47,22 @@ add_library(${target} SHARED src/cloe/utility/xdg.cpp # For IDE integration - ${${target}_PUBLIC_HEADERS} + ${cloe-runtime_PUBLIC_HEADERS} ) -add_library(${alias} ALIAS ${target}) -set_target_properties(${target} PROPERTIES +add_library(cloe::runtime ALIAS cloe-runtime) +set_target_properties(cloe-runtime PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED ON VERSION ${CLOE_VERSION} ) -set_target_linting(${target}) configure_file(src/cloe/version.hpp.in include/cloe/version.hpp @ONLY) -target_include_directories(${target} +target_include_directories(cloe-runtime PUBLIC "$" "$" "$" ) -target_link_libraries(${target} +target_link_libraries(cloe-runtime PUBLIC Boost::headers Boost::filesystem @@ -75,7 +74,7 @@ target_link_libraries(${target} pantor::inja incbin::incbin ) -target_compile_definitions(${target} +target_compile_definitions(cloe-runtime PRIVATE PROJECT_SOURCE_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}\" PUBLIC @@ -85,9 +84,10 @@ target_compile_definitions(${target} # Testing ------------------------------------------------------------- include(CTest) if(BUILD_TESTING) - find_package(GTest REQUIRED) + find_package(GTest REQUIRED QUIET) include(GoogleTest) + message(STATUS "Building test-cloe executable.") add_executable(test-cloe # find src -type f -name "*_test.cpp" src/cloe/version_test.cpp @@ -103,13 +103,13 @@ if(BUILD_TESTING) GTest::gtest GTest::gtest_main Boost::boost - ${target} + cloe-runtime ) gtest_add_tests(TARGET test-cloe) endif() # Installation -------------------------------------------------------- -install(TARGETS ${target} +install(TARGETS cloe-runtime LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE diff --git a/runtime/cmake/CloePluginSetup.cmake b/runtime/cmake/CloePluginSetup.cmake index 7d8f6c4a1..8ad139a41 100644 --- a/runtime/cmake/CloePluginSetup.cmake +++ b/runtime/cmake/CloePluginSetup.cmake @@ -6,7 +6,7 @@ include(TargetLinting) function(cloe_add_plugin) set(options - NO_LINTING + LINT ) set(one_value_args TARGET # [required] @@ -44,11 +44,11 @@ function(cloe_add_plugin) message(SEND_ERROR "cloe_add_plugin requires property SOURCES to be set") endif() if(NOT DEFINED _ARG_OUTPUT_DIRECTORY) - set(_ARG_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib/cloe) + set(_ARG_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/cloe) endif() # Add the cloe plugin target: - message(STATUS "-> Building ${_ARG_OUTPUT_NAME} plugin.") + message(STATUS "Building ${_ARG_OUTPUT_NAME} plugin.") add_library(${target} MODULE ${_ARG_SOURCES} ) @@ -71,7 +71,7 @@ function(cloe_add_plugin) OUTPUT_NAME ${_ARG_OUTPUT_NAME} PREFIX "" ) - if(NOT ${_ARG_NO_LINTING}) + if(${_ARG_LINT}) set_target_linting(${target}) endif() target_compile_options(${target} diff --git a/runtime/conanfile.py b/runtime/conanfile.py index 4021f5fdf..9cde7269f 100644 --- a/runtime/conanfile.py +++ b/runtime/conanfile.py @@ -51,7 +51,7 @@ def requirements(self): self.requires("incbin/cci.20211107") def build_requirements(self): - self.test_requires("gtest/1.13.0") + self.test_requires("gtest/1.14.0") def layout(self): cmake.cmake_layout(self) diff --git a/tests/conanfile_default.py b/tests/conanfile_default.py deleted file mode 100644 index f02947e98..000000000 --- a/tests/conanfile_default.py +++ /dev/null @@ -1,37 +0,0 @@ -# mypy: ignore-errors -# pylint: skip-file - -from pathlib import Path - -from conan import ConanFile - - -class CloeTest(ConanFile): - python_requires = "cloe-launch-profile/[>=0.20.0]@cloe/develop" - python_requires_extend = "cloe-launch-profile.Base" - - default_options = { - "cloe:with_vtd": False, - "cloe-engine:server": True, - } - - @property - def cloe_launch_env(self): - return { - "CLOE_LOG_LEVEL": "debug", - "CLOE_STRICT_MODE": "1", - "CLOE_WRITE_OUTPUT": "0", - "CLOE_ROOT": Path(self.recipe_folder) / "..", - } - - def set_version(self): - self.version = self.project_version("../VERSION") - - def requirements(self): - self.requires(f"cloe/{self.version}@cloe/develop") - if self.options["cloe"].with_vtd: - # These dependencies aren't pulled in by the "cloe" package, - # because they are not required to build the package. - # We need them to run the tests though. - self.requires("osi-sensor/1.0.0-vtd2.2@cloe/stable") - self.requires("vtd/2.2.0@cloe-restricted/stable") diff --git a/tests/conanfile_deployment.py b/tests/conanfile_deployment.py new file mode 100644 index 000000000..22e91d3ae --- /dev/null +++ b/tests/conanfile_deployment.py @@ -0,0 +1,90 @@ +# mypy: ignore-errors +# pylint: skip-file + +from pathlib import Path + +from conan import ConanFile +from conan.tools import files, scm + +required_conan_version = ">=1.52.0" + + +class CloeStandardDeployment(ConanFile): + python_requires = "cloe-launch-profile/[>=0.20.0]@cloe/develop" + python_requires_extend = "cloe-launch-profile.Base" + + name = "cloe-deployment" + license = "Apache-2.0" + url = "https://github.com/eclipse/cloe" + description = "Closed-loop automated driving simulation environment" + topics = ["simulation"] + settings = "os", "compiler", "build_type", "arch" + options = { + "with_esmini": [True, False], + "with_vtd": [True, False], + } + default_options = { + "with_esmini": True, + "with_vtd": False, + + "fable:allow_comments": True, + "cloe-engine:server": True, + } + + @property + def cloe_launch_env(self): + return { + "CLOE_ENGINE_WITH_SERVER": "1", + "CLOE_LOG_LEVEL": "debug", + "CLOE_STRICT_MODE": "1", + "CLOE_WRITE_OUTPUT": "0", + "CLOE_ROOT": Path(self.recipe_folder) / "..", + } + + def set_version(self): + version_file = Path(self.recipe_folder) / "../VERSION" + if version_file.exists(): + self.version = files.load(self, version_file).strip() + else: + git = scm.Git(self, self.recipe_folder) + self.version = git.run("describe --dirty=-dirty")[1:] + + def requirements(self): + def cloe_requires(dep): + self.requires(f"{dep}/{self.version}@cloe/develop") + + cloe_requires("cloe-runtime") + cloe_requires("cloe-models") + cloe_requires("cloe-osi") + cloe_requires("cloe-plugin-basic") + cloe_requires("cloe-plugin-clothoid-fit") + cloe_requires("cloe-plugin-frustum-culling") + cloe_requires("cloe-plugin-gndtruth-extractor") + cloe_requires("cloe-plugin-minimator") + cloe_requires("cloe-plugin-mocks") + cloe_requires("cloe-plugin-noisy-sensor") + cloe_requires("cloe-plugin-speedometer") + cloe_requires("cloe-plugin-virtue") + + if self.options.with_esmini: + cloe_requires("cloe-plugin-esmini") + + if self.options.with_vtd: + cloe_requires("cloe-plugin-vtd") + + # Overrides: + self.requires("fmt/9.1.0", override=True) + self.requires("inja/3.4.0", override=True) + self.requires("nlohmann_json/3.11.3", override=True) + self.requires("incbin/cci.20211107", override=True) + self.requires("boost/1.74.0", override=True) + self.requires("zlib/1.2.13", override=True) + self.requires("protobuf/3.21.12", override=True) + + # Runtime requirements: + cloe_requires("cloe-engine") + if self.options.with_esmini: + self.requires("esmini-data/2.37.4@cloe/stable") + if self.options.with_vtd: + self.requires("osi-sensor/1.0.0-vtd2.2@cloe/stable") + self.requires("vtd/2.2.0@cloe-restricted/stable") diff --git a/tests/conanfile_superbuild.py b/tests/conanfile_superbuild.py new file mode 100644 index 000000000..4410296aa --- /dev/null +++ b/tests/conanfile_superbuild.py @@ -0,0 +1,59 @@ +# mypy: ignore-errors +# pylint: skip-file + +from pathlib import Path + +from conan import ConanFile +from conan.tools import files, scm + +required_conan_version = ">=1.52.0" + + +class CloeSuperbuildTest(ConanFile): + python_requires = "cloe-launch-profile/[>=0.20.0]@cloe/develop" + python_requires_extend = "cloe-launch-profile.Base" + + name = "cloe-superbuild-test" + license = "Apache-2.0" + url = "https://github.com/eclipse/cloe" + description = "Closed-loop automated driving simulation environment" + topics = ["simulation"] + settings = "os", "compiler", "build_type", "arch" + options = { + "with_esmini": [True, False], + "with_vtd": [True, False], + } + default_options = { + "with_esmini": True, + "with_vtd": False, + + "cloe:fable_allow_comments": True, + "cloe:engine_server": True, + } + + @property + def cloe_launch_env(self): + return { + "CLOE_ENGINE_WITH_SERVER": "1" if self.options["cloe"].engine_server else "0", + "CLOE_LOG_LEVEL": "debug", + "CLOE_STRICT_MODE": "1", + "CLOE_WRITE_OUTPUT": "0", + "CLOE_ROOT": Path(self.recipe_folder) / "..", + } + + def configure(self): + self.options["cloe"].with_esmini = self.options.with_esmini + self.options["cloe"].with_vtd = self.options.with_vtd + + def set_version(self): + self.version = self.project_version("../VERSION") + + def requirements(self): + self.requires(f"cloe/{self.version}@cloe/develop") + + # Runtime requirements: + if self.options.with_esmini: + self.requires("esmini-data/2.37.4@cloe/stable") + if self.options.with_vtd: + self.requires("osi-sensor/1.0.0-vtd2.2@cloe/stable") + self.requires("vtd/2.2.0@cloe-restricted/stable") diff --git a/vendor/esmini-data/conanfile.py b/vendor/esmini-data/conanfile.py index c285bc7e0..6572f14cf 100644 --- a/vendor/esmini-data/conanfile.py +++ b/vendor/esmini-data/conanfile.py @@ -13,6 +13,12 @@ class ESMiniData(ConanFile): description = "Basic OpenScenario player example data" topics = ("Environment Simulator", "OpenScenario", "OpenDrive") + # This package may not be built while all other packages are built + # because it is solely a runtime dependency. Because it only copies + # a few files, the only thing that may take a longer period of time + # is downloading the esmini archive. For now, this is acceptable. + build_policy = "missing" + def export_sources(self): files.export_conandata_patches(self) diff --git a/vendor/esmini/test_package/CMakeLists.txt b/vendor/esmini/test_package/CMakeLists.txt index 57e834a31..1dc1c7d17 100644 --- a/vendor/esmini/test_package/CMakeLists.txt +++ b/vendor/esmini/test_package/CMakeLists.txt @@ -1,7 +1,7 @@ -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.15...3.27 FATAL_ERROR) project(test_package LANGUAGES CXX) -find_package(esmini REQUIRED) +find_package(esmini REQUIRED QUIET) add_executable(${PROJECT_NAME} test_package.cpp) target_link_libraries(${PROJECT_NAME} diff --git a/vendor/open-simulation-interface/test_package/CMakeLists.txt b/vendor/open-simulation-interface/test_package/CMakeLists.txt index 27d995312..5bb5a5761 100644 --- a/vendor/open-simulation-interface/test_package/CMakeLists.txt +++ b/vendor/open-simulation-interface/test_package/CMakeLists.txt @@ -1,7 +1,7 @@ -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.15...3.27 FATAL_ERROR) project(test_package CXX) -find_package(open_simulation_interface REQUIRED CONFIG) +find_package(open_simulation_interface REQUIRED QUIET CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) target_link_libraries(${PROJECT_NAME}