Added options in the root CMakeList.txt to inactivate any optional targets & move back to a single CMakeList.txt

This commit is contained in:
Sébastien Rombauts 2014-02-07 19:12:47 +01:00
parent d6f5029f6c
commit e7aa4f46bb
6 changed files with 4894 additions and 69 deletions

2
.gitignore vendored
View File

@ -1,6 +1,8 @@
Debug Debug
Release Release
build build
example1
*.a
/SQLiteCpp.sln /SQLiteCpp.sln
*.ncb *.ncb

View File

@ -1,6 +1,6 @@
# Main CMake file compiling the library itself, examples and tests. # Main CMake file for compiling the library itself, examples and tests.
# #
# Copyright (c) 2012-2013 Sebastien Rombauts (sebastien.rombauts@gmail.com) # Copyright (c) 2012-2014 Sebastien Rombauts (sebastien.rombauts@gmail.com)
# #
# Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt # Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt
# or copy at http://opensource.org/licenses/MIT) # or copy at http://opensource.org/licenses/MIT)
@ -9,40 +9,99 @@ cmake_minimum_required (VERSION 2.6)
project(SQLiteCpp) project(SQLiteCpp)
# Enable the use of SQLite column metadata and Column::getName() method, # Enable the use of SQLite column metadata and Column::getName() method,
# Require that the sqlite3 library is also compiled with this flag. # Require that the sqlite3 library is also compiled with this flag (default under Debian/Ubuntu).
option (SQLITE_ENABLE_COLUMN_METADATA option(SQLITE_ENABLE_COLUMN_METADATA "Enable Column::getName(). Require support from sqlite3 library." ON)
"Enable Column::getName(). Require support from sqlite3 library." OFF)
if (SQLITE_ENABLE_COLUMN_METADATA) if (SQLITE_ENABLE_COLUMN_METADATA)
add_definitions(-DSQLITE_ENABLE_COLUMN_METADATA) add_definitions(-DSQLITE_ENABLE_COLUMN_METADATA)
endif () endif ()
option(SQLITE_ENABLE_ASSERT_HANDLER "Enable the user defintion of a assertion_failed() handler." ON)
if (SQLITE_ENABLE_ASSERT_HANDLER)
# Enable the user defintion of a assertion_failed() handler. # Enable the user defintion of a assertion_failed() handler.
add_definitions(-DSQLITECPP_ENABLE_ASSERT_HANDLER) add_definitions(-DSQLITECPP_ENABLE_ASSERT_HANDLER)
endif ()
# Define useful variables to handle OS/Compiler differences
if (MSVC) if (MSVC)
set(CPPLINT_ARG_OUTPUT "--output=vs7")
set(CPPCHECK_ARG_TEMPLATE "--template=vs")
set(DEV_NULL "NUL")
# build the SQLite3 C library for Windows (for ease of use) # build the SQLite3 C library for Windows (for ease of use)
add_subdirectory(sqlite3) add_subdirectory(sqlite3)
include_directories("${PROJECT_SOURCE_DIR}/sqlite3") include_directories("${PROJECT_SOURCE_DIR}/sqlite3")
# disable Visual Studio warnings for fopen() used in the example # disable Visual Studio warnings for fopen() used in the example
add_definitions (/D_CRT_SECURE_NO_WARNINGS) add_definitions(-D_CRT_SECURE_NO_WARNINGS)
elseif (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) elseif (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
set(CPPLINT_ARG_OUTPUT "--output=eclipse")
set(CPPCHECK_ARG_TEMPLATE "--template=gcc")
set(DEV_NULL "/dev/null")
# GCC flags # GCC flags
add_definitions(-rdynamic -fstack-protector-all -Wall -Wextra -pedantic -Weffc++ -Wformat-security -Winit-self -Wswitch-default -Wswitch-enum -Wfloat-equal -Wundef -Wshadow -Wcast-qual -Wconversion -Wlogical-op -Winline -Wsuggest-attribute=pure -Wsuggest-attribute=const) add_definitions(-rdynamic -fstack-protector-all -Wall -Wextra -pedantic -Weffc++ -Wformat-security -Winit-self -Wswitch-default -Wswitch-enum -Wfloat-equal -Wundef -Wshadow -Wcast-qual -Wconversion -Wlogical-op -Winline -Wsuggest-attribute=pure -Wsuggest-attribute=const)
endif () endif ()
set(CPPLINT_ARG_VERBOSE "--verbose=3")
set(CPPLINT_ARG_LINELENGTH "--linelength=120")
# add a cppcheck target to the "all" target
add_custom_target(cppcheck ## Core source code ##
# adding a new file require explicittly modifing the CMakeLists.txt
# so that CMake knows that it should rebuild the project (it is best practice)
# list of sources files of the library
set(SQLITECPP_SRC
src/SQLiteC++.h
src/Assertion.h
src/Column.cpp
src/Column.h
src/Database.cpp
src/Database.h
src/Exception.h
src/Statement.cpp
src/Statement.h
src/Transaction.cpp
src/Transaction.h
)
# add sources of the wrapper as a "SQLiteCpp" static library
add_library (SQLiteCpp ${SQLITECPP_SRC})
source_group(src FILES ${SQLITECPP_SRC})
if(UNIX AND (CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"))
set_target_properties(SQLiteCpp PROPERTIES COMPILE_FLAGS "-fPIC")
endif(UNIX AND (CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"))
# Optional additional targets:
option(SQLITECPP_RUN_CPPLINT "Run cpplint.py tool for Google C++ StyleGuide." OFF)
if (SQLITECPP_RUN_CPPLINT)
# add a cpplint target to the "all" target
add_custom_target(SQLiteCpp_cpplint
ALL ALL
COMMAND cppcheck -j 4 cppcheck --enable=style,portability,performance,information --quiet --template='{file}:{line}: warning: cppcheck: {message} [{severity}/{id}]' src COMMAND python cpplint.py ${CPPLINT_ARG_OUTPUT} ${CPPLINT_ARG_VERBOSE} ${CPPLINT_ARG_LINELENGTH} ${PROJECT_SOURCE_DIR}/${SQLITECPP_SRC}
)
endif()
option(SQLITECPP_RUN_CPPCHECK "Run cppcheck C++ static analysis tool." ON)
if (SQLITECPP_RUN_CPPCHECK)
# add a cppcheck target to the "all" target
add_custom_target(SQLiteCpp_cppcheck
ALL
COMMAND cppcheck -j 4 cppcheck --enable=style --quiet ${CPPCHECK_ARG_TEMPLATE} ${PROJECT_SOURCE_DIR}/src
)
endif()
option(SQLITECPP_RUN_DOXYGEN "Run Doxygen C++ documentation tool." ON)
if (SQLITECPP_RUN_DOXYGEN)
# add a Doxygen target to the "all" target
add_custom_target(SQLiteCpp_doxygen
ALL
COMMAND doxygen Doxyfile > ${DEV_NULL}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
) )
endif()
################################################################################ option(SQLITECPP_RUN_TESTS "Run test tools." ON)
# add the subdirectory containing the CMakeLists.txt of the wrapper library if (SQLITECPP_RUN_TESTS)
add_subdirectory (src)
include_directories ("${PROJECT_SOURCE_DIR}/src")
################################################################################
# add the example1 executable, linked with the wrapper library # add the example1 executable, linked with the wrapper library
add_executable(example1 examples/example1/main.cpp) add_executable(example1 examples/example1/main.cpp)
target_link_libraries(example1 SQLiteCpp sqlite3) target_link_libraries(example1 SQLiteCpp sqlite3)
@ -50,5 +109,6 @@ target_link_libraries (example1 SQLiteCpp sqlite3)
# add a "test" target: # add a "test" target:
enable_testing() enable_testing()
# does the example1 runs successfully # does the example1 runs successfully?
add_test(Example1Run example1) add_test(Example1Run example1)
endif()

4791
cpplint.py vendored Executable file

File diff suppressed because it is too large Load Diff

View File

@ -14,7 +14,7 @@
/** /**
* @def SQLITECPP_ASSERT SQLITECPP_ASSERT() is used in destructors, where exceptions shall not be thrown * SQLITECPP_ASSERT SQLITECPP_ASSERT() is used in destructors, where exceptions shall not be thrown
* *
* Define SQLITECPP_ENABLE_ASSERT_HANDLER at the project level * Define SQLITECPP_ENABLE_ASSERT_HANDLER at the project level
* and define a SQLite::assertion_failed() assertion handler * and define a SQLite::assertion_failed() assertion handler

View File

@ -1,28 +0,0 @@
# CMake file for compiling the wrapper static library itself.
#
# This allow for easy use of SQLiteC++ as a Git submodule;
# simply use add_subdirectory (SQLiteCpp/src) into your main CMakeLists.txt file,
# and link to the "SQLiteCpp" library
#
# Copyright (c) 2013 Sebastien Rombauts (sebastien.rombauts@gmail.com)
#
# Distributed under the MIT License (MIT) (See accompanying file LICENSE.txt
# or copy at http://opensource.org/licenses/MIT)
# add sources of the wrapper as a "SQLiteCpp" static library
add_library (SQLiteCpp
SQLiteC++.h
Assertion.h
Column.cpp
Column.h
Database.cpp
Database.h
Exception.h
Statement.cpp
Statement.h
Transaction.cpp
Transaction.h
)
if(UNIX AND (CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"))
set_target_properties(SQLiteCpp PROPERTIES COMPILE_FLAGS "-fPIC")
endif(UNIX AND (CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang"))

View File

@ -256,7 +256,7 @@ public:
void (*apFunc)(sqlite3_context *, int, sqlite3_value **), void (*apFunc)(sqlite3_context *, int, sqlite3_value **),
void (*apStep)(sqlite3_context *, int, sqlite3_value **), void (*apStep)(sqlite3_context *, int, sqlite3_value **),
void (*apFinal)(sqlite3_context *), void (*apFinal)(sqlite3_context *),
void (*axDestroy)(void *)); void (*apDestroy)(void *));
/** /**
* @brief Create or redefine a SQL function or aggregate in the sqlite database. * @brief Create or redefine a SQL function or aggregate in the sqlite database.