Skip to content

Commit

Permalink
chore: cmake_minimum_required 3.21
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-vincent committed Nov 21, 2023
1 parent b28e5bd commit e55d298
Show file tree
Hide file tree
Showing 11 changed files with 57 additions and 87 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.21)
project(lanelet2)

set(CMAKE_CXX_STANDARD 17)
Expand Down
10 changes: 5 additions & 5 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@


class Lanelet2Conan(ConanFile):
name = "lanelet2"
name = "lanelet2x"
version = "1.2.1"

# Optional metadata
license = "BSD"
url = "https://github.com/fzi-forschungszentrum-informatik/lanelet2"
description = "Map handling framework for automated driving"
url = "https://github.com/wu-vincent/lanelet2"
description = "Your favorite map handling framework for automated driving, now standalone and with cross-platform support."

# Binary configuration
settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False], "fPIC": [True, False]}
default_options = {"shared": False, "fPIC": True}
options = {"shared": [True, False], "fPIC": [True]}
default_options = {"shared": False, "fPIC": True} # "boost/*:shared": True

proj_list = [
'lanelet2_core',
Expand Down
4 changes: 2 additions & 2 deletions lanelet2_core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5.1)
cmake_minimum_required(VERSION 3.21)
project(lanelet2_core)

###################
Expand All @@ -24,7 +24,7 @@ file(GLOB PROJECT_SOURCE_FILES_SRC "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
# Declare a cpp library
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 Boost::graph Eigen3::Eigen)
target_link_libraries(${PROJECT_NAME} PUBLIC Boost::headers Eigen3::Eigen)

#############
## Install ##
Expand Down
9 changes: 6 additions & 3 deletions lanelet2_io/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5.1)
cmake_minimum_required(VERSION 3.21)
project(lanelet2_io)

###################
Expand Down Expand Up @@ -47,8 +47,11 @@ if (LANELET2_ENABLE_TESTING)
add_executable("${PROJECT_NAME}_test" ${PROJECT_SOURCE_FILES_TEST})
target_link_libraries("${PROJECT_NAME}_test" PRIVATE GTest::gtest_main ${PROJECT_NAME})

add_custom_command(TARGET "${PROJECT_NAME}_test" POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:lanelet2_core>" "$<TARGET_FILE_DIR:${PROJECT_NAME}_test>")
if (WIN32)
add_custom_command(TARGET "${PROJECT_NAME}_test" POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_RUNTIME_DLLS:${PROJECT_NAME}_test>" "$<TARGET_FILE_DIR:${PROJECT_NAME}_test>"
COMMAND_EXPAND_LISTS)
endif ()

gtest_discover_tests("${PROJECT_NAME}_test")
add_dependencies("${PROJECT_NAME}_test" lanelet2_maps)
Expand Down
2 changes: 1 addition & 1 deletion lanelet2_maps/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5.1)
cmake_minimum_required(VERSION 3.21)
project(lanelet2_maps)

###########
Expand Down
12 changes: 6 additions & 6 deletions lanelet2_matching/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5.1)
cmake_minimum_required(VERSION 3.21)
project(lanelet2_matching)

###################
Expand Down Expand Up @@ -46,11 +46,11 @@ if (LANELET2_ENABLE_TESTING)
add_executable("${PROJECT_NAME}_test" ${PROJECT_SOURCE_FILES_TEST})
target_link_libraries("${PROJECT_NAME}_test" PRIVATE GTest::gtest_main ${PROJECT_NAME})

add_custom_command(TARGET "${PROJECT_NAME}_test" POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:lanelet2_core>" "$<TARGET_FILE_DIR:${PROJECT_NAME}_test>"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:lanelet2_io>" "$<TARGET_FILE_DIR:${PROJECT_NAME}_test>"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:lanelet2_traffic_rules>" "$<TARGET_FILE_DIR:${PROJECT_NAME}_test>"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:lanelet2_projection>" "$<TARGET_FILE_DIR:${PROJECT_NAME}_test>")
if (WIN32)
add_custom_command(TARGET "${PROJECT_NAME}_test" POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_RUNTIME_DLLS:${PROJECT_NAME}_test>" "$<TARGET_FILE_DIR:${PROJECT_NAME}_test>"
COMMAND_EXPAND_LISTS)
endif ()

gtest_discover_tests("${PROJECT_NAME}_test")
endif ()
10 changes: 6 additions & 4 deletions lanelet2_projection/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5.1)
cmake_minimum_required(VERSION 3.21)
project(lanelet2_projection)

###################
Expand Down Expand Up @@ -47,9 +47,11 @@ if (LANELET2_ENABLE_TESTING)
add_executable("${PROJECT_NAME}_test" ${PROJECT_SOURCE_FILES_TEST})
target_link_libraries("${PROJECT_NAME}_test" PRIVATE GTest::gtest_main ${PROJECT_NAME})

add_custom_command(TARGET "${PROJECT_NAME}_test" POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:lanelet2_core>" "$<TARGET_FILE_DIR:${PROJECT_NAME}_test>"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:lanelet2_io>" "$<TARGET_FILE_DIR:${PROJECT_NAME}_test>")
if (WIN32)
add_custom_command(TARGET "${PROJECT_NAME}_test" POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_RUNTIME_DLLS:${PROJECT_NAME}_test>" "$<TARGET_FILE_DIR:${PROJECT_NAME}_test>"
COMMAND_EXPAND_LISTS)
endif ()

gtest_discover_tests("${PROJECT_NAME}_test")
endif ()
63 changes: 12 additions & 51 deletions lanelet2_python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,69 +1,30 @@
set(MRT_PKG_VERSION 4.0.0)
# Modify only if you know what you are doing!
cmake_minimum_required(VERSION 3.5.1)
cmake_minimum_required(VERSION 3.21)
project(lanelet2_python)

###################
## Find packages ##
###################
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 <package name 1> <package name 2> ...)
# 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()
find_package(Boost REQUIRED COMPONENTS python)
find_package(PythonLibs REQUIRED)

########################
## Add python modules ##
## Build 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( lanelet2
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")

###########
## Build ##
###########
# Declare a cpp library
mrt_add_library(${PROJECT_NAME}
INCLUDES ${PROJECT_HEADER_FILES_INC} ${PROJECT_SOURCE_FILES_INC}
SOURCES ${PROJECT_SOURCE_FILES_SRC}
)
file(GLOB PROJECT_PYTHON_SOURCE_FILES_SRC "${CMAKE_SOURCE_DIR}/python_api/*.cpp")
foreach (PROJECT_PYTHON_SOURCE_FILE ${PROJECT_PYTHON_SOURCE_FILES_SRC})
get_filename_component(PYTHON_MODULE_NAME ${PROJECT_PYTHON_SOURCE_FILE} NAME_WE)
add_library(${PYTHON_MODULE_NAME} SHARED ${PROJECT_PYTHON_SOURCE_FILE})
target_include_directories(${PYTHON_MODULE_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
set_target_properties(${PYTHON_MODULE_NAME} PROPERTIES PREFIX "")
endforeach ()

#############
## 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})


#############
## Testing ##
#############
# Add test targets for cpp and python tests
if (CATKIN_ENABLE_TESTING)
mrt_add_tests(test)
mrt_add_nosetests(test)
endif()
10 changes: 6 additions & 4 deletions lanelet2_routing/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5.1)
cmake_minimum_required(VERSION 3.21)
project(lanelet2_routing)

###################
Expand Down Expand Up @@ -48,9 +48,11 @@ if (LANELET2_ENABLE_TESTING)
add_executable("${PROJECT_NAME}_test" ${PROJECT_SOURCE_FILES_TEST})
target_link_libraries("${PROJECT_NAME}_test" PRIVATE GTest::gtest_main ${PROJECT_NAME})

add_custom_command(TARGET "${PROJECT_NAME}_test" POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:lanelet2_core>" "$<TARGET_FILE_DIR:${PROJECT_NAME}_test>"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:lanelet2_traffic_rules>" "$<TARGET_FILE_DIR:${PROJECT_NAME}_test>")
if (WIN32)
add_custom_command(TARGET "${PROJECT_NAME}_test" POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_RUNTIME_DLLS:${PROJECT_NAME}_test>" "$<TARGET_FILE_DIR:${PROJECT_NAME}_test>"
COMMAND_EXPAND_LISTS)
endif ()

gtest_discover_tests("${PROJECT_NAME}_test")
add_dependencies("${PROJECT_NAME}_test" lanelet2_maps)
Expand Down
9 changes: 6 additions & 3 deletions lanelet2_traffic_rules/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5.1)
cmake_minimum_required(VERSION 3.21)
project(lanelet2_traffic_rules)

###################
Expand Down Expand Up @@ -45,8 +45,11 @@ if (LANELET2_ENABLE_TESTING)
add_executable("${PROJECT_NAME}_test" ${PROJECT_SOURCE_FILES_TEST})
target_link_libraries("${PROJECT_NAME}_test" PRIVATE GTest::gtest_main ${PROJECT_NAME})

add_custom_command(TARGET "${PROJECT_NAME}_test" POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:lanelet2_core>" "$<TARGET_FILE_DIR:${PROJECT_NAME}_test>")
if (WIN32)
add_custom_command(TARGET "${PROJECT_NAME}_test" POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_RUNTIME_DLLS:${PROJECT_NAME}_test>" "$<TARGET_FILE_DIR:${PROJECT_NAME}_test>"
COMMAND_EXPAND_LISTS)
endif ()

gtest_discover_tests("${PROJECT_NAME}_test")
endif ()
13 changes: 6 additions & 7 deletions lanelet2_validation/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5.1)
cmake_minimum_required(VERSION 3.21)
project(lanelet2_validation)

###################
Expand Down Expand Up @@ -68,12 +68,11 @@ if (LANELET2_ENABLE_TESTING)
add_executable("${PROJECT_NAME}_test" ${PROJECT_SOURCE_FILES_TEST})
target_link_libraries("${PROJECT_NAME}_test" PRIVATE GTest::gtest_main ${PROJECT_NAME})

add_custom_command(TARGET "${PROJECT_NAME}_test" POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:lanelet2_core>" "$<TARGET_FILE_DIR:${PROJECT_NAME}_test>"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:lanelet2_io>" "$<TARGET_FILE_DIR:${PROJECT_NAME}_test>"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:lanelet2_traffic_rules>" "$<TARGET_FILE_DIR:${PROJECT_NAME}_test>"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:lanelet2_projection>" "$<TARGET_FILE_DIR:${PROJECT_NAME}_test>"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:lanelet2_routing>" "$<TARGET_FILE_DIR:${PROJECT_NAME}_test>")
if (WIN32)
add_custom_command(TARGET "${PROJECT_NAME}_test" POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_RUNTIME_DLLS:${PROJECT_NAME}_test>" "$<TARGET_FILE_DIR:${PROJECT_NAME}_test>"
COMMAND_EXPAND_LISTS)
endif ()

gtest_discover_tests("${PROJECT_NAME}_test")
add_dependencies("${PROJECT_NAME}_test" lanelet2_maps)
Expand Down

0 comments on commit e55d298

Please sign in to comment.