CMake refactor (#8168)

* Add option VERBOSE_CONFIGURE + several other minor tweaks.

* Minor refactor and expose version option variables for ROS2 build.

* Remove unneeded option BUILD_PYTHON_API_WHEEL_PACKAGE.

* Make cmake_minimum_required uniform + fix potential linker error.

* Revert ROS2 configure.
This commit is contained in:
MarcelPiNacy-CVC 2024-09-19 17:35:18 +02:00 committed by GitHub
parent 4c1196db44
commit 0bbd239b1a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 295 additions and 149 deletions

View File

@ -39,9 +39,9 @@ endif ()
if (WIN32) if (WIN32)
add_compile_definitions (_CRT_SECURE_NO_WARNINGS) add_compile_definitions (_CRT_SECURE_NO_WARNINGS)
check_cxx_compiler_flag (/utf-8 HAS_MSVC_UTF8)
check_cxx_compiler_flag(/utf-8 HAS_MSVC_UTF8)
if (HAS_MSVC_UTF8) if (HAS_MSVC_UTF8)
# @TODO This causes warnings with MASM. A better approach should be looked into.
add_compile_options (/utf-8) add_compile_options (/utf-8)
endif () endif ()
endif () endif ()
@ -49,7 +49,7 @@ endif ()
set (CARLA_COMMON_DEFINITIONS) set (CARLA_COMMON_DEFINITIONS)
foreach (FORMAT ${LIBCARLA_IMAGE_SUPPORTED_FORMATS}) foreach (FORMAT ${LIBCARLA_IMAGE_SUPPORTED_FORMATS})
carla_message ("Enabling CARLA image support for \"${FORMAT}\".") carla_message_verbose ("Enabling CARLA image support for \"${FORMAT}\".")
string (TOUPPER "${FORMAT}" FORMAT_UPPERCASE) string (TOUPPER "${FORMAT}" FORMAT_UPPERCASE)
list (APPEND CARLA_COMMON_DEFINITIONS LIBCARLA_IMAGE_SUPPORT_${FORMAT_UPPERCASE}=1) list (APPEND CARLA_COMMON_DEFINITIONS LIBCARLA_IMAGE_SUPPORT_${FORMAT_UPPERCASE}=1)
endforeach () endforeach ()
@ -61,6 +61,19 @@ if (WIN32)
list (APPEND CARLA_COMMON_DEFINITIONS _USE_MATH_DEFINES) list (APPEND CARLA_COMMON_DEFINITIONS _USE_MATH_DEFINES)
endif () endif ()
if (WIN32)
set (EXE_EXT .exe)
set (UE_SYSTEM_NAME Win64)
elseif (LINUX)
set (EXE_EXT)
set (UE_SYSTEM_NAME Linux)
elseif (APPLE)
set (EXE_EXT)
set (UE_SYSTEM_NAME Mac)
else ()
carla_error ("Unknown target system.")
endif ()
# ================================ # ================================
# Exception Definitions # Exception Definitions
# ================================ # ================================

View File

@ -94,8 +94,9 @@ target_link_libraries (
libsqlite3 libsqlite3
) )
# ==== ZLIB ====
# ==== ZLIB ====
carla_dependency_option (ZLIB_BUILD_EXAMPLES OFF) carla_dependency_option (ZLIB_BUILD_EXAMPLES OFF)
carla_dependency_add ( carla_dependency_add (
zlib zlib
@ -117,8 +118,9 @@ endif ()
carla_dependency_option (ZLIB_INCLUDE_DIRS ${zlib_SOURCE_DIR} ${zlib_BINARY_DIR}) carla_dependency_option (ZLIB_INCLUDE_DIRS ${zlib_SOURCE_DIR} ${zlib_BINARY_DIR})
carla_dependency_option (ZLIB_LIBRARIES ${ZLIB_LIBRARY}) carla_dependency_option (ZLIB_LIBRARIES ${ZLIB_LIBRARY})
# ==== LIBPNG ====
# ==== LIBPNG ====
carla_dependency_option (PNG_SHARED OFF) carla_dependency_option (PNG_SHARED OFF)
carla_dependency_option (PNG_STATIC ON) carla_dependency_option (PNG_STATIC ON)
if (APPLE) if (APPLE)
@ -143,11 +145,6 @@ include_directories (
# ==== BOOST ==== # ==== BOOST ====
carla_dependency_option (BOOST_ENABLE_PYTHON ${BUILD_PYTHON_API})
carla_dependency_option (BOOST_ENABLE_MPI OFF)
carla_dependency_option (BOOST_LOCALE_WITH_ICU OFF)
carla_dependency_option (BOOST_LOCALE_WITH_ICONV OFF)
set ( set (
BOOST_INCLUDED_PROJECTS BOOST_INCLUDED_PROJECTS
asio asio
@ -155,11 +152,22 @@ set (
python python
date_time date_time
geometry geometry
gil
container container
variant2 variant2
gil
)
set (
BOOST_EXCLUDED_PROJECTS
# filesystem # <- Boost.GIL links with Boost.filesystem, so we can't remove the dependency yet.
) )
carla_dependency_option (BOOST_INCLUDE_LIBRARIES "${BOOST_INCLUDED_PROJECTS}") carla_dependency_option (BOOST_INCLUDE_LIBRARIES "${BOOST_INCLUDED_PROJECTS}")
carla_dependency_option (BOOST_EXCLUDE_LIBRARIES "${BOOST_EXCLUDED_PROJECTS}")
carla_dependency_option (BOOST_ENABLE_PYTHON ${BUILD_PYTHON_API})
carla_dependency_option (BOOST_ENABLE_MPI OFF)
carla_dependency_option (BOOST_LOCALE_WITH_ICU OFF)
carla_dependency_option (BOOST_LOCALE_WITH_ICONV OFF)
carla_dependency_option (BOOST_GIL_BUILD_EXAMPLES OFF)
carla_dependency_option (BOOST_GIL_BUILD_HEADER_TESTS OFF)
carla_dependency_add( carla_dependency_add(
boost boost
${CARLA_BOOST_TAG} ${CARLA_BOOST_TAG}
@ -167,8 +175,9 @@ carla_dependency_add(
https://github.com/boostorg/boost.git https://github.com/boostorg/boost.git
) )
# ==== EIGEN ====
# ==== EIGEN ====
carla_dependency_option (EIGEN_BUILD_PKGCONFIG OFF) carla_dependency_option (EIGEN_BUILD_PKGCONFIG OFF)
carla_dependency_option (BUILD_TESTING OFF) carla_dependency_option (BUILD_TESTING OFF)
carla_dependency_option (EIGEN_BUILD_DOC OFF) carla_dependency_option (EIGEN_BUILD_DOC OFF)
@ -179,8 +188,9 @@ carla_dependency_add (
https://gitlab.com/libeigen/eigen.git https://gitlab.com/libeigen/eigen.git
) )
# ==== RPCLIB ====
# ==== RPCLIB ====
carla_dependency_add ( carla_dependency_add (
rpclib rpclib
${CARLA_RPCLIB_TAG} ${CARLA_RPCLIB_TAG}
@ -188,8 +198,9 @@ carla_dependency_add (
https://github.com/carla-simulator/rpclib.git https://github.com/carla-simulator/rpclib.git
) )
# ==== RECAST ====
# ==== RECAST ====
carla_dependency_option (RECASTNAVIGATION_BUILDER ON) carla_dependency_option (RECASTNAVIGATION_BUILDER ON)
carla_dependency_add ( carla_dependency_add (
recastnavigation recastnavigation
@ -198,9 +209,10 @@ carla_dependency_add (
https://github.com/carla-simulator/recastnavigation.git https://github.com/carla-simulator/recastnavigation.git
) )
# ==== PROJ ====
if (ENABLE_OSM2ODR) if (ENABLE_OSM2ODR)
# ==== PROJ ====
carla_dependency_option (BUILD_TESTING OFF) carla_dependency_option (BUILD_TESTING OFF)
carla_dependency_option (ENABLE_TIFF OFF) carla_dependency_option (ENABLE_TIFF OFF)
carla_dependency_option (ENABLE_CURL OFF) carla_dependency_option (ENABLE_CURL OFF)
@ -212,9 +224,10 @@ if (ENABLE_OSM2ODR)
) )
endif () endif ()
# ==== XERCESC ====
if (ENABLE_OSM2ODR) if (ENABLE_OSM2ODR)
# ==== XERCESC ====
carla_dependency_add ( carla_dependency_add (
xercesc xercesc
${CARLA_XERCESC_TAG} ${CARLA_XERCESC_TAG}
@ -223,20 +236,18 @@ if (ENABLE_OSM2ODR)
) )
endif () endif ()
# ==== LUNASVG ====
if (BUILD_OSM_WORLD_RENDERER) if (BUILD_OSM_WORLD_RENDERER)
# ==== LUNASVG ====
carla_dependency_add ( carla_dependency_add (
lunasvg lunasvg
${CARLA_LUNASVG_TAG} ${CARLA_LUNASVG_TAG}
https://github.com/sammycage/lunasvg/archive/refs/tags/${CARLA_LUNASVG_TAG}.zip https://github.com/sammycage/lunasvg/archive/refs/tags/${CARLA_LUNASVG_TAG}.zip
https://github.com/sammycage/lunasvg.git https://github.com/sammycage/lunasvg.git
) )
endif ()
# ==== LIBOSMSCOUT ==== # ==== LIBOSMSCOUT ====
if (BUILD_OSM_WORLD_RENDERER)
carla_dependency_add ( carla_dependency_add (
libosmscout libosmscout
${CARLA_LIBOSMSCOUT_TAG} ${CARLA_LIBOSMSCOUT_TAG}
@ -245,9 +256,10 @@ if (BUILD_OSM_WORLD_RENDERER)
) )
endif () endif ()
# ==== STREETMAP ====
if (BUILD_CARLA_UNREAL) if (BUILD_CARLA_UNREAL)
# ==== STREETMAP ====
carla_dependency_add ( carla_dependency_add (
StreetMap StreetMap
${CARLA_STREETMAP_TAG} ${CARLA_STREETMAP_TAG}

View File

@ -104,12 +104,6 @@ carla_option (
OFF OFF
) )
carla_option (
BUILD_PYTHON_API_WHEEL_PACKAGE
"Whether to build the CARLA python API wheel package."
ON
)
carla_option ( carla_option (
ENABLE_PEP517 ENABLE_PEP517
"Whether to use PEP 517." "Whether to use PEP 517."
@ -146,6 +140,12 @@ carla_string_option (
/usr/bin/gcc-12 /usr/bin/gcc-12
) )
carla_option (
VERBOSE_CONFIGURE
"Whether to emit extra messages during CMake configure."
OFF
)
# ================================ # ================================
@ -198,18 +198,14 @@ carla_string_option (
"${CARLA_UNREAL_RHI_DEFAULT}" "${CARLA_UNREAL_RHI_DEFAULT}"
) )
if (${BUILD_CARLA_UNREAL}) if (BUILD_CARLA_UNREAL)
if (${CARLA_HAS_UNREAL_ENGINE_PATH}) if (NOT ${CARLA_HAS_UNREAL_ENGINE_PATH})
carla_message ( carla_error (
"Carla UE project successfully added to build. (UE path: ${CARLA_UNREAL_ENGINE_PATH})" "Could not add UE project to build since the carla_option CARLA_UNREAL_ENGINE_PATH "
) "is not set to a valid path (\"${CARLA_UNREAL_ENGINE_PATH}\")."
else () "Please set it to point to the root path of your CARLA Unreal Engine installation."
carla_error ( )
"Could not add UE project to build since the carla_option CARLA_UNREAL_ENGINE_PATH " endif ()
"is not set to a valid path (\"${CARLA_UNREAL_ENGINE_PATH}\")."
"Please set it to point to the root path of your CARLA Unreal Engine installation."
)
endif ()
endif () endif ()
carla_string_option ( carla_string_option (
@ -380,7 +376,6 @@ carla_string_option (
${CARLA_LIBOSMSCOUT_VERSION} ${CARLA_LIBOSMSCOUT_VERSION}
) )
# ==== STREETMAP ==== # ==== STREETMAP ====
carla_string_option ( carla_string_option (
@ -394,3 +389,45 @@ carla_string_option (
"Target StreetMap git tag." "Target StreetMap git tag."
${CARLA_STREETMAP_VERSION} ${CARLA_STREETMAP_VERSION}
) )
# ==== FASTDDS ====
carla_string_option (
CARLA_FASTDDS_VERSION
"Target Fast-DDS version."
2.11.2
)
carla_string_option (
CARLA_FASTDDS_TAG
"Target Fast-DDS git tag."
${CARLA_FASTDDS_VERSION}
)
# ==== FASTCDR ====
carla_string_option (
CARLA_FASTCDR_VERSION
"Target Fast-CDR version."
2.2.x
)
carla_string_option (
CARLA_FASTCDR_TAG
"Target Fast-CDR git tag."
${CARLA_FASTCDR_VERSION}
)
# ==== FOONATHAN MEMORY VENDOR ====
carla_string_option (
CARLA_FOONATHAN_MEMORY_VENDOR_VERSION
"Target foonathan_memory_vendor version."
master
)
carla_string_option (
CARLA_FOONATHAN_MEMORY_VENDOR_TAG
"Target foonathan_memory_vendor git tag."
${CARLA_FOONATHAN_MEMORY_VENDOR_VERSION}
)

View File

@ -1,20 +1,15 @@
# Similar to configure_file, but also expands variables
# that are set at generate time, like generator expressions.
function (carla_two_step_configure_file DESTINATION SOURCE)
carla_message ("Configuring file ${DESTINATION}")
# Configure-time step; evaluate variables:
configure_file (${SOURCE} ${DESTINATION} @ONLY)
# Generate-time step; evaluate generator expressions:
file (GENERATE OUTPUT ${DESTINATION} INPUT ${DESTINATION})
endfunction ()
# message wrapper for normal messages. # message wrapper for normal messages.
function (carla_message) function (carla_message)
message (STATUS "CARLA: " ${ARGN}) message (STATUS "CARLA: " ${ARGN})
endfunction () endfunction ()
# message wrapper for normal messages.
function (carla_message_verbose)
if (VERBOSE_CONFIGURE)
message (STATUS "CARLA: " ${ARGN})
endif ()
endfunction ()
# message() wrapper for warnings. # message() wrapper for warnings.
@ -39,7 +34,7 @@ endfunction ()
macro (carla_option NAME DESCRIPTION VALUE) macro (carla_option NAME DESCRIPTION VALUE)
option (${NAME} ${DESCRIPTION} ${VALUE}) option (${NAME} ${DESCRIPTION} ${VALUE})
carla_message ("(option) ${NAME} : ${${NAME}}") carla_message_verbose ("(option) ${NAME} : ${${NAME}}")
get_property (DOCS GLOBAL PROPERTY CARLA_OPTION_DOCS) get_property (DOCS GLOBAL PROPERTY CARLA_OPTION_DOCS)
string ( string (
APPEND APPEND
@ -55,7 +50,7 @@ endmacro ()
macro (carla_string_option NAME DESCRIPTION VALUE) macro (carla_string_option NAME DESCRIPTION VALUE)
set (${NAME} "${VALUE}") set (${NAME} "${VALUE}")
carla_message ("(option) ${NAME} : \"${${NAME}}\"") carla_message_verbose ("(option) ${NAME} : \"${${NAME}}\"")
get_property (DOCS GLOBAL PROPERTY CARLA_OPTION_DOCS) get_property (DOCS GLOBAL PROPERTY CARLA_OPTION_DOCS)
string ( string (
APPEND APPEND
@ -69,6 +64,18 @@ endmacro ()
# Similar to configure_file, but also expands variables
# that are set at generate time, like generator expressions.
function (carla_two_step_configure_file DESTINATION SOURCE)
carla_message_verbose ("Configuring file ${DESTINATION}")
# Configure-time step; evaluate variables:
configure_file (${SOURCE} ${DESTINATION} @ONLY)
# Generate-time step; evaluate generator expressions:
file (GENERATE OUTPUT ${DESTINATION} INPUT ${DESTINATION})
endfunction ()
# If, for some reason, CARLA is configured with CMake<3.5, this is necessary: # If, for some reason, CARLA is configured with CMake<3.5, this is necessary:
if (${CMAKE_VERSION} VERSION_LESS 3.5) if (${CMAKE_VERSION} VERSION_LESS 3.5)
include (CMakeParseArguments) include (CMakeParseArguments)
@ -139,6 +146,34 @@ endfunction ()
if (VERBOSE_CONFIGURE)
macro (carla_print_cmake_variable NAME)
carla_message ("${NAME}: \'${${NAME}}\'")
endmacro ()
carla_print_cmake_variable (CMAKE_C_COMPILER)
carla_print_cmake_variable (CMAKE_CXX_COMPILER)
carla_print_cmake_variable (CMAKE_ASM_COMPILER)
carla_print_cmake_variable (CMAKE_AR)
carla_print_cmake_variable (CMAKE_C_COMPILER_AR)
carla_print_cmake_variable (CMAKE_CXX_COMPILER_AR)
carla_print_cmake_variable (CMAKE_OBJCOPY)
carla_print_cmake_variable (CMAKE_ADDR2LINE)
carla_print_cmake_variable (CMAKE_C_COMPILER_RANLIB)
carla_print_cmake_variable (CMAKE_CXX_COMPILER_RANLIB)
carla_print_cmake_variable (CMAKE_LINKER)
carla_print_cmake_variable (CMAKE_NM)
carla_print_cmake_variable (CMAKE_OBJDUMP)
carla_print_cmake_variable (CMAKE_RANLIB)
carla_print_cmake_variable (CMAKE_READELF)
carla_print_cmake_variable (CMAKE_STRIP)
carla_print_cmake_variable (COVERAGE_COMMAND)
carla_print_cmake_variable (CMAKE_CXX_STANDARD_LIBRARIES)
carla_print_cmake_variable (CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES)
endif ()
carla_add_target_docs ( carla_add_target_docs (
NAME clean NAME clean
TYPE Builtin TYPE Builtin

View File

@ -8,9 +8,14 @@
]] ]]
set (
CARLA_CMAKE_MINIMUM_REQUIRED_VERSION
3.27.2
)
cmake_minimum_required ( cmake_minimum_required (
VERSION VERSION
3.27.2 ${CARLA_CMAKE_MINIMUM_REQUIRED_VERSION}
) )
cmake_policy (SET CMP0097 NEW) cmake_policy (SET CMP0097 NEW)

View File

@ -11,11 +11,6 @@ set (
${CARLA_WORKSPACE_PATH}/LibCarla/source ${CARLA_WORKSPACE_PATH}/LibCarla/source
) )
set (
LIBCARLA_THIRD_PARTY_SOURCE_PATH
${LIBCARLA_SOURCE_PATH}/third-party
)
carla_two_step_configure_file ( carla_two_step_configure_file (
${LIBCARLA_SOURCE_PATH}/carla/Version.h ${LIBCARLA_SOURCE_PATH}/carla/Version.h
${LIBCARLA_SOURCE_PATH}/carla/Version.h.in ${LIBCARLA_SOURCE_PATH}/carla/Version.h.in
@ -59,9 +54,9 @@ if (BUILD_CARLA_SERVER)
file ( file (
GLOB GLOB
LIBCARLA_SERVER_SOURCES_THIRD_PARTY LIBCARLA_SERVER_SOURCES_THIRD_PARTY
${LIBCARLA_THIRD_PARTY_SOURCE_PATH}/odrSpiral/*.cpp ${LIBCARLA_SOURCE_PATH}/third-party/odrSpiral/*.cpp
${LIBCARLA_THIRD_PARTY_SOURCE_PATH}/moodycamel/*.cpp ${LIBCARLA_SOURCE_PATH}/third-party/moodycamel/*.cpp
${LIBCARLA_THIRD_PARTY_SOURCE_PATH}/pugixml/*.cpp ${LIBCARLA_SOURCE_PATH}/third-party/pugixml/*.cpp
) )
file ( file (
@ -107,9 +102,9 @@ if (BUILD_CARLA_SERVER)
file ( file (
GLOB GLOB
LIBCARLA_SERVER_HEADERS_THIRD_PARTY LIBCARLA_SERVER_HEADERS_THIRD_PARTY
${LIBCARLA_THIRD_PARTY_SOURCE_PATH}/odrSpiral/*.h ${LIBCARLA_SOURCE_PATH}/third-party/odrSpiral/*.h
${LIBCARLA_THIRD_PARTY_SOURCE_PATH}/moodycamel/*.h ${LIBCARLA_SOURCE_PATH}/third-party/moodycamel/*.h
${LIBCARLA_THIRD_PARTY_SOURCE_PATH}/pugixml/*.hpp ${LIBCARLA_SOURCE_PATH}/third-party/pugixml/*.hpp
) )
carla_add_library ( carla_add_library (
@ -206,10 +201,10 @@ if (BUILD_CARLA_CLIENT)
file ( file (
GLOB GLOB
LIBCARLA_CLIENT_HEADERS_THIRD_PARTY LIBCARLA_CLIENT_HEADERS_THIRD_PARTY
${LIBCARLA_THIRD_PARTY_SOURCE_PATH}/odrSpiral/*.h ${LIBCARLA_SOURCE_PATH}/third-party/odrSpiral/*.h
${LIBCARLA_THIRD_PARTY_SOURCE_PATH}/moodycamel/*.h ${LIBCARLA_SOURCE_PATH}/third-party/moodycamel/*.h
${LIBCARLA_THIRD_PARTY_SOURCE_PATH}/pugixml/*.hpp ${LIBCARLA_SOURCE_PATH}/third-party/pugixml/*.hpp
${LIBCARLA_THIRD_PARTY_SOURCE_PATH}/pugixml/*.h ${LIBCARLA_SOURCE_PATH}/third-party/pugixml/*.h
) )
file ( file (
@ -257,8 +252,8 @@ if (BUILD_CARLA_CLIENT)
file ( file (
GLOB GLOB
LIBCARLA_CLIENT_SOURCES_THIRD_PARTY LIBCARLA_CLIENT_SOURCES_THIRD_PARTY
${LIBCARLA_THIRD_PARTY_SOURCE_PATH}/odrSpiral/*.cpp ${LIBCARLA_SOURCE_PATH}/third-party/odrSpiral/*.cpp
${LIBCARLA_THIRD_PARTY_SOURCE_PATH}/pugixml/*.cpp ${LIBCARLA_SOURCE_PATH}/third-party/pugixml/*.cpp
) )
carla_add_library ( carla_add_library (

View File

@ -23,13 +23,47 @@ set (
RecastNavigation::DetourCrowd RecastNavigation::DetourCrowd
) )
get_target_property (Boost_asio_TARGET_NAME Boost::asio ALIASED_TARGET) get_target_property (
get_target_property (Boost_python_TARGET_NAME Boost::python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR} ALIASED_TARGET) Boost_asio_TARGET_NAME
get_target_property (Boost_geometry_TARGET_NAME Boost::geometry ALIASED_TARGET) Boost::asio
get_target_property (Boost_gil_TARGET_NAME Boost::gil ALIASED_TARGET) ALIASED_TARGET
get_target_property (RecastNavigation_Recast_TARGET_NAME RecastNavigation::Recast ALIASED_TARGET) )
get_target_property (RecastNavigation_Detour_TARGET_NAME RecastNavigation::Detour ALIASED_TARGET)
get_target_property (RecastNavigation_DetourCrowd_TARGET_NAME RecastNavigation::DetourCrowd ALIASED_TARGET) get_target_property (
Boost_python_TARGET_NAME
Boost::python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}
ALIASED_TARGET
)
get_target_property (
Boost_geometry_TARGET_NAME
Boost::geometry
ALIASED_TARGET
)
get_target_property (
Boost_gil_TARGET_NAME
Boost::gil
ALIASED_TARGET
)
get_target_property (
RecastNavigation_Recast_TARGET_NAME
RecastNavigation::Recast
ALIASED_TARGET
)
get_target_property (
RecastNavigation_Detour_TARGET_NAME
RecastNavigation::Detour
ALIASED_TARGET
)
get_target_property (
RecastNavigation_DetourCrowd_TARGET_NAME
RecastNavigation::DetourCrowd
ALIASED_TARGET
)
set ( set (
CARLA_PYTHON_API_CARLA_PATH CARLA_PYTHON_API_CARLA_PATH

View File

@ -1,6 +1,6 @@
cmake_minimum_required ( cmake_minimum_required (
VERSION VERSION
@CMAKE_MAJOR_VERSION@.@CMAKE_MINOR_VERSION@.@CMAKE_PATCH_VERSION@ @CARLA_CMAKE_MINIMUM_REQUIRED_VERSION@
) )
project ( project (
@ -47,7 +47,7 @@ set (
${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}
) )
carla_message ( carla_message_verbose (
"Selected Python executable: ${Python3_EXECUTABLE} (Interpreter ID: ${Python3_INTERPRETER_ID})" "Selected Python executable: ${Python3_EXECUTABLE} (Interpreter ID: ${Python3_INTERPRETER_ID})"
) )

View File

@ -1,10 +1,14 @@
cmake_minimum_required (VERSION 3.28.0) cmake_minimum_required (
VERSION
${CARLA_CMAKE_MINIMUM_REQUIRED_VERSION}
)
project (carla-ros2-native-project) project (carla-ros2-native-project)
include (ExternalProject) include (ExternalProject)
set (PROJECT_INSTALL_PATH ${CMAKE_CURRENT_BINARY_DIR}/install) set (PROJECT_INSTALL_PATH ${CMAKE_CURRENT_BINARY_DIR}/install)
set (PROJECT_CMAKE_FLAGS set (PROJECT_CMAKE_FLAGS
-DCMAKE_CXX_COMPILER=${GXX_COMPILER} -DCMAKE_CXX_COMPILER=${GXX_COMPILER}
-DCMAKE_C_COMPILER=${GCC_COMPILER} -DCMAKE_C_COMPILER=${GCC_COMPILER}
@ -15,13 +19,13 @@ set (PROJECT_CMAKE_FLAGS
ExternalProject_add ( ExternalProject_add (
foonathan_memory foonathan_memory
URL https://github.com/eProsima/foonathan_memory_vendor/archive/refs/heads/master.zip URL https://github.com/eProsima/foonathan_memory_vendor/archive/refs/heads/${CARLA_FOONATHAN_MEMORY_VENDOR_TAG}.zip
CMAKE_ARGS ${PROJECT_CMAKE_FLAGS} -DBUILD_SHARED_LIBS=ON -DFOONATHAN_MEMORY_FORCE_VENDORED_BUILD=ON CMAKE_ARGS ${PROJECT_CMAKE_FLAGS} -DBUILD_SHARED_LIBS=ON -DFOONATHAN_MEMORY_FORCE_VENDORED_BUILD=ON
) )
ExternalProject_add ( ExternalProject_add (
fastcdr fastcdr
URL https://github.com/eProsima/Fast-CDR/archive/refs/heads/1.1.x.zip URL https://github.com/eProsima/Fast-CDR/archive/refs/heads/${CARLA_FASTCDR_TAG}.zip
CMAKE_ARGS ${PROJECT_CMAKE_FLAGS} CMAKE_ARGS ${PROJECT_CMAKE_FLAGS}
) )
@ -30,7 +34,7 @@ ExternalProject_add (
ExternalProject_add ( ExternalProject_add (
fastdds fastdds
GIT_REPOSITORY https://github.com/eProsima/Fast-DDS.git GIT_REPOSITORY https://github.com/eProsima/Fast-DDS.git
GIT_TAG 2.11.2 GIT_TAG ${CARLA_FASTDDS_TAG}
CMAKE_ARGS ${PROJECT_CMAKE_FLAGS} -DTHIRDPARTY_Asio=FORCE -DTHIRDPARTY_TinyXML2=FORCE -DCOMPILE_TOOLS=OFF CMAKE_ARGS ${PROJECT_CMAKE_FLAGS} -DTHIRDPARTY_Asio=FORCE -DTHIRDPARTY_TinyXML2=FORCE -DCOMPILE_TOOLS=OFF
DEPENDS foonathan_memory fastcdr DEPENDS foonathan_memory fastcdr
) )

View File

@ -1,44 +1,63 @@
cmake_minimum_required (VERSION 3.28.0) cmake_minimum_required (
VERSION
3.27.2
)
project(carla-ros2-native) project (
carla-ros2-native
)
set (LIBCARLA_SOURCE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../LibCarla/source) set (
LIBCARLA_SOURCE_PATH
file ( ${CMAKE_CURRENT_SOURCE_DIR}/../../LibCarla/source
GLOB
LIBCARLA_ROS2_SOURCES
${LIBCARLA_SOURCE_PATH}/carla/ros2/publishers/*.cpp
${LIBCARLA_SOURCE_PATH}/carla/ros2/subscribers/*.cpp
${LIBCARLA_SOURCE_PATH}/carla/ros2/listeners/*.cpp
${LIBCARLA_SOURCE_PATH}/carla/ros2/types/*.cpp
) )
file ( file (
GLOB GLOB
LIBCARLA_ROS2_HEADERS LIBCARLA_ROS2_SOURCES
${LIBCARLA_SOURCE_PATH}/carla/ros2/publishers/*.h ${LIBCARLA_SOURCE_PATH}/carla/ros2/publishers/*.cpp
${LIBCARLA_SOURCE_PATH}/carla/ros2/subscribers/*.h ${LIBCARLA_SOURCE_PATH}/carla/ros2/subscribers/*.cpp
${LIBCARLA_SOURCE_PATH}/carla/ros2/listeners/*.h ${LIBCARLA_SOURCE_PATH}/carla/ros2/listeners/*.cpp
${LIBCARLA_SOURCE_PATH}/carla/ros2/types/*.h ${LIBCARLA_SOURCE_PATH}/carla/ros2/types/*.cpp
)
file (
GLOB
LIBCARLA_ROS2_HEADERS
${LIBCARLA_SOURCE_PATH}/carla/ros2/publishers/*.h
${LIBCARLA_SOURCE_PATH}/carla/ros2/subscribers/*.h
${LIBCARLA_SOURCE_PATH}/carla/ros2/listeners/*.h
${LIBCARLA_SOURCE_PATH}/carla/ros2/types/*.h
) )
add_library ( add_library (
carla-ros2-native carla-ros2-native
SHARED SHARED
${LIBCARLA_ROS2_HEADERS} ${LIBCARLA_ROS2_HEADERS}
${LIBCARLA_ROS2_SOURCES} ${LIBCARLA_ROS2_SOURCES}
) )
target_include_directories (carla-ros2-native SYSTEM PRIVATE target_include_directories (
${LIBCARLA_SOURCE_PATH} carla-ros2-native
${CMAKE_INSTALL_PREFIX}/include SYSTEM PRIVATE
${LIBCARLA_SOURCE_PATH}
${CMAKE_INSTALL_PREFIX}/include
) )
target_compile_definitions (carla-ros2-native PUBLIC target_compile_definitions (
BOOST_ASIO_ENABLE_BUFFER_DEBUGGING carla-ros2-native
PUBLIC
BOOST_ASIO_ENABLE_BUFFER_DEBUGGING
) )
target_link_libraries(carla-ros2-native target_link_libraries (
${CMAKE_INSTALL_PREFIX}/lib/libfastrtps.so) carla-ros2-native
${CMAKE_INSTALL_PREFIX}/lib/libfastrtps.so
)
install (TARGETS carla-ros2-native DESTINATION lib) install (
TARGETS
carla-ros2-native
DESTINATION
lib
)

View File

@ -66,19 +66,6 @@ if (ENABLE_ROS2_DEMO)
set (LAUNCH_ARGS ${LAUNCH_ARGS} --ros2-demo) set (LAUNCH_ARGS ${LAUNCH_ARGS} --ros2-demo)
endif() endif()
if (WIN32)
set (EXE_EXT .exe)
set (UE_SYSTEM_NAME Win64)
elseif (LINUX)
set (EXE_EXT)
set (UE_SYSTEM_NAME Linux)
elseif (APPLE)
set (EXE_EXT)
set (UE_SYSTEM_NAME Mac)
else ()
carla_error ("Unknown target system.")
endif ()
set ( set (
UNREAL_EDITOR_PATH UNREAL_EDITOR_PATH
${CARLA_UNREAL_ENGINE_PATH}/Engine/Binaries/${UE_SYSTEM_NAME}/UnrealEditor${EXE_EXT} ${CARLA_UNREAL_ENGINE_PATH}/Engine/Binaries/${UE_SYSTEM_NAME}/UnrealEditor${EXE_EXT}
@ -86,9 +73,8 @@ set (
set (CARLA_UE_CONTENT_CHECK_PATH ${CARLA_UE_PATH}/Content/Carla/Blueprints) set (CARLA_UE_CONTENT_CHECK_PATH ${CARLA_UE_PATH}/Content/Carla/Blueprints)
if (IS_DIRECTORY ${CARLA_UE_CONTENT_CHECK_PATH}) if (IS_DIRECTORY ${CARLA_UE_CONTENT_CHECK_PATH})
carla_message ("CARLA Unreal Content - FOUND") carla_message_verbose ("CARLA Unreal Content - FOUND")
else () else ()
carla_message ("CARLA Unreal Content - MISSING")
carla_warning ("Could not find CARLA Content, download it or running the editor will result in a crash.") carla_warning ("Could not find CARLA Content, download it or running the editor will result in a crash.")
endif () endif ()
@ -380,8 +366,11 @@ function (
set (PACKAGE_CONFIGURATION "default (shipping)") set (PACKAGE_CONFIGURATION "default (shipping)")
endif () endif ()
set (TARGET_NAME_SHORT package${TARGET_NAME_SUFFIX})
set (TARGET_NAME carla-unreal-${TARGET_NAME_SHORT})
carla_add_custom_target ( carla_add_custom_target (
carla-unreal-package${TARGET_NAME_SUFFIX} ${TARGET_NAME}
"Create a CARLA package in ${PACKAGE_CONFIGURATION} mode." "Create a CARLA package in ${PACKAGE_CONFIGURATION} mode."
COMMAND COMMAND
${CARLA_UE_BUILD_COMMAND_PREFIX} ${CARLA_UE_BUILD_COMMAND_PREFIX}
@ -415,7 +404,7 @@ function (
) )
add_custom_command ( add_custom_command (
TARGET carla-unreal-package${TARGET_NAME_SUFFIX} TARGET ${TARGET_NAME}
POST_BUILD POST_BUILD
COMMAND ${CMAKE_COMMAND} -E echo "********** PACKAGE CREATING VERSION FILE UNREAL PACKAGE EXTRA FILES STARTED **********" COMMAND ${CMAKE_COMMAND} -E echo "********** PACKAGE CREATING VERSION FILE UNREAL PACKAGE EXTRA FILES STARTED **********"
COMMAND ${CMAKE_COMMAND} COMMAND ${CMAKE_COMMAND}
@ -449,21 +438,24 @@ function (
) )
add_dependencies ( add_dependencies (
carla-unreal-package${TARGET_NAME_SUFFIX} ${TARGET_NAME}
carla-unreal-editor carla-unreal-editor
) )
carla_add_custom_target ( carla_add_custom_target (
package${TARGET_NAME_SUFFIX} ${TARGET_NAME_SHORT}
"Create a CARLA package in ${PACKAGE_CONFIGURATION} mode." "Create a CARLA package in ${PACKAGE_CONFIGURATION} mode."
) )
add_dependencies ( add_dependencies (
package${TARGET_NAME_SUFFIX} ${TARGET_NAME_SHORT}
carla-unreal-package${TARGET_NAME_SUFFIX} ${TARGET_NAME}
) )
endfunction() endfunction()
# Docs for UE5 build configurations: # Docs for UE5 build configurations:
# https://docs.unrealengine.com/4.27/en-US/ProductionPipelines/DevelopmentSetup/BuildConfigurations/ # https://docs.unrealengine.com/4.27/en-US/ProductionPipelines/DevelopmentSetup/BuildConfigurations/
add_carla_ue_package_target("" Shipping) add_carla_ue_package_target("" Shipping)
@ -488,12 +480,6 @@ set (
VERBATIM VERBATIM
) )
carla_add_custom_target (
launch
"Build and open CARLA in the Unreal Editor."
${CARLA_LAUNCH_TARGET_OPTIONS}
)
if (WIN32) if (WIN32)
set ( set (
PRELAUNCH_CONTENT_CHECK_COMMAND PRELAUNCH_CONTENT_CHECK_COMMAND
@ -517,12 +503,6 @@ carla_add_custom_target (
VERBATIM VERBATIM
) )
add_dependencies (
launch
carla-unreal-editor
check-unreal-content
)
carla_add_custom_target ( carla_add_custom_target (
launch-only launch-only
"Open CARLA in the Unreal Editor. This will not rebuild outdated targets." "Open CARLA in the Unreal Editor. This will not rebuild outdated targets."
@ -534,6 +514,18 @@ add_dependencies (
check-unreal-content check-unreal-content
) )
carla_add_custom_target (
launch
"Build and open CARLA in the Unreal Editor."
${CARLA_LAUNCH_TARGET_OPTIONS}
)
add_dependencies (
launch
carla-unreal-editor
check-unreal-content
)
set_property ( set_property (
DIRECTORY APPEND PROPERTY ADDITIONAL_CLEAN_FILES DIRECTORY APPEND PROPERTY ADDITIONAL_CLEAN_FILES
"${CARLA_UE_PATH}/Binaries" "${CARLA_UE_PATH}/Binaries"