Skip to content

Commit f732569

Browse files
authored
Merge pull request #228 from BioDataAnalysis/emmenlau_cmake_add_transitive_compile_definitions
CMakeLists.txt: use transitive compile definitions via cmake
2 parents 69c35d0 + 24564cf commit f732569

File tree

3 files changed

+28
-23
lines changed

3 files changed

+28
-23
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ before_install:
244244
before_script:
245245
- mkdir build
246246
- cd build
247-
- cmake -DCMAKE_BUILD_TYPE=Debug -DSQLITECPP_USE_ASAN=ON -DSQLITECPP_USE_GCOV=ON -DSQLITECPP_BUILD_EXAMPLES=ON -DSQLITECPP_BUILD_TESTS=ON ..
247+
- cmake -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=Debug -DSQLITECPP_USE_ASAN=ON -DSQLITECPP_USE_GCOV=ON -DSQLITECPP_BUILD_EXAMPLES=ON -DSQLITECPP_BUILD_TESTS=ON ..
248248

249249
# build examples, and run tests (ie make & make test)
250250
script:

CMakeLists.txt

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -85,28 +85,6 @@ else (NOT MSVC)
8585
endif ()
8686
endif ()
8787

88-
# Options relative to SQLite and SQLiteC++ functions
89-
90-
option(SQLITE_ENABLE_COLUMN_METADATA "Enable Column::getColumnOriginName(). Require support from sqlite3 library." ON)
91-
if (SQLITE_ENABLE_COLUMN_METADATA)
92-
# Enable the use of SQLite column metadata and Column::getColumnOriginName() method,
93-
# Require that the sqlite3 library is also compiled with this flag (default under Debian/Ubuntu, but not on Mac OS X).
94-
add_definitions(-DSQLITE_ENABLE_COLUMN_METADATA)
95-
endif (SQLITE_ENABLE_COLUMN_METADATA)
96-
97-
option(SQLITE_ENABLE_ASSERT_HANDLER "Enable the user defintion of a assertion_failed() handler." OFF)
98-
if (SQLITE_ENABLE_ASSERT_HANDLER)
99-
# Enable the user defintion of a assertion_failed() handler (default to false, easier to handler for begginers).
100-
add_definitions(-DSQLITECPP_ENABLE_ASSERT_HANDLER)
101-
endif (SQLITE_ENABLE_ASSERT_HANDLER)
102-
103-
option(SQLITE_USE_LEGACY_STRUCT "Fallback to forward declaration of legacy struct sqlite3_value (pre SQLite 3.19)" OFF)
104-
if (SQLITE_USE_LEGACY_STRUCT)
105-
# Force forward declaration of legacy struct sqlite3_value (pre SQLite 3.19)
106-
add_definitions(-DSQLITE_USE_LEGACY_STRUCT)
107-
endif (SQLITE_USE_LEGACY_STRUCT)
108-
109-
11088
## Build the C++ Wrapper ##
11189

11290
# adding a new file require explicittly modifing the CMakeLists.txt
@@ -188,6 +166,27 @@ add_library(SQLiteCpp ${SQLITECPP_SRC} ${SQLITECPP_INC} ${SQLITECPP_DOC} ${SQLIT
188166
# PR https://github.com/SRombauts/SQLiteCpp/pull/111 "linked SQLiteCpp to sqlite3" commented out since it breaks install step from PR #118
189167
#target_link_libraries(SQLiteCpp PUBLIC sqlite3)
190168

169+
# Options relative to SQLite and SQLiteC++ functions
170+
171+
option(SQLITE_ENABLE_COLUMN_METADATA "Enable Column::getColumnOriginName(). Require support from sqlite3 library." ON)
172+
if (SQLITE_ENABLE_COLUMN_METADATA)
173+
# Enable the use of SQLite column metadata and Column::getColumnOriginName() method,
174+
# Require that the sqlite3 library is also compiled with this flag (default under Debian/Ubuntu, but not on Mac OS X).
175+
target_compile_definitions(SQLiteCpp PUBLIC SQLITE_ENABLE_COLUMN_METADATA)
176+
endif (SQLITE_ENABLE_COLUMN_METADATA)
177+
178+
option(SQLITE_ENABLE_ASSERT_HANDLER "Enable the user defintion of a assertion_failed() handler." OFF)
179+
if (SQLITE_ENABLE_ASSERT_HANDLER)
180+
# Enable the user defintion of a assertion_failed() handler (default to false, easier to handler for begginers).
181+
target_compile_definitions(SQLiteCpp PUBLIC SQLITECPP_ENABLE_ASSERT_HANDLER)
182+
endif (SQLITE_ENABLE_ASSERT_HANDLER)
183+
184+
option(SQLITE_USE_LEGACY_STRUCT "Fallback to forward declaration of legacy struct sqlite3_value (pre SQLite 3.19)" OFF)
185+
if (SQLITE_USE_LEGACY_STRUCT)
186+
# Force forward declaration of legacy struct sqlite3_value (pre SQLite 3.19)
187+
target_compile_definitions(SQLiteCpp PUBLIC SQLITE_USE_LEGACY_STRUCT)
188+
endif (SQLITE_USE_LEGACY_STRUCT)
189+
191190
if (UNIX AND (CMAKE_COMPILER_IS_GNUCXX OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang"))
192191
set_target_properties(SQLiteCpp PROPERTIES COMPILE_FLAGS "-fPIC")
193192
endif (UNIX AND (CMAKE_COMPILER_IS_GNUCXX OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang"))

sqlite3/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ add_library(sqlite3
1111
sqlite3.h
1212
)
1313

14+
if (SQLITE_ENABLE_COLUMN_METADATA)
15+
# Enable the use of SQLite column metadata method
16+
# Require that the sqlite3 library is also compiled with this flag:
17+
target_compile_definitions(sqlite3 PUBLIC SQLITE_ENABLE_COLUMN_METADATA)
18+
endif (SQLITE_ENABLE_COLUMN_METADATA)
19+
1420
if (UNIX AND (CMAKE_COMPILER_IS_GNUCXX OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang"))
1521
set_target_properties(sqlite3 PROPERTIES COMPILE_FLAGS "-fPIC")
1622
endif (UNIX AND (CMAKE_COMPILER_IS_GNUCXX OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang"))

0 commit comments

Comments
 (0)