This repository has been archived by the owner on Sep 24, 2024. It is now read-only.
forked from conan-io/conan-center-index
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(conan-io#17575) embag: add new recipe
* embag: add new recipe * embag: set min cxx_standard to 11 * embag: add missing 'm' system lib * embag: bump min c++ std to 14 * embag: fix a portability bug * embag: drop test_v1_package * embag: transitive_libs not required for boost * embag: get rid of patch, add review suggestion * embag: revert to using a patch Otherwise would need to add /Zc:__cplusplus to exported cxxflags. * embag: get rid of the patch
- Loading branch information
1 parent
1280289
commit 73e04b6
Showing
7 changed files
with
183 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
cmake_minimum_required(VERSION 3.15) | ||
project(embag LANGUAGES CXX) | ||
|
||
find_package(Boost REQUIRED COMPONENTS iostreams headers) | ||
find_package(lz4 REQUIRED CONFIG) | ||
find_package(BZip2 REQUIRED CONFIG) | ||
|
||
file(GLOB_RECURSE embag_SOURCES "lib/*.cc") | ||
add_library(embag ${embag_SOURCES}) | ||
set_target_properties(embag PROPERTIES | ||
# embag does not export any symbols otherwise | ||
WINDOWS_EXPORT_ALL_SYMBOLS ON | ||
) | ||
target_compile_features(embag PUBLIC cxx_std_14) | ||
target_link_libraries(embag PUBLIC | ||
Boost::iostreams | ||
Boost::headers | ||
lz4::lz4 | ||
BZip2::BZip2 | ||
) | ||
|
||
if (MSVC) | ||
# For a #if __cplusplus < 201402L check in lib/util.h | ||
target_compile_options(embag PRIVATE /Zc:__cplusplus) | ||
endif() | ||
|
||
install(TARGETS embag) | ||
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib/ | ||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/embag | ||
FILES_MATCHING | ||
PATTERN "*.h" | ||
PATTERN "*.hpp" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
sources: | ||
"0.0.42": | ||
url: "https://github.com/embarktrucks/embag/archive/refs/tags/0.0.42.tar.gz" | ||
sha256: "60b22ba9355528040046b7e2c3ee968798ad5773a9eb7a1d13cf33dc47e2adec" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import os | ||
|
||
from conan import ConanFile | ||
from conan.tools.build import check_min_cppstd | ||
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout | ||
from conan.tools.files import get, copy, rm | ||
from conan.tools.microsoft import is_msvc | ||
|
||
required_conan_version = ">=1.53.0" | ||
|
||
|
||
class EmbagConan(ConanFile): | ||
name = "embag" | ||
description = "Schema and dependency free ROS bag reader" | ||
license = "MIT" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "https://github.com/embarktrucks/embag" | ||
topics = ("rosbag", "ros", "robotics") | ||
package_type = "library" | ||
settings = "os", "arch", "compiler", "build_type" | ||
options = { | ||
"shared": [True, False], | ||
"fPIC": [True, False], | ||
} | ||
default_options = { | ||
"shared": False, | ||
"fPIC": True, | ||
} | ||
|
||
@property | ||
def _min_cppstd(self): | ||
return 14 | ||
|
||
def export_sources(self): | ||
copy(self, "CMakeLists.txt", | ||
src=self.recipe_folder, | ||
dst=os.path.join(self.export_sources_folder, "src")) | ||
|
||
def config_options(self): | ||
if self.settings.os == "Windows": | ||
del self.options.fPIC | ||
|
||
def configure(self): | ||
if self.options.shared: | ||
self.options.rm_safe("fPIC") | ||
|
||
def layout(self): | ||
cmake_layout(self, src_folder="src") | ||
|
||
def requirements(self): | ||
# INFO: embag.h includes boost/variant.hpp | ||
self.requires("boost/1.82.0", transitive_headers=True) | ||
# INFO: decompression.h includes lz4frame.h | ||
self.requires("lz4/1.9.4", transitive_headers=True) | ||
# INFO: ros_bag_types.h includes bzlib.h | ||
self.requires("bzip2/1.0.8", transitive_headers=True) | ||
|
||
def validate(self): | ||
if self.settings.compiler.cppstd: | ||
check_min_cppstd(self, self._min_cppstd) | ||
|
||
def source(self): | ||
get(self, **self.conan_data["sources"][self.version], strip_root=True) | ||
|
||
def generate(self): | ||
tc = CMakeToolchain(self) | ||
tc.generate() | ||
deps = CMakeDeps(self) | ||
deps.generate() | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def package(self): | ||
copy(self, "LICENSE", | ||
dst=os.path.join(self.package_folder, "licenses"), | ||
src=self.source_folder) | ||
cmake = CMake(self) | ||
cmake.install() | ||
rm(self, "*.pdb", self.package_folder, recursive=True) | ||
|
||
def package_info(self): | ||
self.cpp_info.libs = ["embag"] | ||
|
||
if self.settings.os in ["Linux", "FreeBSD"]: | ||
self.cpp_info.system_libs = ["m"] | ||
if is_msvc(self): | ||
# For a #if __cplusplus < 201402L check in lib/util.h, which is a public header | ||
self.cpp_info.cxxflags.append("/Zc:__cplusplus") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cmake_minimum_required(VERSION 3.15) | ||
project(test_package LANGUAGES CXX) | ||
|
||
find_package(embag REQUIRED CONFIG) | ||
|
||
add_executable(${PROJECT_NAME} test_package.cpp) | ||
target_link_libraries(${PROJECT_NAME} PRIVATE embag::embag) | ||
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from conan import ConanFile | ||
from conan.tools.build import can_run | ||
from conan.tools.cmake import cmake_layout, CMake | ||
import os | ||
|
||
|
||
class TestPackageConan(ConanFile): | ||
settings = "os", "arch", "compiler", "build_type" | ||
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" | ||
test_type = "explicit" | ||
|
||
def requirements(self): | ||
self.requires(self.tested_reference_str) | ||
|
||
def layout(self): | ||
cmake_layout(self) | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def test(self): | ||
if can_run(self): | ||
bin_path = os.path.join(self.cpp.build.bindir, "test_package") | ||
self.run(bin_path, env="conanrun") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include <cstdlib> | ||
#include <iostream> | ||
|
||
#include <embag/view.h> | ||
|
||
int main() { | ||
Embag::View view{}; | ||
// Do not load any bag file for testing | ||
// view.addBag("xyz.bag"); | ||
const auto start_time = view.getStartTime(); | ||
const auto end_time = view.getEndTime(); | ||
std::cout << "Start time is " << start_time.secs + start_time.nsecs * 1e-9 << std::endl; | ||
std::cout << "End time is " << end_time.secs + end_time.nsecs * 1e-9 << std::endl; | ||
for (const auto &message : view.getMessages()) { | ||
message->print(); | ||
} | ||
return EXIT_SUCCESS; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
versions: | ||
"0.0.42": | ||
folder: all |