diff --git a/packages/cpp/ArmoniK.Api.Client/CMakeLists.txt b/packages/cpp/ArmoniK.Api.Client/CMakeLists.txt index 9b496f36c..bf18053e6 100644 --- a/packages/cpp/ArmoniK.Api.Client/CMakeLists.txt +++ b/packages/cpp/ArmoniK.Api.Client/CMakeLists.txt @@ -75,11 +75,7 @@ list(APPEND PROTO_GENERATED_FILES ${PROTO_GENERATED_MESSAGES}) target_link_libraries(${PROJECT_NAME} PUBLIC protobuf::libprotobuf gRPC::grpc++_unsecure ArmoniK.Api.Common) -if(MSVC) - target_compile_options(${PROJECT_NAME} PRIVATE /W4) -else() - target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra) -endif() +setup_options(${PROJECT_NAME}) target_compile_definitions(${PROJECT_NAME} PUBLIC API_CLIENT_NAMESPACE=${NAMESPACE}) diff --git a/packages/cpp/ArmoniK.Api.Common/CMakeLists.txt b/packages/cpp/ArmoniK.Api.Common/CMakeLists.txt index b2acfc973..8e31b0d62 100644 --- a/packages/cpp/ArmoniK.Api.Common/CMakeLists.txt +++ b/packages/cpp/ArmoniK.Api.Common/CMakeLists.txt @@ -61,11 +61,7 @@ add_library(${PROJECT_NAME} STATIC ${PROTO_GENERATED_FILES} ${SRC_CLIENT_FILES} target_link_libraries(${PROJECT_NAME} PUBLIC protobuf::libprotobuf gRPC::grpc++_unsecure) target_compile_definitions(${PROJECT_NAME} PUBLIC API_COMMON_NAMESPACE=${NAMESPACE}) -if(MSVC) - target_compile_options(${PROJECT_NAME} PRIVATE /W4) -else() - target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra) -endif() +setup_options(${PROJECT_NAME}) set(PROTO_BINARY_DIR "${PROJECT_BUILD_DIR}") set(PROTO_IMPORT_DIRS "${PROTO_FILES_DIR}") diff --git a/packages/cpp/ArmoniK.Api.Common/header/serilog/serilog.h b/packages/cpp/ArmoniK.Api.Common/header/serilog/serilog.h index f6424184d..bc3f2b259 100644 --- a/packages/cpp/ArmoniK.Api.Common/header/serilog/serilog.h +++ b/packages/cpp/ArmoniK.Api.Common/header/serilog/serilog.h @@ -802,7 +802,10 @@ class serilog { void initialize(const char *name) { level = base_level; level_serilog = base_level_serilog; - std::strcpy(name_, name); + if (name != name_) { + std::strcpy(name_, name); + } + register_logger(this); shared_instance().init(level, level_serilog); } diff --git a/packages/cpp/ArmoniK.Api.Worker/CMakeLists.txt b/packages/cpp/ArmoniK.Api.Worker/CMakeLists.txt index 8e1650191..d374be1d9 100644 --- a/packages/cpp/ArmoniK.Api.Worker/CMakeLists.txt +++ b/packages/cpp/ArmoniK.Api.Worker/CMakeLists.txt @@ -42,11 +42,7 @@ target_include_directories(${PROJECT_NAME} "$" ) -if(MSVC) - target_compile_options(${PROJECT_NAME} PRIVATE /W4) -else() - target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra) -endif() +setup_options(${PROJECT_NAME}) set(PROTO_BINARY_DIR "${PROJECT_BUILD_DIR}") set(PROTO_IMPORT_DIRS "${PROTO_FILES_DIR}") diff --git a/packages/cpp/CMakeLists.txt b/packages/cpp/CMakeLists.txt index 05588d969..2cafb8912 100644 --- a/packages/cpp/CMakeLists.txt +++ b/packages/cpp/CMakeLists.txt @@ -25,6 +25,32 @@ include(CMakePackageConfigHelpers) set(CMAKE_CXX_STANDARD 17) +function(setup_options project_name_param) + +file(READ /etc/issue ${PROJECT_NAME}_ETCISSUE_CONTENT) +string(FIND "${${project_name_param}_ETCISSUE_CONTENT}" "Alpine" IS_ALPINE) + +if(MSVC) + target_compile_options(${project_name_param} PRIVATE /W4) +else() + if(CMAKE_BUILD_TYPE MATCHES DEBUG AND IS_ALPINE EQUAL -1) + target_compile_options(${project_name_param} PRIVATE -Wall -Wextra -Wpedantic -fsanitize=undefined,address) + else () + target_compile_options(${project_name_param} PRIVATE -Wall -Wextra -Wpedantic) + endif() +endif() + +if(IS_ALPINE EQUAL -1) + message(STATUS "Not found Alpine distribution " ${IS_ALPINE}) +else() + message(STATUS "Found Alpine distribution " ${IS_ALPINE}) +endif() + +if(CMAKE_BUILD_TYPE MATCHES DEBUG AND IS_ALPINE EQUAL -1) + target_link_options(${project_name_param} PRIVATE -fsanitize=undefined,address) +endif() +endfunction() + add_subdirectory(ArmoniK.Api.Common) if(BUILD_WORKER) add_subdirectory(ArmoniK.Api.Worker)