Minor changes, introduce options for -Wall and -Werror.

This commit is contained in:
Marcel Pi 2024-03-12 13:04:01 +01:00
parent 60e1b9d7d4
commit 8c14d9ff4c
6 changed files with 101 additions and 48 deletions

20
CMake/Errors.cmake Normal file
View File

@ -0,0 +1,20 @@
if (ENABLE_WARNINGS_TO_ERRORS)
if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
check_cxx_compiler_flag(-Werror HAS_WALL)
if (HAS_WALL)
add_compile_options (-Werror)
endif ()
else ()
check_cxx_compiler_flag(/WX HAS_WALL)
if (HAS_WALL)
add_compile_options (/WX)
endif ()
endif ()
else ()
check_cxx_compiler_flag(-Werror HAS_WALL)
if (HAS_WALL)
add_compile_options (-Werror)
endif ()
endif ()
endif ()

View File

@ -79,3 +79,15 @@ option (
"Whether to clone dependencies instead of directly downloading a compressed archive."
OFF
)
option (
ENABLE_ALL_WARNINGS
"Whether to emit extra build warnings."
ON
)
option (
ENABLE_WARNINGS_TO_ERRORS
"Whether to convert build warnings to errors."
OFF
)

20
CMake/Warnings.cmake Normal file
View File

@ -0,0 +1,20 @@
if (ENABLE_ALL_WARNINGS)
if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
check_cxx_compiler_flag(-Wall HAS_WALL)
if (HAS_WALL)
add_compile_options (-Wall)
endif ()
else ()
check_cxx_compiler_flag(/Wall HAS_WALL)
if (HAS_WALL)
add_compile_options (/Wall)
endif ()
endif ()
else ()
check_cxx_compiler_flag(-Wall HAS_WALL)
if (HAS_WALL)
add_compile_options (-Wall)
endif ()
endif ()
endif ()

View File

@ -28,13 +28,16 @@ set (
project (
CARLA
VERSION ${CARLA_VERSION}
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
DESCRIPTION
"Open-source simulator for autonomous driving research."
HOMEPAGE_URL
https://carla.org
)
set (CMAKE_CXX_STANDARD 20)
@ -56,8 +59,9 @@ set (
include (CheckCCompilerFlag)
include (CheckCXXCompilerFlag)
include (CheckLinkerFlag)
include (${CARLA_WORKSPACE_PATH}/CMake/CarlaOptions.cmake)
include (${CARLA_WORKSPACE_PATH}/CMake/Warnings.cmake)
include (${CARLA_WORKSPACE_PATH}/CMake/Errors.cmake)
if (LINUX)
check_linker_flag (
@ -120,12 +124,8 @@ else ()
list (APPEND CARLA_EXCEPTION_DEFINITIONS PUGIXML_NO_EXCEPTIONS)
endif ()
include (${CARLA_WORKSPACE_PATH}/CMake/CarlaDependencies.cmake)
if (BUILD_CARLA_CLIENT OR BUILD_CARLA_SERVER)
add_subdirectory (LibCarla)
endif ()

View File

@ -1,7 +1,11 @@
project (
carla-python-api
LANGUAGES CXX
VERSION ${CARLA_VERSION}
VERSION
${CARLA_VERSION}
LANGUAGES
CXX
DESCRIPTION
"Python API for communicating with the CARLA server."
)
set (PYTHON_API_PATH ${CARLA_WORKSPACE_PATH}/PythonAPI)

View File

@ -1,5 +1,11 @@
project (
carla-ue
carla-unreal
VERSION
${CARLA_VERSION}
LANGUAGES
CXX
DESCRIPTION
"Open-source simulator for autonomous driving research."
)
set (
@ -39,8 +45,6 @@ else ()
)
endif ()
set (CMAKE_NINJA_FORCE_RESPONSE_FILE ON)
add_custom_command (
@ -57,13 +61,13 @@ add_custom_command (
)
add_custom_target (
carla-ue-generate-project-files
carla-unreal-generate-project-files
DEPENDS
${CARLA_UE_PATH}/CMakeLists.txt
)
add_dependencies (
carla-ue-generate-project-files
carla-unreal-generate-project-files
carla-server
libsqlite3
Boost::asio
@ -85,7 +89,10 @@ if (CMAKE_TOOLCHAIN_FILE)
NORMALIZE
OUTPUT_VARIABLE TOOLCHAIN_FILE
)
set (TOOLCHAIN_FILE_OPTION --toolchain=${TOOLCHAIN_FILE})
set (
TOOLCHAIN_FILE_OPTION
--toolchain=${TOOLCHAIN_FILE}
)
else ()
set (TOOLCHAIN_FILE_OPTION)
endif ()
@ -94,7 +101,7 @@ endif ()
add_custom_command (
OUTPUT
${CMAKE_CURRENT_BINARY_DIR}/carla-ue-configure.stamp
${CMAKE_CURRENT_BINARY_DIR}/carla-unreal-configure.stamp
COMMENT
"Configuring Carla Unreal..."
COMMAND
@ -104,27 +111,27 @@ add_custom_command (
${TOOLCHAIN_FILE_OPTION}
COMMAND
${CMAKE_COMMAND}
-E touch carla-ue-configure.stamp
-E touch carla-unreal-configure.stamp
USES_TERMINAL
VERBATIM
)
add_custom_target (
carla-ue-configure
carla-unreal-configure
DEPENDS
carla-ue-configure.stamp
carla-unreal-configure.stamp
)
add_dependencies (
carla-ue-configure
carla-ue-generate-project-files
carla-unreal-configure
carla-unreal-generate-project-files
)
add_custom_command (
OUTPUT
${CMAKE_CURRENT_BINARY_DIR}/carla-ue.stamp
${CMAKE_CURRENT_BINARY_DIR}/carla-unreal.stamp
COMMENT
"Building Carla Unreal..."
COMMAND
@ -133,58 +140,48 @@ add_custom_command (
--target CarlaUnrealEditor
COMMAND
${CMAKE_COMMAND}
-E touch carla-ue.stamp
-E touch carla-unreal.stamp
USES_TERMINAL
VERBATIM
)
add_custom_target (
carla-ue
carla-unreal
DEPENDS
carla-ue.stamp
carla-unreal.stamp
)
add_dependencies (
carla-ue
carla-ue-configure
carla-unreal
carla-unreal-configure
)
if (WIN32)
set (EXE_EXT .exe)
else ()
set (EXE_EXT)
endif ()
if (WIN32)
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 ()
message (FATAL_ERROR "Unknown target system.")
endif ()
add_custom_target (
launch-only
COMMENT
"Launching Carla Unreal..."
COMMAND
${CARLA_UNREAL_ENGINE_PATH}/Engine/Binaries/${UE_SYSTEM_NAME}/UnrealEditor${EXE_EXT}
${CARLA_UE_PROJECT_PATH}
-${CARLA_UNREAL_RHI}
${LAUNCH_ARGS}
USES_TERMINAL
VERBATIM
set (
UNREAL_EDITOR_PATH
${CARLA_UNREAL_ENGINE_PATH}/Engine/Binaries/${UE_SYSTEM_NAME}/UnrealEditor${EXE_EXT}
)
add_custom_target (
launch
COMMENT
"Launching Carla Unreal..."
COMMAND
${CARLA_UNREAL_ENGINE_PATH}/Engine/Binaries/${UE_SYSTEM_NAME}/UnrealEditor${EXE_EXT}
${UNREAL_EDITOR_PATH}
${CARLA_UE_PROJECT_PATH}
-${CARLA_UNREAL_RHI}
${LAUNCH_ARGS}
@ -194,7 +191,7 @@ add_custom_target (
add_dependencies (
launch
carla-ue
carla-unreal
)