@@ -12,18 +12,8 @@ project(SQLiteCpp)
1212# Define useful variables to handle OS differences:
1313if (WIN32 )
1414 set (DEV_NULL "NUL" )
15- # build the SQLite3 C library for Windows (for ease of use)
16- set (SQLITECPP_INTERNAL_SQLITE_DEFAULT ON )
17- set (SQLITE_ENABLE_COLUMN_METADATA_DEFAULT ON )
1815else (WIN32 ) # UNIX
1916 set (DEV_NULL "/dev/null" )
20- # do not build the SQLite3 C library, but uses the Linux/Mac OS X sqlite3-dev package
21- set (SQLITECPP_INTERNAL_SQLITE_DEFAULT OFF )
22- if (APPLE )
23- set (SQLITE_ENABLE_COLUMN_METADATA_DEFAULT OFF )
24- else (APPLE )
25- set (SQLITE_ENABLE_COLUMN_METADATA_DEFAULT ON )
26- endif (APPLE )
2717endif (WIN32 )
2818
2919# then Compiler/IDE differences:
@@ -40,10 +30,11 @@ if (MSVC)
4030else (MSVC )
4131 set (CPPLINT_ARG_OUTPUT "--output=eclipse" )
4232 set (CPPCHECK_ARG_TEMPLATE "--template=gcc" )
33+ # Useful compile flags and extra warnings
34+ #add_compile_options() is not supported with CMake 2.8.7 of Ubuntu 12.04 on Travis-CI
35+ add_definitions (-fstack-protector -Wall -Winit-self -Wswitch-enum -Wshadow -Winline)
4336 if (CMAKE_COMPILER_IS_GNUCXX)
4437 # GCC flags
45- #add_compile_options() is not supported with CMake 2.8.7 of Ubuntu 12.04 on Travis-CI
46- add_definitions (-rdynamic -fstack-protector-all -Wall -Wextra -pedantic -Wformat-security -Winit-self -Wswitch-default -Wswitch-enum -Wfloat-equal -Wshadow -Wcast-qual -Wconversion -Wlogical-op -Winline)
4738 if (SQLITECPP_USE_GCOV AND CMAKE_COMPILER_IS_GNUCXX)
4839 if (CMAKE_BUILD_TYPE STREQUAL "Debug" )
4940 message (STATUS "Using GCov instrumentation" )
@@ -53,9 +44,6 @@ else (MSVC)
5344 add_definitions (-fprofile-arcs -ftest-coverage)
5445 set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage" )
5546 endif ()
56- elseif ("${CMAKE_CXX_COMPILER_ID} " STREQUAL "Clang" )
57- # Clang flags
58- add_definitions (-fstack-protector-all -Wall -Wextra -pedantic -Wformat-security -Winit-self -Wswitch-default -Wswitch-enum -Wfloat-equal -Wshadow -Wcast-qual -Wconversion -Winline)
5947 endif (CMAKE_COMPILER_IS_GNUCXX)
6048endif (MSVC )
6149# and then common variables
@@ -65,7 +53,7 @@ set(CPPLINT_ARG_LINELENGTH "--linelength=120")
6553
6654# Options relative to SQLite and SQLiteC++ functions
6755
68- option (SQLITE_ENABLE_COLUMN_METADATA "Enable Column::getName(). Require support from sqlite3 library." ${SQLITE_ENABLE_COLUMN_METADATA_DEFAULT} )
56+ option (SQLITE_ENABLE_COLUMN_METADATA "Enable Column::getName(). Require support from sqlite3 library." ON )
6957if (SQLITE_ENABLE_COLUMN_METADATA)
7058 # Enable the use of SQLite column metadata and Column::getName() method,
7159 # Require that the sqlite3 library is also compiled with this flag (default under Debian/Ubuntu, but not on Mac OS X).
@@ -79,7 +67,7 @@ if (SQLITE_ENABLE_ASSERT_HANDLER)
7967endif (SQLITE_ENABLE_ASSERT_HANDLER)
8068
8169
82- ## Core source code ##
70+ ## Build the C++ Wrapper ##
8371
8472# adding a new file require explicittly modifing the CMakeLists.txt
8573# so that CMake knows that it should rebuild the project (it is best practice)
@@ -155,11 +143,11 @@ if (UNIX AND (CMAKE_COMPILER_IS_GNUCXX OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Cla
155143endif (UNIX AND (CMAKE_COMPILER_IS_GNUCXX OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" ))
156144
157145
158- # SQLite3 library (mostly usefull under Windows)
146+ ## Build provided copy of SQLite3 C library ##
159147
160- option (SQLITECPP_INTERNAL_SQLITE "Add the internal SQLite3 source to the project." ${SQLITECPP_INTERNAL_SQLITE_DEFAULT} )
148+ option (SQLITECPP_INTERNAL_SQLITE "Add the internal SQLite3 source to the project." ON )
161149if (SQLITECPP_INTERNAL_SQLITE)
162- # build the SQLite3 C library for Windows (for ease of use) versus Linux sqlite3-dev package
150+ # build the SQLite3 C library (for ease of use/compatibility ) versus Linux sqlite3-dev package
163151 add_subdirectory (sqlite3)
164152 include_directories ("${PROJECT_SOURCE_DIR} /sqlite3" )
165153endif (SQLITECPP_INTERNAL_SQLITE)
@@ -218,6 +206,13 @@ if (SQLITECPP_BUILD_EXAMPLES)
218206 # add the basic example executable
219207 add_executable (SQLiteCpp_example1 ${SQLITECPP_EXAMPLES} )
220208 target_link_libraries (SQLiteCpp_example1 SQLiteCpp sqlite3)
209+ # Link target with pthread and dl for linux
210+ if (UNIX )
211+ target_link_libraries (SQLiteCpp_example1 pthread)
212+ if (NOT APPLE )
213+ target_link_libraries (SQLiteCpp_example1 dl)
214+ endif ()
215+ endif ()
221216else (SQLITECPP_BUILD_EXAMPLES)
222217 message (STATUS "SQLITECPP_BUILD_EXAMPLES OFF" )
223218endif (SQLITECPP_BUILD_EXAMPLES)
@@ -238,6 +233,10 @@ if (SQLITECPP_BUILD_TESTS)
238233 # add the unit test executable
239234 add_executable (SQLiteCpp_tests ${SQLITECPP_TESTS} )
240235 target_link_libraries (SQLiteCpp_tests gtest_main SQLiteCpp sqlite3)
236+ # Link target with dl for linux
237+ if (UNIX AND NOT APPLE )
238+ target_link_libraries (SQLiteCpp_tests dl)
239+ endif ()
241240
242241 # add a "test" target:
243242 enable_testing ()
@@ -261,7 +260,7 @@ else (NOT BIICODE)
261260 # Include base block dir
262261 ADD_BIICODE_TARGETS()
263262
264- # Link target with dl for linux
263+ # Link target with pthread and dl for linux
265264 if (UNIX )
266265 target_link_libraries (${BII_BLOCK_TARGET} INTERFACE pthread)
267266 if (NOT APPLE )
0 commit comments