mirror of
https://github.com/cuberite/SQLiteCpp.git
synced 2025-08-04 09:46:02 -04:00
Add address sanitizer as an option for GCC & Clang
Add corresponding option SQLITECPP_USE_ASAN Also formalize previously existing SQLITECPP_USE_GCOV option
This commit is contained in:
parent
9b00034b06
commit
a68397c7ac
@ -171,7 +171,7 @@ before_install:
|
|||||||
before_script:
|
before_script:
|
||||||
- mkdir build
|
- mkdir build
|
||||||
- cd build
|
- cd build
|
||||||
- cmake -DCMAKE_BUILD_TYPE=Debug -DSQLITECPP_USE_GCOV=ON -DSQLITECPP_BUILD_EXAMPLES=ON -DSQLITECPP_BUILD_TESTS=ON ..
|
- cmake -DCMAKE_BUILD_TYPE=Debug -DSQLITECPP_USE_ASAN=ON -DSQLITECPP_USE_GCOV=ON -DSQLITECPP_BUILD_EXAMPLES=ON -DSQLITECPP_BUILD_TESTS=ON ..
|
||||||
|
|
||||||
# build examples, and run tests (ie make & make test)
|
# build examples, and run tests (ie make & make test)
|
||||||
script:
|
script:
|
||||||
|
@ -42,13 +42,10 @@ else (MSVC)
|
|||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++0x-compat") # C++ only
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++0x-compat") # C++ only
|
||||||
if (CMAKE_COMPILER_IS_GNUCXX)
|
if (CMAKE_COMPILER_IS_GNUCXX)
|
||||||
# GCC flags
|
# GCC flags
|
||||||
if (SQLITECPP_USE_GCOV AND CMAKE_COMPILER_IS_GNUCXX)
|
option(SQLITECPP_USE_GCOV "USE GCov instrumentation." OFF)
|
||||||
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
if (SQLITECPP_USE_GCOV)
|
||||||
message (STATUS "Using GCov instrumentation")
|
message (STATUS "Using GCov instrumentation")
|
||||||
else ()
|
add_compile_options (-coverage) # NOTE -fkeep-inline-functions would be usefull but not working with current google test and gcc 4.8
|
||||||
message (WARNING "GCov instrumentation works best in Debug mode")
|
|
||||||
endif ()
|
|
||||||
add_compile_options (-coverage) # NOTE would be usefull but not working with current google test and gcc 4.8 -fkeep-inline-functions
|
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -coverage")
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -coverage")
|
||||||
endif ()
|
endif ()
|
||||||
endif (CMAKE_COMPILER_IS_GNUCXX)
|
endif (CMAKE_COMPILER_IS_GNUCXX)
|
||||||
@ -206,6 +203,18 @@ install(EXPORT ${PROJECT_NAME}Config DESTINATION lib/cmake/${PROJECT_NAME})
|
|||||||
# set_target_properties(SQLiteCpp PROPERTIES COMPILE_FLAGS "-DSQLITECPP_HAS_MEM_STRUCT")
|
# set_target_properties(SQLiteCpp PROPERTIES COMPILE_FLAGS "-DSQLITECPP_HAS_MEM_STRUCT")
|
||||||
#endif()
|
#endif()
|
||||||
|
|
||||||
|
option(SQLITECPP_USE_ASAN "Use Address Sanitizer." OFF)
|
||||||
|
if (SQLITECPP_USE_ASAN)
|
||||||
|
if ((CMAKE_CXX_COMPILER_VERSION GREATER_EQUAL 6) OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"))
|
||||||
|
message (STATUS "Using Address Sanitizer")
|
||||||
|
set_target_properties(SQLiteCpp PROPERTIES COMPILE_FLAGS "-fsanitize=address -fno-omit-frame-pointer")
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address")
|
||||||
|
if (CMAKE_COMPILER_IS_GNUCXX)
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=gold")
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
endif (SQLITECPP_USE_ASAN)
|
||||||
|
|
||||||
option(SQLITECPP_INTERNAL_SQLITE "Add the internal SQLite3 source to the project." ON)
|
option(SQLITECPP_INTERNAL_SQLITE "Add the internal SQLite3 source to the project." ON)
|
||||||
if (SQLITECPP_INTERNAL_SQLITE)
|
if (SQLITECPP_INTERNAL_SQLITE)
|
||||||
# build the SQLite3 C library (for ease of use/compatibility) versus Linux sqlite3-dev package
|
# build the SQLite3 C library (for ease of use/compatibility) versus Linux sqlite3-dev package
|
||||||
|
2
build.sh
2
build.sh
@ -11,7 +11,7 @@ mkdir -p build
|
|||||||
cd build
|
cd build
|
||||||
|
|
||||||
# Generate a Makefile for GCC (or Clang, depanding on CC/CXX envvar)
|
# Generate a Makefile for GCC (or Clang, depanding on CC/CXX envvar)
|
||||||
cmake -DCMAKE_BUILD_TYPE=Debug -DSQLITECPP_USE_GCOV=OFF -DSQLITECPP_BUILD_EXAMPLES=ON -DSQLITECPP_BUILD_TESTS=ON ..
|
cmake -DCMAKE_BUILD_TYPE=Debug -DSQLITECPP_USE_ASAN=ON -DSQLITECPP_USE_GCOV=OFF -DSQLITECPP_BUILD_EXAMPLES=ON -DSQLITECPP_BUILD_TESTS=ON ..
|
||||||
|
|
||||||
# Build (ie 'make')
|
# Build (ie 'make')
|
||||||
cmake --build .
|
cmake --build .
|
||||||
|
Loading…
x
Reference in New Issue
Block a user