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.
This commit is contained in:
Sébastien Rombauts 2013-09-01 17:00:14 +02:00
parent a8b471e7ed
commit d75c7a9449
5 changed files with 59 additions and 23 deletions

5
.gitignore vendored
View File

@ -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

View File

@ -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)

View File

@ -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:

View File

@ -1,3 +1,5 @@
Create a "SQLiteCppExample" repository using the wrapper as a Git submodule.
Check C++11 explicit support
Add a FAQ.txt

24
src/CMakeLists.txt Normal file
View File

@ -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
)