carla/CMakeLists.txt

161 lines
3.7 KiB
CMake
Raw Normal View History

#[[
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
3.27.2
2024-03-13 08:04:27 +08:00
)
2024-02-05 18:52:25 +08:00
cmake_policy (SET CMP0097 NEW)
2024-02-28 22:56:26 +08:00
cmake_policy (SET CMP0091 NEW)
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}
)
2023-11-23 07:50:55 +08:00
project (
CARLA
VERSION
${CARLA_VERSION}
LANGUAGES
C
CXX
ASM # This is required by some dependencies, such as LibPNG.
DESCRIPTION
"Open-source simulator for autonomous driving research."
HOMEPAGE_URL
https://carla.org
)
2024-02-05 18:52:25 +08:00
set (CMAKE_CXX_STANDARD 20)
set (CMAKE_CXX_STANDARD_REQUIRED ON)
set (CMAKE_C_STANDARD 11)
set (CMAKE_C_STANDARD_REQUIRED ON)
2024-02-05 18:52:25 +08:00
set (
CARLA_WORKSPACE_PATH
${CMAKE_CURRENT_SOURCE_DIR}
)
set (
CARLA_PACKAGE_PATH
${CMAKE_BINARY_DIR}/Package
)
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
include (CheckCCompilerFlag)
include (CheckCXXCompilerFlag)
include (CheckLinkerFlag)
2024-03-18 21:09:38 +08:00
include (${CARLA_WORKSPACE_PATH}/CMake/Util.cmake)
include (${CARLA_WORKSPACE_PATH}/CMake/CarlaOptions.cmake)
include (${CARLA_WORKSPACE_PATH}/CMake/Warnings.cmake)
include (${CARLA_WORKSPACE_PATH}/CMake/Errors.cmake)
2024-02-01 07:46:04 +08:00
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
carla_warning (
"CARLA is set to be built in Debug mode. This may cause issues when building CarlaUnrealEditor."
)
endif ()
2024-03-18 21:09:38 +08:00
if (LINUX)
check_linker_flag (CXX -lpthread HAS_PTHREAD)
if (HAS_PTHREAD)
add_link_options (-lpthread)
endif ()
endif ()
set (CMAKE_POSITION_INDEPENDENT_CODE ON)
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 ()
set (CARLA_COMMON_DEFINITIONS)
foreach (FORMAT ${LIBCARLA_IMAGE_SUPPORTED_FORMATS})
carla_message ("Enabling CARLA image support for \"${FORMAT}\".")
string (TOUPPER "${FORMAT}" FORMAT_UPPERCASE)
list (APPEND CARLA_COMMON_DEFINITIONS LIBCARLA_IMAGE_SUPPORT_${FORMAT_UPPERCASE}=1)
endforeach ()
if (WIN32)
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
list (APPEND CARLA_COMMON_DEFINITIONS _WIN32_WINNT=0x0601) # <- Windows 10
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 ()
set (CARLA_EXCEPTION_DEFINITIONS)
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 ()
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 ()
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 ()
if (BUILD_OSM_WORLD_RENDERER)
2024-02-05 18:52:25 +08:00
add_subdirectory (osm-world-renderer)
endif ()
if (ENABLE_ROS2)
set (BOOST_INCLUDE_PATH ${CMAKE_BINARY_DIR}/_deps/boost-src/libs)
add_subdirectory (Ros2Native)
endif()
if (BUILD_PYTHON_API)
2024-02-05 18:52:25 +08:00
add_subdirectory (PythonAPI)
2024-02-01 07:46:04 +08:00
endif ()
if (BUILD_CARLA_UNREAL)
add_subdirectory (Unreal)
endif ()
2024-03-19 03:20:02 +08:00
if (BUILD_EXAMPLES)
add_subdirectory (Examples)
endif ()