From bb0eae7178f77fca7700a1d4cf1997062474b828 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Ferr=C3=A3o?= <2031761+viniciusferrao@users.noreply.github.com> Date: Mon, 13 Jan 2025 13:12:08 -0300 Subject: [PATCH] Last try to fix clang-format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Vinícius Ferrão <2031761+viniciusferrao@users.noreply.github.com> --- CMakeLists.txt | 118 +++++++++++++++++++-------------------- CMakePresets.json | 4 +- fuzz_test/CMakeLists.txt | 16 +++--- src/CMakeLists.txt | 48 ++++++++-------- src/cluster.cpp | 12 ++-- src/os.cpp | 2 +- test/CMakeLists.txt | 102 ++++++++++++++++----------------- 7 files changed, 151 insertions(+), 151 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 00ed58a4..2eb9d6af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,8 +8,8 @@ cmake_minimum_required(VERSION 3.26.5) # Only set the cxx_standard if it is not set by someone else if (NOT DEFINED CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 23) -endif() + set(CMAKE_CXX_STANDARD 23) +endif () # strongly encouraged to enable this globally to avoid conflicts between # -Wpedantic being enabled and -std=c++20 and -std=gnu++20 for example @@ -18,34 +18,34 @@ set(CMAKE_CXX_EXTENSIONS OFF) # Enable Conan 2.0 support option(cloysterhpc_ENABLE_CONAN "Use Conan 2 to manage dependencies" ON) -if(cloysterhpc_ENABLE_CONAN) - set(CMAKE_PROJECT_TOP_LEVEL_INCLUDES cmake/conan_provider.cmake) -endif() +if (cloysterhpc_ENABLE_CONAN) + set(CMAKE_PROJECT_TOP_LEVEL_INCLUDES cmake/conan_provider.cmake) +endif () # Set a default build type if none was specified # This is required for Conan 2.0 to work properly -if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) - message(STATUS "Setting build type to 'Debug' as none was specified.") - set(CMAKE_BUILD_TYPE - Debug - CACHE STRING "Choose the type of build." FORCE) - # Set the possible values of build type for cmake-gui, ccmake - set_property( - CACHE CMAKE_BUILD_TYPE - PROPERTY STRINGS - "Debug" - "Release" - "MinSizeRel" - "RelWithDebInfo") -endif() +if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) + message(STATUS "Setting build type to 'Debug' as none was specified.") + set(CMAKE_BUILD_TYPE + Debug + CACHE STRING "Choose the type of build." FORCE) + # Set the possible values of build type for cmake-gui, ccmake + set_property( + CACHE CMAKE_BUILD_TYPE + PROPERTY STRINGS + "Debug" + "Release" + "MinSizeRel" + "RelWithDebInfo") +endif () # Set the project name and language project( - CloysterHPC - VERSION 0.1.1 - DESCRIPTION "Cloyster HPC is a turnkey HPC cluster solution with an user-friendly installer" - HOMEPAGE_URL "https://github.com/viniciusferrao/cloysterhpc" - LANGUAGES CXX C) + CloysterHPC + VERSION 0.1.1 + DESCRIPTION "Cloyster HPC is a turnkey HPC cluster solution with an user-friendly installer" + HOMEPAGE_URL "https://github.com/viniciusferrao/cloysterhpc" + LANGUAGES CXX C) include(cmake/PreventInSourceBuilds.cmake) include(ProjectOptions.cmake) @@ -71,16 +71,16 @@ execute_process( ) # Check if GIT_SHA is empty and set to "Unknown" if it is -if("${GIT_SHA}" STREQUAL "") - set(GIT_SHA "Unknown") -endif() +if ("${GIT_SHA}" STREQUAL "") + set(GIT_SHA "Unknown") +endif () # Get the short SHA (first 8 characters) if GIT_SHA is not "Unknown" -if(NOT "${GIT_SHA}" STREQUAL "Unknown") - string(SUBSTRING "${GIT_SHA}" 0 8 GIT_SHORT_SHA) -else() - set(GIT_SHORT_SHA "Unknown") -endif() +if (NOT "${GIT_SHA}" STREQUAL "Unknown") + string(SUBSTRING "${GIT_SHA}" 0 8 GIT_SHORT_SHA) +else () + set(GIT_SHORT_SHA "Unknown") +endif () # Cache the variables for future use set(GIT_SHA "${GIT_SHA}" CACHE STRING "SHA this build was generated from") @@ -105,51 +105,51 @@ add_subdirectory(configured_files) add_subdirectory(src) # Don't even look at tests if we're not top level -if(NOT PROJECT_IS_TOP_LEVEL) - return() -endif() +if (NOT PROJECT_IS_TOP_LEVEL) + return() +endif () # Adding the tests: include(CTest) -if(BUILD_TESTING) - add_subdirectory(test) -endif() +if (BUILD_TESTING) + add_subdirectory(test) +endif () -if(cloysterhpc_BUILD_FUZZ_TESTS) - message(AUTHOR_WARNING "Building Fuzz Tests, using fuzzing sanitizer https://www.llvm.org/docs/LibFuzzer.html") - if (NOT cloysterhpc_ENABLE_ADDRESS_SANITIZER AND NOT cloysterhpc_ENABLE_THREAD_SANITIZER) - message(WARNING "You need asan or tsan enabled for meaningful fuzz testing") - endif() - add_subdirectory(fuzz_test) +if (cloysterhpc_BUILD_FUZZ_TESTS) + message(AUTHOR_WARNING "Building Fuzz Tests, using fuzzing sanitizer https://www.llvm.org/docs/LibFuzzer.html") + if (NOT cloysterhpc_ENABLE_ADDRESS_SANITIZER AND NOT cloysterhpc_ENABLE_THREAD_SANITIZER) + message(WARNING "You need asan or tsan enabled for meaningful fuzz testing") + endif () + add_subdirectory(fuzz_test) -endif() +endif () # If MSVC is being used, and ASAN is enabled, we need to set the debugger environment # so that it behaves well with MSVC's debugger, and we can run the target from visual studio -if(MSVC) - get_all_installable_targets(all_targets) - message("all_targets=${all_targets}") - set_target_properties(${all_targets} PROPERTIES VS_DEBUGGER_ENVIRONMENT "PATH=$(VC_ExecutablePath_x64);%PATH%") -endif() +if (MSVC) + get_all_installable_targets(all_targets) + message("all_targets=${all_targets}") + set_target_properties(${all_targets} PROPERTIES VS_DEBUGGER_ENVIRONMENT "PATH=$(VC_ExecutablePath_x64);%PATH%") +endif () # set the startup project for the "play" button in MSVC set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT ${cloysterhpc_BINARY_NAME}) -if(CMAKE_SKIP_INSTALL_RULES) - return() -endif() +if (CMAKE_SKIP_INSTALL_RULES) + return() +endif () include(cmake/PackageProject.cmake) # Add other targets that you want installed here, by default we just package the one executable # we know we want to ship cloysterhpc_package_project( - TARGETS - ${cloysterhpc_BINARY_NAME} - cloysterhpc_options - cloysterhpc_warnings - # FIXME: this does not work! CK - # PRIVATE_DEPENDENCIES_CONFIGURED project_options project_warnings + TARGETS + ${cloysterhpc_BINARY_NAME} + cloysterhpc_options + cloysterhpc_warnings + # FIXME: this does not work! CK + # PRIVATE_DEPENDENCIES_CONFIGURED project_options project_warnings ) diff --git a/CMakePresets.json b/CMakePresets.json index 21ca411d..54d62c3b 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -22,7 +22,9 @@ "condition": { "type": "inList", "string": "${hostSystemName}", - "list": ["Linux"] + "list": [ + "Linux" + ] }, "vendor": { "microsoft.com/VisualStudioRemoteSettings/CMake/1.0": { diff --git a/fuzz_test/CMakeLists.txt b/fuzz_test/CMakeLists.txt index a7e3d5ef..674d0fd4 100644 --- a/fuzz_test/CMakeLists.txt +++ b/fuzz_test/CMakeLists.txt @@ -5,17 +5,17 @@ find_package(fmt) add_executable(fuzz_tester fuzz_tester.cpp) target_link_libraries( - fuzz_tester - PRIVATE cmake_conan2_template_options - cmake_conan2_template_warnings - fmt::fmt - -coverage - -fsanitize=fuzzer) + fuzz_tester + PRIVATE cmake_conan2_template_options + cmake_conan2_template_warnings + fmt::fmt + -coverage + -fsanitize=fuzzer) target_compile_options(fuzz_tester PRIVATE -fsanitize=fuzzer) # Allow short runs during automated testing to see if something new breaks set(FUZZ_RUNTIME - 10 - CACHE STRING "Number of seconds to run fuzz tests during ctest run") # Default of 10 seconds + 10 + CACHE STRING "Number of seconds to run fuzz tests during ctest run") # Default of 10 seconds add_test(NAME fuzz_tester_run COMMAND fuzz_tester -max_total_time=${FUZZ_RUNTIME}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6b15648b..1206c48d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -12,45 +12,45 @@ add_executable(${cloysterhpc_BINARY_NAME} main.cpp) include(../cmake/CommonLibraries.cmake) target_link_libraries( - ${cloysterhpc_BINARY_NAME} - PRIVATE - cloysterhpc_static - cloysterhpc::cloysterhpc_options - cloysterhpc::cloysterhpc_warnings) + ${cloysterhpc_BINARY_NAME} + PRIVATE + cloysterhpc_static + cloysterhpc::cloysterhpc_options + cloysterhpc::cloysterhpc_warnings) target_link_system_libraries( - ${cloysterhpc_BINARY_NAME} - PRIVATE - ${COMMON_LIBS}) + ${cloysterhpc_BINARY_NAME} + PRIVATE + ${COMMON_LIBS}) target_link_libraries( - cloysterhpc_object - PRIVATE - cloysterhpc::cloysterhpc_options - cloysterhpc::cloysterhpc_warnings) + cloysterhpc_object + PRIVATE + cloysterhpc::cloysterhpc_options + cloysterhpc::cloysterhpc_warnings) target_link_system_libraries( - cloysterhpc_object - PRIVATE - ${COMMON_LIBS}) + cloysterhpc_object + PRIVATE + ${COMMON_LIBS}) target_include_directories(cloysterhpc_static PRIVATE - "${CMAKE_BINARY_DIR}/configured_files/include") + "${CMAKE_BINARY_DIR}/configured_files/include") target_include_directories(cloysterhpc_static ${WARNING_GUARD} PRIVATE - $ - $) + $ + $) target_include_directories(cloysterhpc_object PRIVATE - "${CMAKE_BINARY_DIR}/configured_files/include") + "${CMAKE_BINARY_DIR}/configured_files/include") target_include_directories(cloysterhpc_object ${WARNING_GUARD} PRIVATE - $ - $) + $ + $) target_include_directories(${cloysterhpc_BINARY_NAME} PRIVATE - "${CMAKE_BINARY_DIR}/configured_files/include") + "${CMAKE_BINARY_DIR}/configured_files/include") target_include_directories(${cloysterhpc_BINARY_NAME} ${WARNING_GUARD} PRIVATE - $ - $) + $ + $) # Set target locations to the root folder of the project in /bin and /lib. # WARNING: This will break multiple target compile, disable it if necessary diff --git a/src/cluster.cpp b/src/cluster.cpp index 42c9183f..6c779b14 100644 --- a/src/cluster.cpp +++ b/src/cluster.cpp @@ -551,8 +551,7 @@ void Cluster::fillData(const std::string& answerfilePath) externalConnection.setAddress(answerfile.external.con_ip_addr.value()); getNetwork(Network::Profile::External) - .setAddress( - getNetwork(Network::Profile::External) + .setAddress(getNetwork(Network::Profile::External) .calculateAddress(answerfile.external.con_ip_addr.value())); } else { auto externalNetworkIpAddress = externalConnection.fetchAddress( @@ -561,7 +560,7 @@ void Cluster::fillData(const std::string& answerfilePath) getNetwork(Network::Profile::External) .setAddress(getNetwork(Network::Profile::External) - .calculateAddress(externalNetworkIpAddress)); + .calculateAddress(externalNetworkIpAddress)); } if (!answerfile.external.con_mac_addr->empty()) { @@ -619,8 +618,7 @@ void Cluster::fillData(const std::string& answerfilePath) serviceConnection.setAddress(answerfile.service.con_ip_addr.value()); getNetwork(Network::Profile::Service) - .setAddress( - getNetwork(Network::Profile::Service) + .setAddress(getNetwork(Network::Profile::Service) .calculateAddress(answerfile.service.con_ip_addr.value())); m_headnode.addConnection(std::move(serviceConnection)); @@ -674,8 +672,8 @@ void Cluster::fillData(const std::string& answerfilePath) getNetwork(Network::Profile::Application) .setAddress(getNetwork(Network::Profile::Application) - .calculateAddress( - answerfile.application.con_ip_addr.value())); + .calculateAddress( + answerfile.application.con_ip_addr.value())); m_headnode.addConnection(std::move(applicationConnection)); } diff --git a/src/os.cpp b/src/os.cpp index 92f346ee..16b899e4 100644 --- a/src/os.cpp +++ b/src/os.cpp @@ -24,7 +24,7 @@ OS::OS() { - struct utsname system { }; + struct utsname system {}; uname(&system); setArch(system.machine); diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index c070ee67..60f36f40 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -4,16 +4,16 @@ project(CmakeConfigPackageTests LANGUAGES CXX) # ---- Test as standalone project the exported config package ---- -if(PROJECT_IS_TOP_LEVEL OR TEST_INSTALLED_VERSION) - enable_testing() +if (PROJECT_IS_TOP_LEVEL OR TEST_INSTALLED_VERSION) + enable_testing() - find_package(cloysterhpc CONFIG REQUIRED) # for intro, project_options, ... + find_package(cloysterhpc CONFIG REQUIRED) # for intro, project_options, ... - if(NOT TARGET cloysterhpc_options) - message(FATAL_ERROR "Required config package not found!") - return() # be strictly paranoid for Template Janitor github action! CK - endif() -endif() + if (NOT TARGET cloysterhpc_options) + message(FATAL_ERROR "Required config package not found!") + return() # be strictly paranoid for Template Janitor github action! CK + endif () +endif () # Provide a simple smoke test to make sure that the CLI works and can display a --help message add_test(NAME cli.has_help COMMAND main --help) @@ -42,47 +42,47 @@ target_compile_definitions(cloysterhpc_test_object PRIVATE BUILD_TESTING=1) include(../cmake/CommonLibraries.cmake) target_link_libraries( - ${PROJECT_NAME} - PRIVATE - cloysterhpc_test_object - cloysterhpc::cloysterhpc_warnings - cloysterhpc::cloysterhpc_options) + ${PROJECT_NAME} + PRIVATE + cloysterhpc_test_object + cloysterhpc::cloysterhpc_warnings + cloysterhpc::cloysterhpc_options) target_link_system_libraries( - ${PROJECT_NAME} - PRIVATE - ${COMMON_LIBS}) + ${PROJECT_NAME} + PRIVATE + ${COMMON_LIBS}) target_include_directories(${PROJECT_NAME} ${WARNING_GUARD} PRIVATE - $ - $) + $ + $) target_link_libraries( - cloysterhpc_test_object - PRIVATE - cloysterhpc::cloysterhpc_options - cloysterhpc::cloysterhpc_warnings) + cloysterhpc_test_object + PRIVATE + cloysterhpc::cloysterhpc_options + cloysterhpc::cloysterhpc_warnings) target_link_system_libraries( - cloysterhpc_test_object - PRIVATE - ${COMMON_LIBS}) + cloysterhpc_test_object + PRIVATE + ${COMMON_LIBS}) target_include_directories(cloysterhpc_test_object PRIVATE - "${CMAKE_BINARY_DIR}/../configured_files/include") + "${CMAKE_BINARY_DIR}/../configured_files/include") target_include_directories(cloysterhpc_test_object ${WARNING_GUARD} PRIVATE - $ - $) + $ + $) set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD ${CMAKE_CXX_STANDARD}) -if(WIN32 AND BUILD_SHARED_LIBS) - add_custom_command( - TARGET ${PROJECT_NAME} - PRE_BUILD - COMMAND ${CMAKE_COMMAND} -E copy $ $ - COMMAND_EXPAND_LISTS) -endif() +if (WIN32 AND BUILD_SHARED_LIBS) + add_custom_command( + TARGET ${PROJECT_NAME} + PRE_BUILD + COMMAND ${CMAKE_COMMAND} -E copy $ $ + COMMAND_EXPAND_LISTS) +endif () # ---- Add Tests ---- @@ -91,26 +91,26 @@ endif() # ${PROJECT_NAME}) if (cloysterhpc_ENABLE_CONAN) - string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER) - string(TOUPPER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_UPPER) - string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" CMAKE_SYSTEM_PROCESSOR_LOWER) + string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER) + string(TOUPPER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_UPPER) + string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" CMAKE_SYSTEM_PROCESSOR_LOWER) - # Hack to fix wrong architecture name for aarch64 during Conan install - if (CMAKE_SYSTEM_PROCESSOR_LOWER STREQUAL "aarch64") - set(CMAKE_SYSTEM_PROCESSOR_LOWER "armv8") - endif() + # Hack to fix wrong architecture name for aarch64 during Conan install + if (CMAKE_SYSTEM_PROCESSOR_LOWER STREQUAL "aarch64") + set(CMAKE_SYSTEM_PROCESSOR_LOWER "armv8") + endif () - include(${doctest_DIR}/doctest-${CMAKE_BUILD_TYPE_LOWER}-${CMAKE_SYSTEM_PROCESSOR_LOWER}-data.cmake) - include(${doctest_BUILD_DIRS_${CMAKE_BUILD_TYPE_UPPER}}/doctest.cmake) -else() - include(${doctest_SOURCE_DIR}/scripts/cmake/doctest.cmake) -endif() + include(${doctest_DIR}/doctest-${CMAKE_BUILD_TYPE_LOWER}-${CMAKE_SYSTEM_PROCESSOR_LOWER}-data.cmake) + include(${doctest_BUILD_DIRS_${CMAKE_BUILD_TYPE_UPPER}}/doctest.cmake) +else () + include(${doctest_SOURCE_DIR}/scripts/cmake/doctest.cmake) +endif () doctest_discover_tests(${PROJECT_NAME}) # ---- code coverage ---- -if(ENABLE_TEST_COVERAGE) - target_compile_options(${PROJECT_NAME} PUBLIC -O0 -g -fprofile-arcs -ftest-coverage) - target_link_options(${PROJECT_NAME} PUBLIC -fprofile-arcs -ftest-coverage) -endif() +if (ENABLE_TEST_COVERAGE) + target_compile_options(${PROJECT_NAME} PUBLIC -O0 -g -fprofile-arcs -ftest-coverage) + target_link_options(${PROJECT_NAME} PUBLIC -fprofile-arcs -ftest-coverage) +endif ()