-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
set(CMAKE_CXX_STANDARD 17) | ||
set(CMAKE_CXX_EXTENSIONS OFF) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
|
||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer") | ||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -fno-omit-frame-pointer") | ||
|
||
set(sanitizers "address") | ||
if (ENABLE_UB_SANITIZER) | ||
# NOTE: UB check requires instrumented libstdc++ | ||
set(sanitizers "${sanitizers},undefined") | ||
endif () | ||
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") | ||
# do nothing for gcc | ||
elseif (CMAKE_CXX_COMPILER_ID MATCHES "^(Clang|AppleClang)$") | ||
set(sanitizers "${sanitizers},nullability") | ||
else () | ||
message(FATAL_ERROR "unsupported compiler ${CMAKE_CXX_COMPILER_ID}") | ||
endif () | ||
|
||
if (ENABLE_SANITIZER) | ||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=${sanitizers}") | ||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-sanitize=alignment") | ||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-sanitize-recover=${sanitizers}") | ||
endif () | ||
if (ENABLE_COVERAGE) | ||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} --coverage") | ||
endif () | ||
|
||
function(set_compile_options target_name) | ||
target_compile_options(${target_name} | ||
PRIVATE -Wall -Wextra -Werror) | ||
endfunction(set_compile_options) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
if(TARGET gflags::gflags) | ||
return() | ||
endif() | ||
|
||
find_library(gflags_LIBRARY_FILE NAMES gflags) | ||
find_path(gflags_INCLUDE_DIR NAMES gflags/gflags.h) | ||
|
||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(gflags DEFAULT_MSG | ||
gflags_LIBRARY_FILE | ||
gflags_INCLUDE_DIR) | ||
|
||
if(gflags_LIBRARY_FILE AND gflags_INCLUDE_DIR) | ||
set(gflags_FOUND ON) | ||
add_library(gflags::gflags SHARED IMPORTED) | ||
set_target_properties(gflags::gflags PROPERTIES | ||
IMPORTED_LOCATION "${gflags_LIBRARY_FILE}" | ||
INTERFACE_INCLUDE_DIRECTORIES "${gflags_INCLUDE_DIR}") | ||
else() | ||
set(gflags_FOUND OFF) | ||
endif() | ||
|
||
unset(gflags_LIBRARY_FILE CACHE) | ||
unset(gflags_INCLUDE_DIR CACHE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
if(TARGET glog::glog) | ||
return() | ||
endif() | ||
|
||
find_library(glog_LIBRARY_FILE NAMES glog) | ||
find_path(glog_INCLUDE_DIR NAMES glog/logging.h) | ||
|
||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(glog DEFAULT_MSG | ||
glog_LIBRARY_FILE | ||
glog_INCLUDE_DIR) | ||
|
||
if(glog_LIBRARY_FILE AND glog_INCLUDE_DIR) | ||
set(glog_FOUND ON) | ||
add_library(glog::glog SHARED IMPORTED) | ||
set_target_properties(glog::glog PROPERTIES | ||
IMPORTED_LOCATION "${glog_LIBRARY_FILE}" | ||
INTERFACE_INCLUDE_DIRECTORIES "${glog_INCLUDE_DIR}") | ||
else() | ||
set(glog_FOUND OFF) | ||
endif() | ||
|
||
unset(glog_LIBRARY_FILE CACHE) | ||
unset(glog_INCLUDE_DIR CACHE) |