Fix include scoping issues with sqlite3

This commit is contained in:
Peter Bell 2020-05-08 12:21:35 +01:00
parent a5e1c70883
commit 7cfe26ee9f
2 changed files with 6 additions and 11 deletions

View File

@ -225,7 +225,7 @@ if (SQLITECPP_INTERNAL_SQLITE)
message(STATUS "Compile sqlite3 from source in subdirectory") message(STATUS "Compile sqlite3 from source in subdirectory")
# build the SQLite3 C library (for ease of use/compatibility) versus Linux sqlite3-dev package # build the SQLite3 C library (for ease of use/compatibility) versus Linux sqlite3-dev package
add_subdirectory(sqlite3) add_subdirectory(sqlite3)
target_link_libraries(SQLiteCpp PUBLIC sqlite3) target_link_libraries(SQLiteCpp PUBLIC SQLite::SQLite3)
else (SQLITECPP_INTERNAL_SQLITE) else (SQLITECPP_INTERNAL_SQLITE)
find_package (SQLite3 REQUIRED) find_package (SQLite3 REQUIRED)
message(STATUS "Link to sqlite3 system library") message(STATUS "Link to sqlite3 system library")
@ -245,8 +245,6 @@ endif (UNIX)
# Set includes for target and transitive downstream targets # Set includes for target and transitive downstream targets
target_include_directories(SQLiteCpp target_include_directories(SQLiteCpp
PRIVATE
$<$<BOOL:${SQLITECPP_INTERNAL_SQLITE}>:${CMAKE_CURRENT_SOURCE_DIR}/sqlite3>
PUBLIC PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/>) $<INSTALL_INTERFACE:include/>)
@ -330,9 +328,6 @@ if (SQLITECPP_BUILD_EXAMPLES)
# add the basic example executable # add the basic example executable
add_executable(SQLiteCpp_example1 ${SQLITECPP_EXAMPLES}) add_executable(SQLiteCpp_example1 ${SQLITECPP_EXAMPLES})
target_link_libraries(SQLiteCpp_example1 SQLiteCpp) target_link_libraries(SQLiteCpp_example1 SQLiteCpp)
target_include_directories(SQLiteCpp_example1 PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include
$<$<BOOL:${SQLITECPP_INTERNAL_SQLITE}>:${CMAKE_CURRENT_SOURCE_DIR}/sqlite3>)
if (MSYS OR MINGW) if (MSYS OR MINGW)
target_link_libraries(SQLiteCpp_example1 ssp) target_link_libraries(SQLiteCpp_example1 ssp)
endif () endif ()
@ -345,9 +340,6 @@ if (SQLITECPP_BUILD_TESTS)
# add the unit test executable # add the unit test executable
add_executable(SQLiteCpp_tests ${SQLITECPP_TESTS}) add_executable(SQLiteCpp_tests ${SQLITECPP_TESTS})
target_link_libraries(SQLiteCpp_tests SQLiteCpp) target_link_libraries(SQLiteCpp_tests SQLiteCpp)
target_include_directories(SQLiteCpp_tests PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include
$<$<BOOL:${SQLITECPP_INTERNAL_SQLITE}>:${CMAKE_CURRENT_SOURCE_DIR}/sqlite3>)
find_package(GTest) find_package(GTest)
if (GTEST_FOUND) if (GTEST_FOUND)

View File

@ -11,9 +11,12 @@ add_library(sqlite3
sqlite3.h sqlite3.h
) )
add_library(SQLite::SQLite3 ALIAS sqlite3)
target_include_directories(sqlite3 target_include_directories(sqlite3
PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> PUBLIC
PUBLIC $<INSTALL_INTERFACE:include/>) $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include/>)
if (SQLITE_ENABLE_COLUMN_METADATA) if (SQLITE_ENABLE_COLUMN_METADATA)
# Enable the use of SQLite column metadata method # Enable the use of SQLite column metadata method