Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spdlog: Use system library if found #154

Merged
merged 1 commit into from
Jun 25, 2024
Merged
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
17 changes: 13 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,16 @@ else()
endif()
add_definitions(-DLOADER_VERSION_SHA="${VERSION_SHA}")

include_directories("${CMAKE_CURRENT_SOURCE_DIR}/third_party/spdlog_headers")
if(SYSTEM_SPDLOG)
find_package(spdlog CONFIG)
if(spdlog_FOUND)
message(STATUS "System spdlog found.")
else()
message(FATAL_ERROR "SYSTEM_SPDLOG specified but spdlog wasn't found.")
endif()
else()
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/third_party/spdlog_headers")
endif()

# Update other relevant variables to include the patch
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
Expand Down Expand Up @@ -151,17 +160,17 @@ if(MSVC)

# enable exceptions handling
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")

# enable creation of PDB files for Release Builds
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF")

# enable CET shadow stack
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /CETCOMPAT")

#Use of sccache with MSVC requires workaround of replacing /Zi with /Z7
#https://github.com/mozilla/sccache
if(USE_Z7) #sccache
if(USE_Z7) #sccache
string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
string(REPLACE "/Zi" "/Z7" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
Expand Down
14 changes: 8 additions & 6 deletions source/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: MIT

add_library(utils
STATIC
"logging.h"
"logging.cpp"
)
set(logging_files logging.h logging.cpp)
add_library(utils STATIC ${logging_files})

target_include_directories(utils PRIVATE ${CMAKE_SOURCE_DIR}/third_party/spdlog_headers/)
if(SYSTEM_SPDLOG)
target_link_libraries(utils PUBLIC spdlog::spdlog)
else()
target_include_directories(utils PUBLIC ${PROJECT_SOURCE_DIR}/third_party/spdlog_headers/)
endif()
set_property(TARGET utils PROPERTY POSITION_INDEPENDENT_CODE ON)
Loading