diff --git a/CMakeLists.txt b/CMakeLists.txt index 5830994a..20d76061 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,12 +1,30 @@ cmake_minimum_required(VERSION 3.5) project(lanelet2) -enable_testing() +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED) + +set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) +if (MSVC) + add_compile_definitions(_USE_MATH_DEFINES) +endif () + +option(LANELET2_ENABLE_TESTS "Build the testing tree." OFF) +if (LANELET2_ENABLE_TESTS) + enable_testing() +endif () + + +#include_directories( +# lanelet2_core/include +# lanelet2_io/include +# lanelet2_projection/include +# lanelet2_traffic_rules/include +# lanelet2_routing/include +# lanelet2_validation/include) -#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_io) #add_subdirectory(lanelet2_projection) #add_subdirectory(lanelet2_traffic_rules) #add_subdirectory(lanelet2_routing) diff --git a/conanfile.py b/conanfile.py index 3ca183de..ecb8bccf 100644 --- a/conanfile.py +++ b/conanfile.py @@ -18,7 +18,7 @@ class Lanelet2Conan(ConanFile): proj_list = [ 'lanelet2_core', - # 'lanelet2_io', + 'lanelet2_io', # 'lanelet2_matching', # 'lanelet2_projection', # 'lanelet2_traffic_rules', diff --git a/lanelet2_core/CMakeLists.txt b/lanelet2_core/CMakeLists.txt index e133c646..ea0f478f 100644 --- a/lanelet2_core/CMakeLists.txt +++ b/lanelet2_core/CMakeLists.txt @@ -53,10 +53,6 @@ file(GLOB PROJECT_SOURCE_FILES_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp") # INCLUDES ${PROJECT_HEADER_FILES_INC} ${PROJECT_SOURCE_FILES_INC} # SOURCES ${PROJECT_SOURCE_FILES_SRC} # ) -set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) -if (MSVC) - add_compile_definitions(_USE_MATH_DEFINES) -endif () find_package(Boost REQUIRED) find_package(Eigen3 REQUIRED) add_library(${PROJECT_NAME} SHARED ${PROJECT_SOURCE_FILES_SRC}) @@ -82,9 +78,11 @@ install(TARGETS ${PROJECT_NAME} # mrt_add_tests(test) # mrt_add_nosetests(test) #endif () -include(GoogleTest) -find_package(GTest REQUIRED) -file(GLOB PROJECT_SOURCE_FILES_test "${CMAKE_CURRENT_SOURCE_DIR}/test/*.cpp") -add_executable("${PROJECT_NAME}-test" ${PROJECT_SOURCE_FILES_test}) -target_link_libraries("${PROJECT_NAME}-test" PRIVATE GTest::gtest_main ${PROJECT_NAME}) -gtest_discover_tests("${PROJECT_NAME}-test") \ No newline at end of file +if (LANELET2_ENABLE_TESTS) + include(GoogleTest) + find_package(GTest REQUIRED) + file(GLOB PROJECT_SOURCE_FILES_test "${CMAKE_CURRENT_SOURCE_DIR}/test/*.cpp") + add_executable("${PROJECT_NAME}-test" ${PROJECT_SOURCE_FILES_test}) + target_link_libraries("${PROJECT_NAME}-test" PRIVATE GTest::gtest_main ${PROJECT_NAME}) + gtest_discover_tests("${PROJECT_NAME}-test") +endif () \ No newline at end of file diff --git a/lanelet2_io/CMakeLists.txt b/lanelet2_io/CMakeLists.txt index e4828bf4..63fb824b 100644 --- a/lanelet2_io/CMakeLists.txt +++ b/lanelet2_io/CMakeLists.txt @@ -1,4 +1,4 @@ -set(MRT_PKG_VERSION 4.0.0) +#set(MRT_PKG_VERSION 4.0.0) # Modify only if you know what you are doing! cmake_minimum_required(VERSION 3.5.1) project(lanelet2_io) @@ -6,64 +6,82 @@ project(lanelet2_io) ################### ## Find packages ## ################### -find_package(mrt_cmake_modules REQUIRED) -include(UseMrtStdCompilerFlags) -include(GatherDeps) +#find_package(mrt_cmake_modules REQUIRED) +#include(UseMrtStdCompilerFlags) +#include(GatherDeps) # You can add a custom.cmake in order to add special handling for this package. E.g. you can do: # list(REMOVE_ITEM DEPENDEND_PACKAGES ...) # To remove libs which cannot be found automatically. You can also "find_package" other, custom dependencies there. # You can also set PROJECT_INSTALL_FILES to install files that are not installed by default. -if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/custom.cmake") - include("${CMAKE_CURRENT_SOURCE_DIR}/custom.cmake") -endif() - -find_package(AutoDeps REQUIRED COMPONENTS ${DEPENDEND_PACKAGES}) - -mrt_parse_package_xml() +#if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/custom.cmake") +# include("${CMAKE_CURRENT_SOURCE_DIR}/custom.cmake") +#endif() +# +#find_package(AutoDeps REQUIRED COMPONENTS ${DEPENDEND_PACKAGES}) +# +#mrt_parse_package_xml() ######################## ## Add python modules ## ######################## # This adds a python module if located under src/{PROJECT_NAME) -mrt_python_module_setup() - -mrt_glob_files(PROJECT_PYTHON_SOURCE_FILES_SRC "python_api/*.cpp") -if (PROJECT_PYTHON_SOURCE_FILES_SRC) - # Add a cpp-python api library. Make sure there are no name collisions with python modules in this project - mrt_add_python_api( ${PROJECT_NAME} - FILES ${PROJECT_PYTHON_SOURCE_FILES_SRC} - ) -endif() +#mrt_python_module_setup() +# +#mrt_glob_files(PROJECT_PYTHON_SOURCE_FILES_SRC "python_api/*.cpp") +#if (PROJECT_PYTHON_SOURCE_FILES_SRC) +# # Add a cpp-python api library. Make sure there are no name collisions with python modules in this project +# mrt_add_python_api( ${PROJECT_NAME} +# FILES ${PROJECT_PYTHON_SOURCE_FILES_SRC} +# ) +#endif() ############################ ## Read source code files ## ############################ -mrt_glob_files_recurse(PROJECT_HEADER_FILES_INC "include/*.h" "include/*.hpp" "include/*.cuh") -mrt_glob_files(PROJECT_SOURCE_FILES_INC "src/*.h" "src/*.hpp" "src/*.cuh") -mrt_glob_files(PROJECT_SOURCE_FILES_SRC "src/*.cpp" "src/*.cu") +#mrt_glob_files_recurse(PROJECT_HEADER_FILES_INC "include/*.h" "include/*.hpp" "include/*.cuh") +#mrt_glob_files(PROJECT_SOURCE_FILES_INC "src/*.h" "src/*.hpp" "src/*.cuh") +#mrt_glob_files(PROJECT_SOURCE_FILES_SRC "src/*.cpp" "src/*.cu") +file(GLOB PROJECT_SOURCE_FILES_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp") ########### ## Build ## ########### # Declare a cpp library -mrt_add_library(${PROJECT_NAME} - INCLUDES ${PROJECT_HEADER_FILES_INC} ${PROJECT_SOURCE_FILES_INC} - SOURCES ${PROJECT_SOURCE_FILES_SRC} - ) +#mrt_add_library(${PROJECT_NAME} +# INCLUDES ${PROJECT_HEADER_FILES_INC} ${PROJECT_SOURCE_FILES_INC} +# SOURCES ${PROJECT_SOURCE_FILES_SRC} +# ) +find_package(Boost REQUIRED) +find_package(pugixml REQUIRED) +add_library(${PROJECT_NAME} SHARED ${PROJECT_SOURCE_FILES_SRC}) +target_include_directories(${PROJECT_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include") +target_link_libraries(${PROJECT_NAME} PUBLIC lanelet2_core Boost::boost Boost::filesystem Boost::serialization pugixml::pugixml) ############# ## Install ## ############# # Install all targets, headers by default and scripts and other files if specified (folders or files). # This command also exports libraries and config files for dependent packages and this supersedes catkin_package. -mrt_install(PROGRAMS scripts FILES res data ${PROJECT_INSTALL_FILES}) +#mrt_install(PROGRAMS scripts FILES res data ${PROJECT_INSTALL_FILES}) +install(TARGETS ${PROJECT_NAME} + ARCHIVE DESTINATION ${PROJECT_INSTALL_FILES} + LIBRARY DESTINATION ${PROJECT_INSTALL_FILES} + RUNTIME DESTINATION ${PROJECT_INSTALL_FILES}) ############# ## Testing ## ############# # Add test targets for cpp and python tests -if (CATKIN_ENABLE_TESTING) - mrt_add_tests(test) - mrt_add_nosetests(test) -endif() +#if (CATKIN_ENABLE_TESTING) +# mrt_add_tests(test) +# mrt_add_nosetests(test) +#endif() +if (LANELET2_ENABLE_TESTS) + include(GoogleTest) + find_package(GTest REQUIRED) + file(GLOB PROJECT_SOURCE_FILES_test "${CMAKE_CURRENT_SOURCE_DIR}/test/*.cpp") + add_executable("${PROJECT_NAME}-test" ${PROJECT_SOURCE_FILES_test}) + target_link_libraries("${PROJECT_NAME}-test" PRIVATE GTest::gtest_main ${PROJECT_NAME}) + gtest_discover_tests("${PROJECT_NAME}-test") +endif () \ No newline at end of file diff --git a/lanelet2_io/test/TestSetup.h b/lanelet2_io/test/TestSetup.h index 67652af7..1f70c50f 100644 --- a/lanelet2_io/test/TestSetup.h +++ b/lanelet2_io/test/TestSetup.h @@ -52,8 +52,8 @@ inline bool operator==(const PrimitiveLayer& rhs, const PrimitiveLayer& lh } template <> -inline bool operator==(const PrimitiveLayer& rhs, - const PrimitiveLayer& lhs) { +inline bool operator== (const PrimitiveLayer& rhs, + const PrimitiveLayer& lhs) { return rhs.size() == lhs.size() && std::all_of(rhs.begin(), rhs.end(), [&lhs](auto& v1) { return *v1->constData() == *(*lhs.find(v1->id()))->constData(); }); @@ -124,13 +124,15 @@ inline Area setUpArea(int& num, const std::string& type = AttributeValueString:: class Tempfile { public: explicit Tempfile(std::string name) { - char dir[] = {"/tmp/lanelet2_io_test.XXXXXX"}; - auto* res = mkdtemp(dir); - if (res == nullptr) { - throw lanelet::LaneletError("Failed to crate temporary directory"); + boost::filesystem::path dir = boost::filesystem::temp_directory_path() / "lanelet2_io_test.XXXXXX"; + if (!boost::filesystem::exists(dir)) { + bool created = boost::filesystem::create_directory(dir); + if (!created) { + throw lanelet::LaneletError("Failed to crate temporary directory"); + } } - dir_ = dir; - path_ = fs::path(dir_) / name; + dir_ = dir.string(); + path_ = dir / name; } Tempfile(Tempfile&& rhs) noexcept = delete; Tempfile& operator=(Tempfile&& rhs) noexcept = delete;