Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
R
rapidjson
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
rapidjson
Commits
56bb9992
Commit
56bb9992
authored
May 31, 2016
by
Eli Fidler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support building with ASAN and UBSAN on Clang and GCC
parent
2e663391
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
0 deletions
+31
-0
CMakeLists.txt
CMakeLists.txt
+31
-0
No files found.
CMakeLists.txt
View file @
56bb9992
CMAKE_MINIMUM_REQUIRED
(
VERSION 2.8
)
if
(
POLICY CMP0025
)
# detect Apple's Clang
cmake_policy
(
SET CMP0025 NEW
)
endif
()
if
(
POLICY CMP0054
)
cmake_policy
(
SET CMP0054 NEW
)
endif
()
...
...
@@ -28,6 +32,9 @@ option(RAPIDJSON_BUILD_THIRDPARTY_GTEST
option
(
RAPIDJSON_BUILD_CXX11
"Build rapidjson with C++11 (gcc/clang)"
ON
)
option
(
RAPIDJSON_BUILD_ASAN
"Build rapidjson with address sanitizer (gcc/clang)"
OFF
)
option
(
RAPIDJSON_BUILD_UBSAN
"Build rapidjson with undefined behavior sanitizer (gcc/clang)"
OFF
)
option
(
RAPIDJSON_HAS_STDSTRING
""
OFF
)
if
(
RAPIDJSON_HAS_STDSTRING
)
add_definitions
(
-DRAPIDJSON_HAS_STDSTRING
)
...
...
@@ -51,11 +58,35 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-std=c++11"
)
endif
()
endif
()
if
(
RAPIDJSON_BUILD_ASAN
)
if
(
CMAKE_CXX_COMPILER_VERSION VERSION_LESS
"4.8.0"
)
message
(
FATAL_ERROR
"GCC < 4.8 doesn't support the address sanitizer"
)
else
()
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-fsanitize=address"
)
endif
()
endif
()
if
(
RAPIDJSON_BUILD_UBSAN
)
if
(
CMAKE_CXX_COMPILER_VERSION VERSION_LESS
"4.9.0"
)
message
(
FATAL_ERROR
"GCC < 4.9 doesn't support the undefined behavior sanitizer"
)
else
()
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-fsanitize=undefined"
)
endif
()
endif
()
elseif
(
CMAKE_CXX_COMPILER_ID MATCHES
"Clang"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-march=native -Wall -Wextra -Werror -Wno-missing-field-initializers"
)
if
(
RAPIDJSON_BUILD_CXX11
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-std=c++11"
)
endif
()
if
(
RAPIDJSON_BUILD_ASAN
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-fsanitize=address"
)
endif
()
if
(
RAPIDJSON_BUILD_UBSAN
)
if
(
CMAKE_CXX_COMPILER_ID STREQUAL
"AppleClang"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-fsanitize=undefined-trap -fsanitize-undefined-trap-on-error"
)
else
()
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-fsanitize=undefined"
)
endif
()
endif
()
elseif
(
"
${
CMAKE_CXX_COMPILER_ID
}
"
STREQUAL
"MSVC"
)
add_definitions
(
-D_CRT_SECURE_NO_WARNINGS=1
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
/EHsc"
)
...
...
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