Skip to content

Commit

Permalink
fix: fixed serilog, added cmake function (#372)
Browse files Browse the repository at this point in the history
  • Loading branch information
lemaitre-aneo authored Aug 4, 2023
2 parents b8800ae + f8a33cb commit c4bfecb
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 16 deletions.
6 changes: 1 addition & 5 deletions packages/cpp/ArmoniK.Api.Client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})

Expand Down
6 changes: 1 addition & 5 deletions packages/cpp/ArmoniK.Api.Common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
5 changes: 4 additions & 1 deletion packages/cpp/ArmoniK.Api.Common/header/serilog/serilog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
6 changes: 1 addition & 5 deletions packages/cpp/ArmoniK.Api.Worker/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@ target_include_directories(${PROJECT_NAME}
"$<TARGET_PROPERTY:ArmoniK.Api.Common,INTERFACE_INCLUDE_DIRECTORIES>"
)

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}")
Expand Down
26 changes: 26 additions & 0 deletions packages/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c4bfecb

Please sign in to comment.