SQLiteCpp icon indicating copy to clipboard operation
SQLiteCpp copied to clipboard

Added cmake variables to make submoduling the project easier

Open abelmul opened this issue 5 years ago • 4 comments

That explains it

abelmul avatar May 31 '20 16:05 abelmul

Coverage Status

Coverage remained the same at 100.0% when pulling ce44286e96bcbba4c3b49f8f93d5a6f35bd65aa8 on abelmul:master into f0cd9e35864b173ef519f9fdba91a731ad94a28d on SRombauts:master.

coveralls avatar May 31 '20 16:05 coveralls

Hello, thanks for this proposal.

I think that what you should do here is use the provided Find SQLiteCpp cmake file instead, no? find_package(SQLiteCpp 3 REQUIRED)

Cheers

SRombauts avatar Jun 01 '20 07:06 SRombauts

To quote the readme file in order to submodule and add this library you have to do

add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/thirdparty/SQLiteCpp)

include_directories(
  ${CMAKE_CURRENT_LIST_DIR}/thirdparty/SQLiteCpp/include
)

add_executable(main src/main.cpp)
target_link_libraries(main
  SQLiteCpp
  sqlite3
  pthread
  dl
  )

With this pull request you can do

add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/thirdparty/SQLiteCpp)

include_directories(${SQLITECPP_INCLUDE_DIRS})
add_executable(main src/main.cpp)
target_link_libraries(main ${SQLITECPP_LIBRARIES)

I think it keeps application code clean.

abelmul avatar Jun 01 '20 20:06 abelmul

If linking multiple libraries is required then that hints at the fact that the SQLiteCpp target is missing some PUBLIC dependencies. That's the modern CMake solution and is preferable to the old school approach of having LIBNAME_INCLUDE_DIRS and LIBNAME_LIBRARIES variables.

ChrisThrasher avatar May 17 '23 19:05 ChrisThrasher