Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
S
spdlog
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
spdlog
Commits
cf64f2ba
Commit
cf64f2ba
authored
Jun 10, 2019
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed CMake address sanitizer
parent
68a0193d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
29 deletions
+28
-29
CMakeLists.txt
CMakeLists.txt
+2
-1
utils.cmake
cmake/utils.cmake
+19
-20
CMakeLists.txt
example/CMakeLists.txt
+2
-2
CMakeLists.txt
tests/CMakeLists.txt
+5
-6
No files found.
CMakeLists.txt
View file @
cf64f2ba
...
...
@@ -45,6 +45,7 @@ option(SPDLOG_BUILD_EXAMPLES "Build examples" ON)
option
(
SPDLOG_BUILD_BENCH
"Build benchmarks (Requires https://github.com/google/benchmark.git to be installed)"
OFF
)
option
(
SPDLOG_BUILD_TESTS
"Build tests"
OFF
)
option
(
SPDLOG_BUILD_HO_TESTS
"Build tests using the header only version"
OFF
)
option
(
SPDLOG_SANITIZE_ADDRESS
"Enable address sanitizer in tests"
OFF
)
option
(
SPDLOG_INSTALL
"Generate the install target."
${
SPDLOG_MASTER_PROJECT
}
)
option
(
SPDLOG_FMT_EXTERNAL
"Use external fmt library instead of bundled"
OFF
)
...
...
@@ -57,7 +58,7 @@ find_package(Threads REQUIRED)
#---------------------------------------------------------------------------------------
add_library
(
spdlog STATIC src/spdlog.cpp
${
SPDLOG_ALL_HEADERS
}
)
add_library
(
spdlog::spdlog ALIAS spdlog
)
target_compile_definitions
(
spdlog PUBLIC SPDLOG_COMPILED_LIB
)
target_include_directories
(
spdlog PUBLIC
"$<BUILD_INTERFACE:
${
CMAKE_CURRENT_LIST_DIR
}
/include>"
...
...
cmake/utils.cmake
View file @
cf64f2ba
...
...
@@ -12,30 +12,30 @@ function(spdlog_extract_version)
if
(
NOT ver_major OR NOT ver_minor OR NOT ver_patch
)
message
(
FATAL_ERROR
"Could not extract valid version from spdlog/version.h"
)
endif
()
set
(
SPDLOG_VERSION
"
${
ver_major
}
.
${
ver_minor
}
.
${
ver_patch
}
"
PARENT_SCOPE
)
set
(
SPDLOG_VERSION
"
${
ver_major
}
.
${
ver_minor
}
.
${
ver_patch
}
"
PARENT_SCOPE
)
endfunction
()
# Turn on warnings on the given target
# Turn on warnings on the given target
function
(
spdlog_enable_warnings target_name
)
if
(
CMAKE_CXX_COMPILER_ID MATCHES
"GNU|Clang|AppleClang"
)
target_compile_options
(
${
target_name
}
PRIVATE -Wall -Wextra -Wconversion -pedantic -Wfatal-errors
)
endif
()
if
(
CMAKE_CXX_COMPILER_ID MATCHES
"MSVC"
)
target_compile_options
(
${
target_name
}
PRIVATE /W4 /WX
)
endif
()
if
(
CMAKE_CXX_COMPILER_ID MATCHES
"GNU|Clang|AppleClang"
)
target_compile_options
(
${
target_name
}
PRIVATE -Wall -Wextra -Wconversion -pedantic -Wfatal-errors
)
endif
()
if
(
CMAKE_CXX_COMPILER_ID MATCHES
"MSVC"
)
target_compile_options
(
${
target_name
}
PRIVATE /W4 /WX
)
endif
()
endfunction
()
# Enable address sanitizer (gcc/clang only)
function
(
spdlog_enable_sanitizer target_name
)
if
(
NOT CMAKE_CXX_COMPILER_ID MATCHES
"GNU|Clang"
)
message
(
FATAL_ERROR
"Sanitizer supported only for gcc/clang"
)
endif
()
message
(
STATUS
"Address sanitizer enabled"
)
target_compile_options
(
${
target_name
}
"-fsanitize=address,undefined"
)
target_compile_options
(
${
target_name
}
"-fno-sanitize=signed-integer-overflow"
)
target_compile_options
(
${
target_name
}
"-fno-sanitize-recover=all"
)
target_compile_options
(
${
target_name
}
"-fno-omit-frame-pointer"
)
target_link_libraries
(
${
target_name
}
"-fsanitize=address,undefined -fuse-ld=gold"
)
endfunction
()
\ No newline at end of file
function
(
spdlog_enable_sanitizer target_name
)
if
(
NOT CMAKE_CXX_COMPILER_ID MATCHES
"GNU|Clang"
)
message
(
FATAL_ERROR
"Sanitizer supported only for gcc/clang"
)
endif
()
message
(
STATUS
"Address sanitizer enabled"
)
target_compile_options
(
${
target_name
}
PRIVATE -fsanitize=address,undefined
)
target_compile_options
(
${
target_name
}
PRIVATE -fno-sanitize=signed-integer-overflow
)
target_compile_options
(
${
target_name
}
PRIVATE -fno-sanitize-recover=all
)
target_compile_options
(
${
target_name
}
PRIVATE -fno-omit-frame-pointer
)
target_link_libraries
(
${
target_name
}
PRIVATE -fsanitize=address,undefined -fuse-ld=gold
)
endfunction
()
example/CMakeLists.txt
View file @
cf64f2ba
...
...
@@ -14,14 +14,14 @@ endif()
#---------------------------------------------------------------------------------------
add_executable
(
example example.cpp
)
spdlog_enable_warnings
(
example
)
target_link_libraries
(
example spdlog::spdlog
)
target_link_libraries
(
example
PRIVATE
spdlog::spdlog
)
#---------------------------------------------------------------------------------------
# Example of using header-only library
#---------------------------------------------------------------------------------------
add_executable
(
example_header_only example.cpp
)
spdlog_enable_warnings
(
example_header_only
)
target_link_libraries
(
example_header_only spdlog::spdlog_header_only
)
target_link_libraries
(
example_header_only
PRIVATE
spdlog::spdlog_header_only
)
# Create logs directory
file
(
MAKE_DIRECTORY
"
${
CMAKE_CURRENT_BINARY_DIR
}
/logs"
)
tests/CMakeLists.txt
View file @
cf64f2ba
...
...
@@ -22,21 +22,21 @@ enable_testing()
if
(
SPDLOG_BUILD_TESTS
)
add_executable
(
spdlog-utests
${
SPDLOG_UTESTS_SOURCES
}
)
spdlog_enable_warnings
(
spdlog-utests
)
target_link_libraries
(
spdlog-utests spdlog
)
target_link_libraries
(
spdlog-utests
PRIVATE
spdlog
)
if
(
SPDLOG_SANITIZE_ADDRESS
)
spdlog_enable_sanitizer
(
spdlog-utests
)
endif
()
add_test
(
NAME spdlog-utests COMMAND spdlog-utests
)
add_test
(
NAME spdlog-utests COMMAND spdlog-utests
)
endif
()
# The header-only library version tests
if
(
SPDLOG_BUILD_HO_TESTS
)
add_executable
(
spdlog-utests-ho
${
SPDLOG_UTESTS_SOURCES
}
)
spdlog_enable_warnings
(
spdlog-utests-ho
)
target_link_libraries
(
spdlog-utests-ho spdlog::spdlog_header_only
)
target_link_libraries
(
spdlog-utests-ho
PRIVATE
spdlog::spdlog_header_only
)
if
(
SPDLOG_SANITIZE_ADDRESS
)
spdlog_set_address_sanitizer
(
spdlog-utests-ho
)
endif
()
add_test
(
NAME spdlog-utests-ho COMMAND spdlog-utests-ho
)
endif
()
\ No newline at end of file
endif
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment