forked from jrl-umi3218/sch-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conanfile.py
78 lines (68 loc) · 2.88 KB
/
conanfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# -*- coding: utf-8 -*-
#
# Copyright 2012-2019 CNRS-UM LIRMM, CNRS-AIST JRL
#
from conans import ConanFile, CMake, tools
import os
import shutil
class SCHCoreConan(ConanFile):
name = "sch-core"
version = "1.4.1"
description = "Efficient implementation of GJK algorithm for proximity queries (collision detection, distance computations, penetration depths and witness points) between convex shapes."
topics = ("robotics", "collision", "proximity", "convex")
url = "https://github.com/jrl-umi3218/sch-core"
homepage = "https://github.com/jrl-umi3218/sch-core"
author = "Pierre Gergondet <[email protected]>"
license = "BSD-2-Clause"
exports = ["LICENSE"]
exports_sources = ["CMakeLists.txt", "conan/CMakeLists.txt", "cmake/*", "CMakeModules/*", "doc/*", "examples/*", "include/*", "src/*", "README.md", "conan/FindBoost.cmake"]
generators = ["cmake_paths"]
settings = "os", "arch", "compiler", "build_type"
requires = (
# We don't really care for a specific version of Boost and conan has >= 1.64
"boost/1.73.0"
)
def source(self):
# Wrap the original CMake file to call conan_basic_setup
shutil.move("CMakeLists.txt", "CMakeListsOriginal.txt")
shutil.move(os.path.join("conan", "CMakeLists.txt"), "CMakeLists.txt")
# Make sure we find conan's Boost not system Boost
pattern = 'include(CMakeFindDependencyMacro)'
replacement = '''if(CONAN_BOOST_ROOT)
set(BOOST_ROOT "${{CONAN_BOOST_ROOT}}")
else()
set(BOOST_ROOT "${{PACKAGE_PREFIX_DIR}}")
endif()
set(Boost_NO_SYSTEM_PATHS ON)
list(APPEND CMAKE_MODULE_PATH "${{CMAKE_CURRENT_LIST_DIR}}")
{}'''.format(pattern)
tools.replace_in_file('cmake/Config.cmake.in', pattern, replacement)
# Install the up-to-date FindBoost.cmake
pattern = 'project(sch-core CXX)'
replacement = '''{}
set(BOOST_ROOT "${{CONAN_BOOST_ROOT}}")
set(Boost_NO_SYSTEM_PATHS ON)
list(APPEND CMAKE_MODULE_PATH "${{CMAKE_CURRENT_LIST_DIR}}/conan")
install(FILES conan/FindBoost.cmake DESTINATION lib/cmake/RBDyn)'''.format(pattern)
tools.replace_in_file('CMakeListsOriginal.txt', pattern, replacement)
def _configure_cmake(self):
cmake = CMake(self)
cmake.definitions['BUILD_TESTING'] = False
cmake.definitions['INSTALL_DOCUMENTATION'] = False
cmake.definitions['SCH_BUILD_BSD'] = True
cmake.configure()
return cmake
def configure(self):
self.options['boost'].shared = True
def build(self):
cmake = self._configure_cmake()
cmake.build()
def package(self):
cmake = self._configure_cmake()
cmake.install()
def deploy(self):
self.copy("*")
self.copy_deps("*")
def package_info(self):
self.cpp_info.libs = tools.collect_libs(self)
self.env_info.LD_LIBRARY_PATH.append(os.path.join(self.package_folder, 'lib'))