From d75c7a9449ab8fba5f549a530f3b03cd26ec3515 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Rombauts?= Date: Sun, 1 Sep 2013 17:00:14 +0200 Subject: [PATCH] Added a proper "src/CMakeLists.txt" file defining the static library. - This enable using this SQLiteCpp repository as a Git submodule, - simply add_subdirectory (SQLiteCpp/src) to you main CMakeLists.txt and link to the "SQLiteCpp" wrapper library. --- .gitignore | 5 +++++ CMakeLists.txt | 45 +++++++++++++++++++++++---------------------- README.md | 6 +++++- TODO.txt | 2 ++ src/CMakeLists.txt | 24 ++++++++++++++++++++++++ 5 files changed, 59 insertions(+), 23 deletions(-) create mode 100644 src/CMakeLists.txt diff --git a/.gitignore b/.gitignore index 29daa80..416476d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ Debug Release build +/SQLiteCpp.sln *.ncb *.suo *.user @@ -14,4 +15,8 @@ core .settings/ CMakeCache.txt +CMakeFiles *.cmake +*.dir +Testing +Win32 diff --git a/CMakeLists.txt b/CMakeLists.txt index e2b3175..36164ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,35 +1,36 @@ +# Main CMake file compiling the library itself, examples and tests. +# +# Copyright (c) 2012-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) + cmake_minimum_required (VERSION 2.6) project (SQLiteCpp) -if(MSVC) +if (MSVC) + # build the SQLite3 C library for windows build (for ease of use) include_directories ("${PROJECT_SOURCE_DIR}/sqlite3") add_library (sqlite3 sqlite3/sqlite3.c sqlite3/sqlite3.h) -elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) - 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 -Wsuggest-attribute=noreturn) -endif() + # disable Visual Studio warnings for fopen() used in the example + add_definitions (/D_CRT_SECURE_NO_WARNINGS) +elseif (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) + # 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 -Wsuggest-attribute=noreturn) +endif () -# add the wrapper as a library -add_library(SQLiteCpp - src/SQLiteC++.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 the subdirectory containing the CMakeLists.txt of the library +add_subdirectory (src) +include_directories ("${PROJECT_SOURCE_DIR}/src") +################################################################################ -# add the exemple1 executable, linked with the wrapper library -add_executable(example1 examples/example1/main.cpp) +# add the example1 executable, linked with the wrapper library +add_executable (example1 examples/example1/main.cpp) target_link_libraries (example1 SQLiteCpp sqlite3) # add a "test" target: -enable_testing() +enable_testing () # does the example1 runs successfully add_test (Example1Run example1) - - diff --git a/README.md b/README.md index f9d3636..a9c33f0 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,11 @@ in a custom shared pointer (See the inner class "Statement::Ptr"). To use this wrappers, you need to add the 10 SQLiteC++ source files from the src/ directory in your project code base, and compile/link against the sqlite library. -You can also build the wrapper as a library; this is how CMake link the examples. +The easiest way to do this is to add the wrapper as a library. +The proper "CMakeLists.txt" file defining the static library is provided in the src/ subdirectory, +so you simply have to add_directory(SQLiteCpp/src) to you main CMakeLists.txt +and link to the "SQLiteCpp" wrapper library. +Thus this SQLiteCpp repository can directly be used as a Git submoldule. ### Building the examples: diff --git a/TODO.txt b/TODO.txt index 176d27d..a76c9cc 100644 --- a/TODO.txt +++ b/TODO.txt @@ -1,3 +1,5 @@ +Create a "SQLiteCppExample" repository using the wrapper as a Git submodule. + Check C++11 explicit support Add a FAQ.txt diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..c89e3b7 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,24 @@ +# 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 + Column.cpp + Column.h + Database.cpp + Database.h + Exception.h + Statement.cpp + Statement.h + Transaction.cpp + Transaction.h +)