Skip to content

Commit

Permalink
clothoid_fit: Modernize build recipe
Browse files Browse the repository at this point in the history
  • Loading branch information
cassava committed Mar 27, 2024
1 parent aea129e commit 93b6ea6
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 52 deletions.
29 changes: 15 additions & 14 deletions plugins/clothoid_fit/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
cmake_minimum_required(VERSION 3.7 FATAL_ERROR)
cmake_minimum_required(VERSION 3.15 FATAL_ERROR)

project(cloe_plugin_clothoid_fit LANGUAGES CXX)

include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)
find_package(cloe-runtime REQUIRED)
find_package(cloe-models REQUIRED)
find_package(Eigen3 REQUIRED)

add_library(g1-fitting-lib STATIC
src/g1_fitting.cpp
Expand All @@ -21,17 +22,16 @@ cloe_add_plugin(
src/clothoid_fit.cpp
LINK_LIBRARIES
g1-fitting-lib
CONAN_PKG::eigen
CONAN_PKG::cloe-runtime
CONAN_PKG::cloe-models
Eigen3::Eigen
cloe::runtime
cloe::models
COMPILE_DEFINITIONS
PROJECT_SOURCE_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}\"
)

option(BuildTests "Build tests?" ON)
if(BuildTests)
message(STATUS "-> Enable testing")
enable_testing()
include(CTest)
if(BUILD_TESTING)
find_package(GTest REQUIRED)
include(GoogleTest)

add_executable(test-clothoid-fit
Expand All @@ -45,10 +45,11 @@ if(BuildTests)
target_link_libraries(test-clothoid-fit
PRIVATE
g1-fitting-lib
CONAN_PKG::gtest
CONAN_PKG::eigen
CONAN_PKG::cloe-runtime
CONAN_PKG::cloe-models
GTest::gtest
GTest::gtest_main
Eigen3::Eigen
cloe::runtime
cloe::models
)
gtest_add_tests(TARGET test-clothoid-fit)
endif()
73 changes: 36 additions & 37 deletions plugins/clothoid_fit/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,70 +1,69 @@
# mypy: ignore-errors
# pylint: skip-file

from pathlib import Path
from conans import ConanFile, CMake, RunEnvironment, tools

from conan import ConanFile
from conan.tools import cmake, files, scm

required_conan_version = ">=1.52.0"

class CloeComponentClothoidFit(ConanFile):
name = "cloe-plugin-clothoid-fit"
url = "https://github.com/eclipse/cloe"
description = "Cloe component plugin that generates clothoids from given lane boundary point lists."
license = "Apache-2.0"
settings = "os", "compiler", "build_type", "arch"
options = {
"test": [True, False],
"pedantic": [True, False],
}
default_options = {
"test": True,
"pedantic": True,
}
generators = "cmake"
generators = "CMakeDeps", "VirtualRunEnv"
no_copy_source = True
exports_sources = [
"src/*",
"CMakeLists.txt",
]
requires = [
"eigen/[~=3.4.0]",
]

_cmake = None

def set_version(self):
version_file = Path(self.recipe_folder) / "../../VERSION"
if version_file.exists():
self.version = tools.load(version_file).strip()
self.version = files.load(self, version_file).strip()
else:
git = tools.Git(folder=self.recipe_folder)
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")
self.requires("eigen/3.4.0")

def build_requirements(self):
if self.options.test:
self.build_requires("gtest/[~1.10]")
self.test_requires("gtest/1.13.0")

def layout(self):
cmake.cmake_layout(self)

def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
self._cmake.definitions["CMAKE_EXPORT_COMPILE_COMMANDS"] = True
self._cmake.definitions["BuildTests"] = self.options.test
self._cmake.definitions["TargetLintingExtended"] = self.options.pedantic
self._cmake.configure()
return self._cmake
def generate(self):
tc = cmake.CMakeToolchain(self)
tc.cache_variables["CMAKE_EXPORT_COMPILE_COMMANDS"] = True
tc.cache_variables["CLOE_PROJECT_VERSION"] = self.version
tc.generate()

def build(self):
cmake = self._configure_cmake()
cmake.build()
if self.options.test:
with tools.environment_append(RunEnvironment(self).vars):
cmake.test()
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):
cmake = self._configure_cmake()
cmake.install()
cm = cmake.CMake(self)
if self.should_install:
cm.install()

def package_id(self):
del self.info.options.pedantic
del self.info.options.test
self.info.requires["boost"].full_package_mode()

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)
2 changes: 2 additions & 0 deletions plugins/clothoid_fit/src/clothoid_fit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
*
*/

#pragma once

#include <math.h> // for atan
#include <Eigen/Geometry> // for Isometry3d
#include <map> // for map
Expand Down
1 change: 0 additions & 1 deletion plugins/clothoid_fit/src/g1_fitting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
/**
* \file g1_fitting.cpp
* \see g1_fitting.hpp
*
*/

#include <math.h> // for M_PI, ..
Expand Down

0 comments on commit 93b6ea6

Please sign in to comment.