From 08c06a01df5c1838bc2edb31e002576f6276da27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=20Sol=C3=A9=20Nogu=C3=A9s?= Date: Mon, 13 May 2024 11:45:53 +0200 Subject: [PATCH] =?UTF-8?q?Revert=20"Introduce=20several=20helper=20macros?= =?UTF-8?q?=20and=20utilities=20for=20improved=20usability.=E2=80=A6"=20(#?= =?UTF-8?q?7635)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 321082ed0b4ca0b421bec3fd4ee2a12090c897c8. Co-authored-by: Marcel Pi --- .gitignore | 2 - CMake/Options.cmake | 10 ++- CMake/Util.cmake | 90 ++------------------ CMakeLists.txt | 27 +----- Examples/CppClient/CMakeLists.txt | 3 +- LibCarla/CMakeLists.txt | 15 +++- PythonAPI/CMakeLists.txt | 6 +- Ros2Native/CMakeLists.txt | 26 +++--- Ros2Native/LibCarlaRos2Native/CMakeLists.txt | 7 +- Unreal/CMakeLists.txt | 54 +++++------- osm-world-renderer/CMakeLists.txt | 6 +- 11 files changed, 66 insertions(+), 180 deletions(-) diff --git a/.gitignore b/.gitignore index bff4d8432..51b46a87a 100644 --- a/.gitignore +++ b/.gitignore @@ -9,5 +9,3 @@ Dist/ out/ CMakeSettings.json - -Help.md diff --git a/CMake/Options.cmake b/CMake/Options.cmake index 22abe12ff..d5ac73375 100644 --- a/CMake/Options.cmake +++ b/CMake/Options.cmake @@ -125,7 +125,13 @@ carla_option ( carla_string_option ( LIBCARLA_IMAGE_SUPPORTED_FORMATS "Semicolon-separated list of supported image formats by LibCarla. Available formats: png, jpeg, tiff." - "png" + png +) + +carla_string_option ( + GCC_COMPILER + "gcc compiler used by some CARLA extensions." + /usr/bin/gcc-7 ) @@ -186,7 +192,7 @@ if (${BUILD_CARLA_UNREAL} AND ${CARLA_HAS_UNREAL_ENGINE_PATH}) ) else () carla_error ( - "Could not add UE project to build since the carla_option 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}\")." "Please set it to point to the root path of your CARLA Unreal Engine installation." ) diff --git a/CMake/Util.cmake b/CMake/Util.cmake index e635de73a..a30fc797a 100644 --- a/CMake/Util.cmake +++ b/CMake/Util.cmake @@ -1,12 +1,12 @@ # 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) +macro (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 () +endmacro () @@ -17,104 +17,26 @@ endfunction () -# message() wrapper for warnings. -function (carla_warning) +# message wrapper for warnings. +macro (carla_warning) message (WARNING ${ARGN}) -endfunction () +endmacro () -# message() wrapper for errors. +# message wrapper for errors. function (carla_error) message (FATAL_ERROR ${ARGN}) endfunction () -function (carla_get_option_docs OUT_VAR) - get_property (DOCS GLOBAL PROPERTY CARLA_OPTION_DOCS) - set (${OUT_VAR} ${DOCS}) - return (PROPAGATE ${OUT_VAR}) -endfunction () - macro (carla_option NAME DESCRIPTION VALUE) option (${NAME} ${DESCRIPTION} ${VALUE}) carla_message ("(option) ${NAME} : ${VALUE}") - get_property (DOCS GLOBAL PROPERTY CARLA_OPTION_DOCS) - string ( - APPEND - DOCS - "- ${NAME}\n" - "\t- Description: ${DESCRIPTION}\n" - "\t- Default: ${VALUE}\n" - ) - set_property (GLOBAL PROPERTY CARLA_OPTION_DOCS ${DOCS}) endmacro () - - macro (carla_string_option NAME DESCRIPTION VALUE) set (${NAME} "${VALUE}") carla_message ("(option) ${NAME} : \"${VALUE}\"") - get_property (DOCS GLOBAL PROPERTY CARLA_OPTION_DOCS) - string ( - APPEND - DOCS - "- ${NAME}\n" - "\t- Description: ${DESCRIPTION}\n" - "\t- Default: \"${VALUE}\"\n" - ) - set_property (GLOBAL PROPERTY CARLA_OPTION_DOCS ${DOCS}) endmacro () - - - -function (carla_get_target_docs OUT_VAR) - get_property (DOCS GLOBAL PROPERTY CARLA_TARGET_DOCS) - set (${OUT_VAR} ${DOCS}) - return (PROPAGATE ${OUT_VAR}) -endfunction () - - -function (carla_add_library NAME DESCRIPTION) - get_property (DOCS GLOBAL PROPERTY CARLA_TARGET_DOCS) - string ( - APPEND - DOCS - "- ${NAME}\n" - "\t- Type: Library\n" - "\t- Description: ${DESCRIPTION}\n" - ) - add_library (${NAME} ${ARGN}) - set_property (GLOBAL PROPERTY CARLA_TARGET_DOCS ${DOCS}) -endfunction () - - - -function (carla_add_executable NAME DESCRIPTION) - get_property (DOCS GLOBAL PROPERTY CARLA_TARGET_DOCS) - string ( - APPEND - DOCS - "- ${NAME}\n" - "\t- Type: Executable\n" - "\t- Description: ${DESCRIPTION}\n" - ) - add_executable (${NAME} ${ARGN}) - set_property (GLOBAL PROPERTY CARLA_TARGET_DOCS ${DOCS}) -endfunction () - - - -function (carla_add_custom_target NAME DESCRIPTION) - get_property (DOCS GLOBAL PROPERTY CARLA_TARGET_DOCS) - string ( - APPEND - DOCS - "- ${NAME}\n" - "\t- Type: CustomTarget\n" - "\t- Description: ${DESCRIPTION}\n" - ) - add_custom_target (${NAME} ${ARGN}) - set_property (GLOBAL PROPERTY CARLA_TARGET_DOCS ${DOCS}) -endfunction () diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a8232dc6..9170d32c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,6 +73,8 @@ include (${CARLA_WORKSPACE_PATH}/CMake/Options.cmake) include (${CARLA_WORKSPACE_PATH}/CMake/Common.cmake) include (${CARLA_WORKSPACE_PATH}/CMake/Dependencies.cmake) + + if (BUILD_CARLA_CLIENT OR BUILD_CARLA_SERVER) add_subdirectory (LibCarla) endif () @@ -97,28 +99,3 @@ endif () if (BUILD_EXAMPLES) add_subdirectory (Examples) endif () - -carla_add_custom_target ( - carla-help - "Display this message." - COMMAND ${CMAKE_COMMAND} -E cat "${CMAKE_CURRENT_BINARY_DIR}/Help.md" -) - -carla_get_option_docs (CARLA_OPTION_DOCS) -carla_get_target_docs (CARLA_TARGET_DOCS) -set (CARLA_CMAKE_HELP_MESSAGE) -string ( - APPEND - CARLA_CMAKE_HELP_MESSAGE - "# CARLA - CMake Help\n" - "## CMake Targets\n" - "${CARLA_TARGET_DOCS}\n" - "## CMake Options\n" - "${CARLA_OPTION_DOCS}\n" -) - -file ( - WRITE - ${CMAKE_CURRENT_BINARY_DIR}/Help.md - ${CARLA_CMAKE_HELP_MESSAGE} -) diff --git a/Examples/CppClient/CMakeLists.txt b/Examples/CppClient/CMakeLists.txt index 4ce087545..343ed24b2 100644 --- a/Examples/CppClient/CMakeLists.txt +++ b/Examples/CppClient/CMakeLists.txt @@ -1,8 +1,7 @@ project (carla-example-cpp-client) -carla_add_executable ( +add_executable ( carla-example-cpp-client - "Build the CARLA C++ client example." main.cpp ) diff --git a/LibCarla/CMakeLists.txt b/LibCarla/CMakeLists.txt index e6ccfce9f..7325ae497 100644 --- a/LibCarla/CMakeLists.txt +++ b/LibCarla/CMakeLists.txt @@ -108,9 +108,8 @@ if (BUILD_CARLA_SERVER) ${LIBCARLA_THIRD_PARTY_SOURCE_PATH}/pugixml/*.hpp ) - carla_add_library ( + add_library ( carla-server - "Build the CARLA server." ${LIBCARLA_SERVER_HEADERS} ${LIBCARLA_SERVER_SOURCES} ${LIBCARLA_SERVER_HEADERS_THIRD_PARTY} @@ -265,9 +264,8 @@ if (BUILD_CARLA_CLIENT) ${LIBCARLA_THIRD_PARTY_SOURCE_PATH}/pugixml/*.cpp ) - carla_add_library ( + add_library ( carla-client - "Build the CARLA client." ${LIBCARLA_CLIENT_HEADERS} ${LIBCARLA_CLIENT_SOURCES} ${LIBCARLA_CLIENT_HEADERS_THIRD_PARTY} @@ -302,3 +300,12 @@ if (BUILD_CARLA_CLIENT) ) endif () + +add_custom_target ( + carla-server-package +) + +add_dependencies ( + carla-server-package + carla-server +) diff --git a/PythonAPI/CMakeLists.txt b/PythonAPI/CMakeLists.txt index 4cec22528..7f95a2dfb 100644 --- a/PythonAPI/CMakeLists.txt +++ b/PythonAPI/CMakeLists.txt @@ -81,9 +81,8 @@ else () ) endif () -carla_add_custom_target ( +add_custom_target ( carla-python-api - "Build the CARLA Python API." COMMAND ${CMAKE_COMMAND} -E copy @@ -97,9 +96,8 @@ carla_add_custom_target ( USES_TERMINAL ) -carla_add_custom_target ( +add_custom_target ( carla-python-api-install - "Build & install the CARLA Python API" COMMAND ${Python3_EXECUTABLE} -m pip install diff --git a/Ros2Native/CMakeLists.txt b/Ros2Native/CMakeLists.txt index 1b4c19230..8b2e85342 100644 --- a/Ros2Native/CMakeLists.txt +++ b/Ros2Native/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 3.28.0) -project (carla-ros2-native-project) +project(carla-ros2-native-project) include (ExternalProject) @@ -29,7 +29,7 @@ ExternalProject_add ( DEPENDS foonathan_memory fastcdr ) -ExternalProject_Add ( +ExternalProject_Add( carla-ros2-native-lib DEPENDS fastdds SOURCE_DIR ${PROJECT_SOURCE_DIR}/LibCarlaRos2Native @@ -37,20 +37,16 @@ ExternalProject_Add ( ) set (CARLA_PLUGIN_BINARY_PATH ${CMAKE_SOURCE_DIR}/Unreal/CarlaUnreal/Plugins/Carla/Binaries/Linux) - -make_directory (${CARLA_PLUGIN_BINARY_PATH}) - -add_custom_command ( - TARGET carla-ros2-native-lib - POST_BUILD - COMMAND - ${CMAKE_COMMAND} -E copy - ${PROJECT_INSTALL_PATH}/lib/*.so* - ${CARLA_PLUGIN_BINARY_PATH} +make_directory(${CARLA_PLUGIN_BINARY_PATH}) +add_custom_command( + TARGET carla-ros2-native-lib + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy + ${PROJECT_INSTALL_PATH}/lib/*.so* + ${CARLA_PLUGIN_BINARY_PATH} ) -carla_add_custom_target ( +add_custom_target ( carla-ros2-native - "Build the ROS2-Native CARLA subproject." DEPENDS carla-ros2-native-lib -) +) \ No newline at end of file diff --git a/Ros2Native/LibCarlaRos2Native/CMakeLists.txt b/Ros2Native/LibCarlaRos2Native/CMakeLists.txt index df77e74e0..3f9ce83c9 100644 --- a/Ros2Native/LibCarlaRos2Native/CMakeLists.txt +++ b/Ros2Native/LibCarlaRos2Native/CMakeLists.txt @@ -22,10 +22,7 @@ file ( ${LIBCARLA_SOURCE_PATH}/carla/ros2/types/*.h ) -carla_add_library ( - carla-ros2-native - "Build the CARLA ROS2-Native subproject." - SHARED +add_library (carla-ros2-native SHARED ${LIBCARLA_ROS2_HEADERS} ${LIBCARLA_ROS2_SOURCES} ) @@ -46,4 +43,4 @@ target_compile_definitions (carla-ros2-native PUBLIC target_link_libraries(carla-ros2-native ${CMAKE_INSTALL_PREFIX}/lib/libfastrtps.so) -install (TARGETS carla-ros2-native DESTINATION lib) +install (TARGETS carla-ros2-native DESTINATION lib) \ No newline at end of file diff --git a/Unreal/CMakeLists.txt b/Unreal/CMakeLists.txt index da3511a41..5904536d4 100644 --- a/Unreal/CMakeLists.txt +++ b/Unreal/CMakeLists.txt @@ -8,8 +8,7 @@ project ( "Open-source simulator for autonomous driving research." ) -carla_option ( - ENABLE_DIRECTORY_CLEAN +option(ENABLE_DIRECTORY_CLEAN "Enable ADDITIONAL_CLEAN_FILES on directory level" ON ) @@ -296,9 +295,8 @@ file ( -carla_add_custom_target ( +add_custom_target ( carla-unreal - "Build the CarlaUnreal subproject." COMMAND ${CARLA_UE_BUILD_COMMAND_PREFIX} CarlaUnreal @@ -318,9 +316,8 @@ add_dependencies ( ${UE_DEPENDENCIES_ORDER_ONLY} ) -carla_add_custom_target ( +add_custom_target ( carla-unreal-editor - "Build the CarlaUnrealEditor subproject." COMMAND ${CARLA_UE_BUILD_COMMAND_PREFIX} CarlaUnrealEditor @@ -340,13 +337,9 @@ add_dependencies ( ${UE_DEPENDENCIES_ORDER_ONLY} ) -function (add_carla_ue_package_target PACKAGE_CONFIGURATION UE_BUILD_CONFIGURATION) - if (NOT "${PACKAGE_CONFIGURATION}" STREQUAL "") - set (TARGET_NAME_SUFFIX -${PACKAGE_CONFIGURATION}) - endif () - carla_add_custom_target ( +function(add_carla_ue_package_target TARGET_NAME_SUFFIX UE_BUILD_CONFIGURATION) + add_custom_target ( carla-unreal-package${TARGET_NAME_SUFFIX} - "Create a CARLA package in ${PACKAGE_CONFIGURATION} mode." COMMAND ${CARLA_UE_BUILD_COMMAND_PREFIX} CarlaUnreal @@ -378,8 +371,8 @@ function (add_carla_ue_package_target PACKAGE_CONFIGURATION UE_BUILD_CONFIGURATI VERBATIM ) - set (CARLA_TARGET_PACKAGE_PATH ${CARLA_PACKAGE_PATH}/${UE_SYSTEM_NAME}) - add_custom_command ( + set(CARLA_TARGET_PACKAGE_PATH ${CARLA_PACKAGE_PATH}/${UE_SYSTEM_NAME}) + add_custom_command( TARGET carla-unreal-package${TARGET_NAME_SUFFIX} POST_BUILD COMMAND ${CMAKE_COMMAND} -E echo "********** PACKAGE CREATING VERSION FILE UNREAL PACKAGE EXTRA FILES STARTED **********" @@ -418,9 +411,8 @@ function (add_carla_ue_package_target PACKAGE_CONFIGURATION UE_BUILD_CONFIGURATI ${UE_DEPENDENCIES_ORDER_ONLY} ) - carla_add_custom_target ( + add_custom_target ( package${TARGET_NAME_SUFFIX} - "Create a CARLA package in ${PACKAGE_CONFIGURATION} mode." ) add_dependencies ( @@ -432,11 +424,11 @@ endfunction() # Docs for UE5 build configurations: # https://docs.unrealengine.com/4.27/en-US/ProductionPipelines/DevelopmentSetup/BuildConfigurations/ add_carla_ue_package_target("" Shipping) -add_carla_ue_package_target(Shipping Shipping) -add_carla_ue_package_target(Debug Debug) -add_carla_ue_package_target(DebugGame DebugGame) -add_carla_ue_package_target(Development Development) -add_carla_ue_package_target(Test Test) +add_carla_ue_package_target(-Shipping Shipping) +add_carla_ue_package_target(-Debug Debug) +add_carla_ue_package_target(-DebugGame DebugGame) +add_carla_ue_package_target(-Development Development) +add_carla_ue_package_target(-Test Test) @@ -453,9 +445,8 @@ set ( VERBATIM ) -carla_add_custom_target ( +add_custom_target ( launch - "Build and open CARLA in the Unreal Editor." ${CARLA_LAUNCH_TARGET_OPTIONS} ) @@ -471,9 +462,8 @@ else () ) endif () -carla_add_custom_target ( - check-unreal-content - "Perform some basic checks to ensure that the CARLA Unreal Editor will not open without its assets." +add_custom_target ( + prelaunch-content-check COMMAND ${PRELAUNCH_CONTENT_CHECK_COMMAND} COMMENT @@ -485,22 +475,20 @@ carla_add_custom_target ( add_dependencies ( launch carla-unreal-editor - check-unreal-content + prelaunch-content-check ) -carla_add_custom_target ( +add_custom_target ( launch-only - "Open CARLA in the Unreal Editor. This will not rebuild outdated targets." ${CARLA_LAUNCH_TARGET_OPTIONS} ) add_dependencies ( launch-only - check-unreal-content + prelaunch-content-check ) -set_property ( - DIRECTORY APPEND PROPERTY ADDITIONAL_CLEAN_FILES +set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_CLEAN_FILES "${CARLA_UE_PATH}/Binaries" "${CARLA_UE_PATH}/Intermediate" "${CARLA_UE_PATH}/Saved" @@ -512,5 +500,5 @@ set_property ( "${CARLA_UE_CARLA_PATH}/Saved" "${CARLA_BUILD_PATH}/Package" "${CARLA_BUILD_PATH}/PythonAPI/dist" -) + ) diff --git a/osm-world-renderer/CMakeLists.txt b/osm-world-renderer/CMakeLists.txt index df5777faf..d62938bd4 100644 --- a/osm-world-renderer/CMakeLists.txt +++ b/osm-world-renderer/CMakeLists.txt @@ -11,9 +11,8 @@ set ( ${CARLA_WORKSPACE_PATH}/osm-world-renderer/OsmRenderer ) -carla_add_library ( +add_library ( lib-osm-map-renderer - "Build OSM-Map-Renderer." ${OSM_RENDERER_SOURCE_PATH}/src/OsmRenderer.cpp ${OSM_RENDERER_SOURCE_PATH}/src/MapDrawer.cpp ${OSM_RENDERER_SOURCE_PATH}/src/MapRasterizer.cpp @@ -33,9 +32,8 @@ target_include_directories ( ${OSM_RENDERER_SOURCE_PATH}/include ) -carla_add_executable ( +add_executable ( osm-world-renderer - "Build OSM-World-Renderer." ${OSM_RENDERER_SOURCE_PATH}/main.cpp )