forked from fzi-forschungszentrum-informatik/Lanelet2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conanfile.py
138 lines (121 loc) · 5.61 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import os
import sys
import xml.etree.ElementTree as ET
from conans import ConanFile, CMake, tools
from distutils.sysconfig import get_python_lib
find_mrt_cmake="""
set(mrt_cmake_modules_FOUND True)
include(${CMAKE_CURRENT_LIST_DIR}/mrt_cmake_modules-extras.cmake)
"""
cmake_lists="""
cmake_minimum_required(VERSION 3.5)
project(lanelet2)
if(POLICY CMP0079)
cmake_policy(SET CMP0079 NEW) # allows to do target_link_libraries on targets from subdirs
endif()
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR})
set(BoostPython_FOUND Yes)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(SKIP_STD)
# hint to gtest
set(GOOGLETEST_VERSION 1.0.0)
set(MRT_GTEST_DIR ${CMAKE_CURRENT_LIST_DIR})
enable_testing()
# declare dependencies
include_directories(lanelet2_core/include lanelet2_io/include lanelet2_projection/include lanelet2_traffic_rules/include
lanelet2_routing/include lanelet2_validation/include)
add_subdirectory(lanelet2_core)
add_subdirectory(lanelet2_io)
add_subdirectory(lanelet2_projection)
add_subdirectory(lanelet2_traffic_rules)
add_subdirectory(lanelet2_routing)
add_subdirectory(lanelet2_validation)
add_subdirectory(lanelet2_examples)
add_subdirectory(lanelet2_python)
add_subdirectory(lanelet2_maps)
add_subdirectory(lanelet2_matching)
# declare dependencies
target_link_libraries(lanelet2_io PUBLIC lanelet2_core)
target_link_libraries(lanelet2_projection PUBLIC lanelet2_core)
target_link_libraries(lanelet2_traffic_rules PUBLIC lanelet2_core)
target_link_libraries(lanelet2_routing PUBLIC lanelet2_core lanelet2_traffic_rules)
target_link_libraries(lanelet2_matching PUBLIC lanelet2_core lanelet2_traffic_rules lanelet2_io lanelet2_projection lanelet2_maps)
target_link_libraries(lanelet2_validation PUBLIC lanelet2_core lanelet2_io lanelet2_routing lanelet2_traffic_rules lanelet2_projection)
target_link_libraries(lanelet2_examples_compiler_flags INTERFACE lanelet2_core lanelet2_io lanelet2_routing lanelet2_traffic_rules lanelet2_projection lanelet2_matching)
target_link_libraries(lanelet2_python_compiler_flags INTERFACE lanelet2_core lanelet2_io lanelet2_routing lanelet2_traffic_rules lanelet2_projection lanelet2_matching)
"""
def read_version():
package = ET.parse('lanelet2_core/package.xml')
return package.find('version').text
def get_py_version():
return "{}.{}".format(sys.version_info.major, sys.version_info.minor)
def get_py_exec():
return "python3" if sys.version_info.major == 3 else "python"
class Lanelet2Conan(ConanFile):
name = "lanelet2"
version = read_version()
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"
license = "BSD"
url = "https://github.com/fzi-forschungszentrum-informatik/lanelet2"
description = "Map handling framework for automated driving"
options = {"shared": [True, False], "fPIC": [True]}
default_options = {"shared": True, "fPIC": True, "boost:shared": True, "boost:python_version": get_py_version(), "boost:without_python": False, "python_dev_config:python": get_py_exec()}
requires = (
"python_dev_config/0.6@bincrafters/stable",
"boost/[>=1.75.0 <=1.81.0]",
"eigen/3.4.0",
"geographiclib/1.52",
"pugixml/1.13",
)
exports_sources = "*"
exports = "lanelet2_core/package.xml"
proj_list = [
'lanelet2_core',
'lanelet2_io',
'lanelet2_matching',
'lanelet2_projection',
'lanelet2_traffic_rules',
'lanelet2_routing',
'lanelet2_validation'
]
def _configure_cmake(self):
cmake = CMake(self)
cmake.definitions["PYTHON_VERSION"] = get_py_version()
cmake.definitions["MRT_CMAKE_ENV"] = "sh;env;PYTHONPATH=" + os.path.join(self.package_folder, self._pythonpath())
cmake.configure()
return cmake
def _pythonpath(self):
return os.path.relpath(get_python_lib(prefix=self.package_folder), start=self.package_folder)
def source(self):
if not os.path.exists("mrt_cmake_modules"):
self.run("git clone https://github.com/KIT-MRT/mrt_cmake_modules.git")
mrt_cmake_dir = os.path.join(os.getcwd(), "mrt_cmake_modules")
with open("mrt_cmake_modules/cmake/mrt_cmake_modules-extras.cmake.in") as f:
extras = f.read().replace("@DEVELSPACE@", "True").replace("@PROJECT_SOURCE_DIR@", mrt_cmake_dir).replace("@CMAKE_CURRENT_SOURCE_DIR@", mrt_cmake_dir)
with open("mrt_cmake_modules-extras.cmake", "w") as f:
f.write(extras)
with open("Findmrt_cmake_modules.cmake", "w") as f:
f.write(find_mrt_cmake)
with open("CMakeLists.txt", "w") as f:
f.write(cmake_lists)
if not os.path.exists("googletest"):
self.run("git clone https://github.com/google/googletest.git")
def build(self):
cmake = self._configure_cmake()
cmake.build()
cmake.test() # not working as long as the pythonpath is not adapted first
cmake.install()
def package(self):
cmake = self._configure_cmake()
cmake.install()
def package_info(self):
self.cpp_info.libs = list(reversed(self.proj_list))
libpath = os.path.join(self.package_folder, "lib")
boost_libpaths = self.deps_cpp_info["boost"].lib_paths
execs = ("lanelet2_examples", "lanelet2_validation", "lanelet2_python")
binpaths = [os.path.join(self.package_folder, "lib", libname) for libname in execs]
self.env_info.PYTHONPATH.append(os.path.join(self.package_folder, self._pythonpath()))
self.env_info.LD_LIBRARY_PATH += [libpath] + boost_libpaths
self.env_info.DYLD_LIBRARY_PATH += [libpath] + boost_libpaths
self.env_info.PATH += binpaths