Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@

root = true

[*.{c++,cc,cpp,cppm,cxx,h,h++,hh,hpp,hxx,inl,ipp,ixx,tlh,tli}]

# Visual C++ Code Style settings

cpp_generate_documentation_comments = doxygen_slash_star

# Visual C++ Formatting settings

indent_style = space
indent_size = 2
tab_width = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

cpp_indent_braces = false
cpp_indent_multi_line_relative_to = innermost_parenthesis
cpp_indent_within_parentheses = indent
cpp_indent_preserve_within_parentheses = false
cpp_indent_case_contents = true
cpp_indent_case_labels = false
cpp_indent_case_contents_when_block = false
cpp_indent_lambda_braces_when_parameter = true
cpp_indent_goto_labels = one_left
cpp_indent_preprocessor = leftmost_column
cpp_indent_access_specifiers = false
cpp_indent_namespace_contents = true
cpp_indent_preserve_comments = false
cpp_new_line_before_open_brace_namespace = ignore
cpp_new_line_before_open_brace_type = ignore
cpp_new_line_before_open_brace_function = ignore
cpp_new_line_before_open_brace_block = ignore
cpp_new_line_before_open_brace_lambda = ignore
cpp_new_line_scope_braces_on_separate_lines = false
cpp_new_line_close_brace_same_line_empty_type = false
cpp_new_line_close_brace_same_line_empty_function = false
cpp_new_line_before_catch = true
cpp_new_line_before_else = true
cpp_new_line_before_while_in_do_while = false
cpp_space_before_function_open_parenthesis = remove
cpp_space_within_parameter_list_parentheses = false
cpp_space_between_empty_parameter_list_parentheses = false
cpp_space_after_keywords_in_control_flow_statements = true
cpp_space_within_control_flow_statement_parentheses = false
cpp_space_before_lambda_open_parenthesis = false
cpp_space_within_cast_parentheses = false
cpp_space_after_cast_close_parenthesis = false
cpp_space_within_expression_parentheses = false
cpp_space_before_block_open_brace = true
cpp_space_between_empty_braces = false
cpp_space_before_initializer_list_open_brace = false
cpp_space_within_initializer_list_braces = true
cpp_space_preserve_in_initializer_list = true
cpp_space_before_open_square_bracket = false
cpp_space_within_square_brackets = false
cpp_space_before_empty_square_brackets = false
cpp_space_between_empty_square_brackets = false
cpp_space_group_square_brackets = true
cpp_space_within_lambda_brackets = false
cpp_space_between_empty_lambda_brackets = false
cpp_space_before_comma = false
cpp_space_after_comma = true
cpp_space_remove_around_member_operators = true
cpp_space_before_inheritance_colon = true
cpp_space_before_constructor_colon = true
cpp_space_remove_before_semicolon = true
cpp_space_after_semicolon = true
cpp_space_remove_around_unary_operator = true
cpp_space_around_binary_operator = insert
cpp_space_around_assignment_operator = insert
cpp_space_pointer_reference_alignment = left
cpp_space_around_ternary_operator = insert
cpp_use_unreal_engine_macro_formatting = true
cpp_wrap_preserve_blocks = one_liners
cpp_include_cleanup_add_missing_error_tag_type = none
cpp_include_cleanup_remove_unused_error_tag_type = none
cpp_include_cleanup_optimize_unused_error_tag_type = none
cpp_include_cleanup_sort_after_edits = false
cpp_include_cleanup_format_after_edits = false
cpp_sort_includes_error_tag_type = none
cpp_sort_includes_priority_case_sensitive = false
cpp_sort_includes_priority_style = quoted
cpp_includes_style = default
cpp_includes_use_forward_slash = true
157 changes: 53 additions & 104 deletions CMake/Common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,39 @@ endif ()
# Common Definitions
# ================================

macro (carla_add_compile_option FLAG)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAG}")
endmacro ()

macro (carla_add_link_option FLAG)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAG}")
endmacro ()

macro (carla_try_add_compile_options)
foreach (NAME ${ARGN})
string (REPLACE "/" "__" NAME2 ${NAME})
string (MAKE_C_IDENTIFIER "CO_${NAME2}" RESULT)
check_c_compiler_flag(${NAME} ${RESULT})
if (${VARIABLE_IDENTIFIER})
carla_add_compile_option (${NAME})
endif ()
endforeach ()
endmacro ()

macro (carla_try_add_link_options)
foreach (NAME ${ARGN})
string (REPLACE "/" "__" NAME2 ${NAME})
string (MAKE_C_IDENTIFIER "LO_${NAME2}" RESULT)
check_linker_flag(C ${NAME} ${RESULT})
if (${RESULT})
carla_add_link_option (${NAME})
endif ()
endforeach ()
endmacro ()

if (WIN32)
add_compile_definitions (_CRT_SECURE_NO_WARNINGS)
check_cxx_compiler_flag (/utf-8 HAS_MSVC_UTF8)
if (HAS_MSVC_UTF8)
# @TODO This causes warnings with MASM. A better approach should be looked into.
add_compile_options ($<$<COMPILE_LANGUAGE:CXX>:/utf-8>)
endif ()
carla_try_add_compile_options (/utf-8)
endif ()

set (CARLA_COMMON_DEFINITIONS)
Expand Down Expand Up @@ -107,13 +133,9 @@ else ()
endif ()

carla_message ("Checking for ${EXCEPTIONS_FLAG} support")
check_cxx_compiler_flag (${EXCEPTIONS_FLAG} HAS_EXCEPTIONS_FLAG)
if (HAS_EXCEPTIONS_FLAG)
add_compile_options ($<$<COMPILE_LANGUAGE:CXX>:${EXCEPTIONS_FLAG}>)
endif ()
carla_try_add_compile_options (${EXCEPTIONS_FLAG})

set (CARLA_EXCEPTION_DEFINITIONS)

if (ENABLE_EXCEPTIONS)
# Nothing
else ()
Expand All @@ -128,29 +150,15 @@ endif ()
# RTTI Definitions
# ================================

if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC" AND
NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
if (ENABLE_RTTI)
set (RTTI_FLAG /GR)
else ()
set (RTTI_FLAG /GR-)
endif ()
if (ENABLE_RTTI)
carla_try_add_compile_options (/GR)
carla_try_add_compile_options (-frtti)
else ()
if (ENABLE_RTTI)
set (RTTI_FLAG -frtti)
else ()
set (RTTI_FLAG -fno-rtti)
endif ()
endif ()

carla_message ("Checking for ${RTTI_FLAG} support")
check_cxx_compiler_flag (${RTTI_FLAG} HAS_RTTI_FLAG)
if (HAS_RTTI_FLAG)
add_compile_options ($<$<COMPILE_LANGUAGE:CXX>:${RTTI_FLAG}>)
carla_try_add_compile_options (/GR-)
carla_try_add_compile_options (-fno-rtti)
endif ()

set (CARLA_RTTI_DEFINITIONS)

if (ENABLE_RTTI)
# Nothing
else ()
Expand All @@ -163,76 +171,30 @@ endif ()
# ================================

if (ENABLE_ALL_WARNINGS)
check_cxx_compiler_flag(-Wall HAS_WALL_GNU)
if (HAS_WALL_GNU)
set (CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
endif ()
check_cxx_compiler_flag(-Wextra HAS_WEXTRA_GNU)
if (HAS_WEXTRA_GNU)
set (CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -Wextra")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra")
endif ()
check_cxx_compiler_flag(/Wall HAS_WALL_MSVC)
if (HAS_WALL_MSVC)
set (CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} /Wall")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Wall")
if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
carla_try_add_compile_options (/W4)
else ()
carla_try_add_compile_options (-Wall)
carla_try_add_compile_options (-Wextra)
endif ()
endif ()

if (CMAKE_C_COMPILER_FRONTEND_VARIANT STREQUAL "GNU")
set (SUPPRESS_WARNING_DIRECTIVE_PREFIX -Wno-)
elseif (CMAKE_C_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
set (SUPPRESS_WARNING_DIRECTIVE_PREFIX /wd)
endif ()

macro (carla_try_suppress_cxx_warning NAME FLAG)
check_cxx_compiler_flag (
${SUPPRESS_WARNING_DIRECTIVE_PREFIX}${FLAG}
HAS_${NAME}
)
if (HAS_${NAME})
add_compile_options (
$<$<COMPILE_LANGUAGE:CXX>:${SUPPRESS_WARNING_DIRECTIVE_PREFIX}${FLAG}>)
endif ()
endmacro ()

macro (carla_try_suppress_c_warning NAME FLAG)
check_c_compiler_flag (
${SUPPRESS_WARNING_DIRECTIVE_PREFIX}${FLAG}
HAS_${NAME}
)
if (HAS_${NAME})
add_compile_options (
$<$<COMPILE_LANGUAGE:C>:${SUPPRESS_WARNING_DIRECTIVE_PREFIX}${FLAG}>)
function (carla_try_suppress_warning WARNING_ID)
if (CMAKE_C_COMPILER_FRONTEND_VARIANT STREQUAL "GNU")
carla_try_add_compile_options (-Wno-${WARNING_ID})
elseif (CMAKE_C_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
carla_try_add_compile_options (/wd${WARNING_ID})
endif ()
endmacro ()
endfunction ()

set (
CARLA_C_SUPRESSED_WARNING_LIST
CARLA_SUPRESSED_WARNING_LIST
macro-redefined 4005
incompatible-pointer-types
)

set (
CARLA_CXX_SUPRESSED_WARNING_LIST
macro-redefined 4005
)

foreach (WARNING ${CARLA_C_SUPRESSED_WARNING_LIST})
string (MAKE_C_IDENTIFIER "${WARNING}" WARNING_NAME)
carla_try_suppress_c_warning (
${WARNING_NAME}
${WARNING}
)
endforeach ()

foreach (WARNING ${CARLA_CXX_SUPRESSED_WARNING_LIST})
string (MAKE_C_IDENTIFIER "${WARNING}" WARNING_NAME)
carla_try_suppress_cxx_warning (
${WARNING_NAME}
${WARNING}
)
foreach (WARNING ${CARLA_SUPRESSED_WARNING_LIST})
carla_try_suppress_warning (${WARNING})
endforeach ()

# ================================
Expand All @@ -241,21 +203,8 @@ endforeach ()

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 ()
carla_try_add_compile_options (/WX)
else ()
check_cxx_compiler_flag(-Werror HAS_WALL)
if (HAS_WALL)
add_compile_options (-Werror)
endif ()
carla_try_add_compile_options (-Werror)
endif ()
endif ()
2 changes: 1 addition & 1 deletion CMake/Dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ carla_dependency_option (BOOST_GIL_BUILD_HEADER_TESTS OFF)
carla_dependency_add(
boost
${CARLA_BOOST_TAG}
https://github.com/boostorg/boost/releases/download/${CARLA_BOOST_TAG}/${CARLA_BOOST_TAG}.zip
https://github.com/boostorg/boost/releases/download/${CARLA_BOOST_TAG}/${CARLA_BOOST_TAG}-cmake.zip
https://github.com/boostorg/boost.git
)

Expand Down
4 changes: 2 additions & 2 deletions CMake/Options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ carla_option (
carla_string_option (
CARLA_BOOST_VERSION
"Target boost version."
1.84.0
1.89.0
)

carla_string_option (
Expand Down Expand Up @@ -309,7 +309,7 @@ carla_string_option (

# We can not upgrade any further due to ZLIB.
# See https://github.com/madler/zlib/issues/1019
# Once this is resolved we can target 1.6.50
# Once this is resolved we can target >1.6.40
carla_string_option (
CARLA_LIBPNG_VERSION
"Target libpng version."
Expand Down
3 changes: 2 additions & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"installDir": "${sourceDir}/Install/${presetName}",
"cacheVariables":
{
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/CMake/Toolchain.cmake"
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/CMake/Toolchain.cmake",
"CMAKE_POLICY_VERSION_MINIMUM" : "3.5"
},
"hidden": true
},
Expand Down
9 changes: 3 additions & 6 deletions LibCarla/source/carla/AtomicList.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@
#include <mutex>
#include <vector>

namespace carla {
namespace client {
namespace detail {
namespace carla::client::detail
{

/// Holds an atomic pointer to a list.
///
Expand Down Expand Up @@ -70,6 +69,4 @@ namespace detail {
AtomicSharedPtr<const ListT> _list;
};

} // namespace detail
} // namespace client
} // namespace carla
} // namespace carla::client::detail
Loading