2024-03-09 03:31:22 +08:00
|
|
|
#[[
|
|
|
|
|
|
|
|
Copyright (c) 2024 Computer Vision Center (CVC) at the Universitat Autonoma
|
|
|
|
de Barcelona (UAB).
|
|
|
|
|
|
|
|
This work is licensed under the terms of the MIT license.
|
|
|
|
For a copy, see <https://opensource.org/licenses/MIT>.
|
|
|
|
|
|
|
|
]]
|
|
|
|
|
2024-03-13 08:04:27 +08:00
|
|
|
cmake_minimum_required (
|
|
|
|
VERSION
|
2024-04-02 16:20:46 +08:00
|
|
|
3.27.2
|
2024-03-13 08:04:27 +08:00
|
|
|
)
|
2024-02-05 18:52:25 +08:00
|
|
|
|
2024-01-25 23:24:20 +08:00
|
|
|
cmake_policy (SET CMP0097 NEW)
|
2024-02-28 22:56:26 +08:00
|
|
|
cmake_policy (SET CMP0091 NEW)
|
2024-03-20 18:34:44 +08:00
|
|
|
cmake_policy (SET CMP0074 NEW)
|
|
|
|
cmake_policy (SET CMP0077 NEW)
|
2024-03-05 00:52:54 +08:00
|
|
|
if (${CMAKE_MINOR_VERSION} GREATER_EQUAL 24)
|
|
|
|
cmake_policy (SET CMP0135 NEW)
|
|
|
|
endif ()
|
2018-07-04 17:59:59 +08:00
|
|
|
|
2023-11-22 00:32:55 +08:00
|
|
|
set (CARLA_VERSION_MAJOR 0)
|
|
|
|
set (CARLA_VERSION_MINOR 9)
|
2024-02-05 18:52:25 +08:00
|
|
|
set (CARLA_VERSION_PATCH 15)
|
2023-11-23 07:50:55 +08:00
|
|
|
|
2024-02-05 18:52:25 +08:00
|
|
|
set (
|
|
|
|
CARLA_VERSION
|
|
|
|
${CARLA_VERSION_MAJOR}.${CARLA_VERSION_MINOR}.${CARLA_VERSION_PATCH}
|
|
|
|
)
|
2024-01-25 23:24:20 +08:00
|
|
|
|
2023-11-23 07:50:55 +08:00
|
|
|
project (
|
2024-02-07 04:47:29 +08:00
|
|
|
CARLA
|
2024-03-12 20:04:01 +08:00
|
|
|
VERSION
|
|
|
|
${CARLA_VERSION}
|
2024-02-20 23:34:31 +08:00
|
|
|
LANGUAGES
|
|
|
|
C
|
|
|
|
CXX
|
|
|
|
ASM # This is required by some dependencies, such as LibPNG.
|
2024-03-12 20:04:01 +08:00
|
|
|
DESCRIPTION
|
|
|
|
"Open-source simulator for autonomous driving research."
|
|
|
|
HOMEPAGE_URL
|
|
|
|
https://carla.org
|
2024-01-25 23:24:20 +08:00
|
|
|
)
|
|
|
|
|
2024-02-05 18:52:25 +08:00
|
|
|
set (CMAKE_CXX_STANDARD 20)
|
|
|
|
set (CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
|
2024-02-20 23:34:31 +08:00
|
|
|
set (CMAKE_C_STANDARD 11)
|
|
|
|
set (CMAKE_C_STANDARD_REQUIRED ON)
|
2024-02-05 18:52:25 +08:00
|
|
|
|
2024-02-20 23:34:31 +08:00
|
|
|
set (
|
|
|
|
CARLA_WORKSPACE_PATH
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}
|
2024-02-07 04:47:29 +08:00
|
|
|
)
|
|
|
|
|
2024-04-02 18:05:55 +08:00
|
|
|
set (
|
|
|
|
CARLA_PACKAGE_PATH
|
|
|
|
${CMAKE_BINARY_DIR}/Package
|
|
|
|
)
|
|
|
|
|
2024-02-20 23:34:31 +08:00
|
|
|
set (
|
|
|
|
CARLA_UNREAL_PLUGINS_PATH
|
2024-03-04 20:33:51 +08:00
|
|
|
${CARLA_WORKSPACE_PATH}/Unreal/CarlaUnreal/Plugins
|
2024-02-05 18:52:25 +08:00
|
|
|
)
|
2024-02-01 07:46:04 +08:00
|
|
|
|
2024-02-20 23:34:31 +08:00
|
|
|
include (CheckCCompilerFlag)
|
|
|
|
include (CheckCXXCompilerFlag)
|
2024-03-09 03:31:22 +08:00
|
|
|
include (CheckLinkerFlag)
|
2024-03-18 21:09:38 +08:00
|
|
|
include (${CARLA_WORKSPACE_PATH}/CMake/Util.cmake)
|
2024-02-20 23:34:31 +08:00
|
|
|
include (${CARLA_WORKSPACE_PATH}/CMake/CarlaOptions.cmake)
|
2024-03-12 20:04:01 +08:00
|
|
|
include (${CARLA_WORKSPACE_PATH}/CMake/Warnings.cmake)
|
|
|
|
include (${CARLA_WORKSPACE_PATH}/CMake/Errors.cmake)
|
2024-02-01 07:46:04 +08:00
|
|
|
|
2024-03-26 21:55:35 +08:00
|
|
|
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
2024-03-20 18:34:44 +08:00
|
|
|
carla_warning (
|
2024-03-26 21:55:35 +08:00
|
|
|
"CARLA is set to be built in Debug mode. This may cause issues when building CarlaUnrealEditor."
|
2024-03-20 18:34:44 +08:00
|
|
|
)
|
|
|
|
endif ()
|
2024-03-18 21:09:38 +08:00
|
|
|
|
2024-03-09 03:31:22 +08:00
|
|
|
if (LINUX)
|
2024-03-15 02:11:15 +08:00
|
|
|
check_linker_flag (CXX -lpthread HAS_PTHREAD)
|
2024-03-09 03:31:22 +08:00
|
|
|
if (HAS_PTHREAD)
|
|
|
|
add_link_options (-lpthread)
|
|
|
|
endif ()
|
|
|
|
endif ()
|
|
|
|
|
2024-01-25 23:24:20 +08:00
|
|
|
|
2024-03-09 03:31:22 +08:00
|
|
|
|
|
|
|
set (CMAKE_POSITION_INDEPENDENT_CODE ON)
|
2024-01-25 23:24:20 +08:00
|
|
|
|
2024-02-28 22:56:26 +08:00
|
|
|
if (WIN32)
|
|
|
|
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
|
|
set (CARLA_DEBUG_AFFIX d)
|
|
|
|
set (CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDebugDLL")
|
|
|
|
else ()
|
|
|
|
set (CARLA_DEBUG_AFFIX )
|
|
|
|
set (CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
|
|
|
|
endif ()
|
2024-02-01 07:46:04 +08:00
|
|
|
endif ()
|
2024-01-25 23:24:20 +08:00
|
|
|
|
2024-03-09 03:31:22 +08:00
|
|
|
|
|
|
|
|
2024-03-15 02:11:15 +08:00
|
|
|
set (CARLA_COMMON_DEFINITIONS)
|
|
|
|
|
|
|
|
foreach (FORMAT ${LIBCARLA_IMAGE_SUPPORTED_FORMATS})
|
2024-03-20 18:34:44 +08:00
|
|
|
carla_message ("Enabling CARLA image support for \"${FORMAT}\".")
|
2024-03-15 02:11:15 +08:00
|
|
|
string (TOUPPER "${FORMAT}" FORMAT_UPPERCASE)
|
|
|
|
list (APPEND CARLA_COMMON_DEFINITIONS LIBCARLA_IMAGE_SUPPORT_${FORMAT_UPPERCASE}=1)
|
|
|
|
endforeach ()
|
2024-01-25 23:24:20 +08:00
|
|
|
|
2023-11-16 02:36:43 +08:00
|
|
|
if (WIN32)
|
2024-03-13 06:19:57 +08:00
|
|
|
add_compile_definitions (_CRT_SECURE_NO_WARNINGS)
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
if (WIN32)
|
|
|
|
# https://learn.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt?view=msvc-170
|
2024-03-15 02:11:15 +08:00
|
|
|
list (APPEND CARLA_COMMON_DEFINITIONS _WIN32_WINNT=0x0601) # <- Windows 10
|
2024-02-20 23:34:31 +08:00
|
|
|
list (APPEND CARLA_COMMON_DEFINITIONS HAVE_SNPRINTF)
|
2024-02-28 22:56:26 +08:00
|
|
|
list (APPEND CARLA_COMMON_DEFINITIONS _USE_MATH_DEFINES)
|
2023-11-22 00:32:55 +08:00
|
|
|
endif ()
|
|
|
|
|
2024-01-25 23:24:20 +08:00
|
|
|
set (CARLA_EXCEPTION_DEFINITIONS)
|
2024-03-09 03:31:22 +08:00
|
|
|
|
2023-11-22 00:32:55 +08:00
|
|
|
if (ENABLE_EXCEPTIONS)
|
2024-02-28 22:56:26 +08:00
|
|
|
# Nothing
|
2023-11-22 00:32:55 +08:00
|
|
|
else ()
|
2024-02-20 23:34:31 +08:00
|
|
|
list (APPEND CARLA_EXCEPTION_DEFINITIONS ASIO_NO_EXCEPTIONS)
|
|
|
|
list (APPEND CARLA_EXCEPTION_DEFINITIONS BOOST_NO_EXCEPTIONS)
|
|
|
|
list (APPEND CARLA_EXCEPTION_DEFINITIONS LIBCARLA_NO_EXCEPTIONS)
|
|
|
|
list (APPEND CARLA_EXCEPTION_DEFINITIONS PUGIXML_NO_EXCEPTIONS)
|
2023-11-22 00:32:55 +08:00
|
|
|
endif ()
|
|
|
|
|
2024-02-20 23:34:31 +08:00
|
|
|
include (${CARLA_WORKSPACE_PATH}/CMake/CarlaDependencies.cmake)
|
|
|
|
|
2024-02-05 18:52:25 +08:00
|
|
|
if (BUILD_CARLA_CLIENT OR BUILD_CARLA_SERVER)
|
|
|
|
add_subdirectory (LibCarla)
|
2023-11-23 00:29:27 +08:00
|
|
|
endif ()
|
2023-11-16 04:54:26 +08:00
|
|
|
|
2023-11-17 03:55:25 +08:00
|
|
|
if (BUILD_OSM_WORLD_RENDERER)
|
2024-02-05 18:52:25 +08:00
|
|
|
add_subdirectory (osm-world-renderer)
|
2024-01-25 23:24:20 +08:00
|
|
|
endif ()
|
|
|
|
|
2024-03-14 23:27:10 +08:00
|
|
|
if (ENABLE_ROS2)
|
|
|
|
set (BOOST_INCLUDE_PATH ${CMAKE_BINARY_DIR}/_deps/boost-src/libs)
|
|
|
|
add_subdirectory (Ros2Native)
|
|
|
|
endif()
|
|
|
|
|
2024-01-25 23:24:20 +08:00
|
|
|
if (BUILD_PYTHON_API)
|
2024-02-05 18:52:25 +08:00
|
|
|
add_subdirectory (PythonAPI)
|
2024-02-01 07:46:04 +08:00
|
|
|
endif ()
|
2024-02-20 23:34:31 +08:00
|
|
|
|
2024-03-11 04:42:58 +08:00
|
|
|
if (BUILD_CARLA_UNREAL)
|
2024-03-04 20:10:00 +08:00
|
|
|
add_subdirectory (Unreal)
|
|
|
|
endif ()
|
2024-03-19 03:20:02 +08:00
|
|
|
|
|
|
|
if (BUILD_EXAMPLES)
|
|
|
|
add_subdirectory (Examples)
|
|
|
|
endif ()
|