carla-simulator / carla

Open-source simulator for autonomous driving research.
http://carla.org
MIT License
10.93k stars 3.52k forks source link

CARLA C++ client example/easy_import_cmake_include #7652

Open xavisolesoft opened 2 months ago

xavisolesoft commented 2 months ago

Problem

Currently, we do not have any example about how to link CARLA C++ client with a C++ application. I have tried to do it by my self quickly but was not trivial as after adding all the next header files I was still having build issues:

add_compile_definitions(ASIO_NO_EXCEPTIONS,
                        BOOST_NO_EXCEPTIONS,
                        LIBCARLA_NO_EXCEPTIONS,
                        PUGIXML_NO_EXCEPTIONS,
                        BOOST_DISABLE_ABI_HEADERS,
                        BOOST_NO_RTTI,
                        BOOST_TYPE_INDEX_FORCE_NO_RTTI_COMPATIBILITY)

target_link_libraries(CarlaStudio PRIVATE C:/programing/carlaUE5/Build/LibCarla/carla-client.lib)
include_directories(C:/programing/carlaUE5/LibCarla/source
                    C:/programing/carlaUE5/Build/_deps/boost-src/libs/asio/include
                    C:/programing/carlaUE5/Build/_deps/boost-src/libs/config/include
                    C:/programing/carlaUE5/Build/_deps/boost-src/libs/throw_exception/include
                    C:/programing/carlaUE5/Build/_deps/boost-src/libs/assert/include
                    C:/programing/carlaUE5/Build/_deps/boost-src/libs/align/include
                    C:/programing/carlaUE5/Build/_deps/boost-src/libs/geometry/include
                    C:/programing/carlaUE5/Build/_deps/boost-src/libs/range/include
                    C:/programing/carlaUE5/Build/_deps/boost-src/libs/preprocessor/include
                    C:/programing/carlaUE5/Build/_deps/boost-src/libs/mpl/include
                    C:/programing/carlaUE5/Build/_deps/boost-src/libs/type_traits/include
                    C:/programing/carlaUE5/Build/_deps/boost-src/libs/iterator/include
                    C:/programing/carlaUE5/Build/_deps/boost-src/libs/static_assert/include
                    C:/programing/carlaUE5/Build/_deps/boost-src/libs/numeric/conversion/include
                    C:/programing/carlaUE5/Build/_deps/boost-src/libs/core/include
                    C:/programing/carlaUE5/Build/_deps/boost-src/libs/rational/include
                    C:/programing/carlaUE5/Build/_deps/boost-src/libs/utility/include
                    C:/programing/carlaUE5/Build/_deps/boost-src/libs/integer/include
                    C:/programing/carlaUE5/Build/_deps/boost-src/libs/multiprecision/include
                    C:/programing/carlaUE5/Build/_deps/boost-src/libs/math/include

                    C:/programing/carlaUE5/Build/_deps/rpclib-src/include)

Proposed solution

My proposal is to create some cmake file that can be included to any C++ project if possible; and anyway create a sample project about how to link with CARLA C++ client.

MarcelPiNacy-CVC commented 2 months ago

I agree, we also should explicitly handle the case of installing with CMake.

xavisolesoft commented 2 months ago

Add the end we need to include some of the headers included here to CARLA UE5 plugin: https://github.com/carla-simulator/carla/blob/ue5-dev/Unreal/CarlaUnreal/Plugins/Carla/Source/Carla/Carla.Build.cs#L128

xavisolesoft commented 2 months ago

I agree, we also should explicitly handle the case of installing with CMake.

You mean installing the CARLA C++ client with all the headers to be able to distribute it out of the box of CARLA? It could make sense for CARLA Release, to prevent the customers to download and build all CARLA to implement a C++ client application.