Skip to content

CMake fails on Ubuntu #276

Closed
Closed

Description

@travishaagen

Using Ubuntu 19 (on arm64), I have no trouble compiling SQLiteCpp, but my own CMake configuration fails with the following error:

CMake Error at /usr/share/cmake-3.13/Modules/CMakeFindDependencyMacro.cmake:48 (find_package):
  By not providing "FindSQLite3.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "SQLite3", but
  CMake did not find one.

  Could not find a package configuration file provided by "SQLite3" with any
  of the following names:

    SQLite3Config.cmake
    sqlite3-config.cmake

  Add the installation prefix of "SQLite3" to CMAKE_PREFIX_PATH or set
  "SQLite3_DIR" to a directory containing one of the above files.  If
  "SQLite3" provides a separate development package or SDK, be sure it has
  been installed.
Call Stack (most recent call first):
  /usr/local/lib/cmake/SQLiteCpp/SQLiteCppConfig.cmake:2 (find_dependency)
  CMakeLists.txt:50 (find_package)

I'm guessing that since SQLiteCppConfig.cmake contains the line find_dependency(SQLite3) that it is telling CMake that either SQLite3Config.cmake or sqlite3-config.cmake exist on system. However, it looks like this Ubuntu issue is stating that these files are not currently installed:

https://bugs.launchpad.net/ubuntu/+source/sqlite3/+bug/1868166

I had thought that when cmake -DSQLITECPP_INTERNAL_SQLITE=ON .. is used, that it might make everything work for me, so perhaps this config option could be checked for in https://github.com/SRombauts/SQLiteCpp/blob/master/cmake/SQLiteCppConfig.cmake.in to stop the execution of find_dependency(SQLite3).

Activity

  1. travishaagen commented on Apr 5, 2020

    @travishaagen
    Author

    On another note, I have been compiling on Mac and Alpine Linux prior to trying Ubuntu and ran into other CMake issues with SQLite3. I found the following that seemed to work:

    find_library(SQLITE3_LIB libsqlite3.a sqlite3)
    if (NOT SQLITE3_LIB)
        message(FATAL_ERROR "sqlite3 library not found")
    endif ()
    

    then

    target_link_libraries(app
        PRIVATE
            ${SQLITE3_LIB}
    )
    

    Reference: https://visualgdb.com/tutorials/linux/cmake/target_link_libraries/

  2. self-assigned this
    on Apr 5, 2020
  3. SRombauts commented on Apr 5, 2020

    @SRombauts
    Owner

    Oh yes I see, I think that SQLiteCppConfig doesn't work with/has not been thought for use with the Internal SQLite3

    Out of curiosity, Have you checked if I am using/testing it in https://github.com/SRombauts/SQLiteCpp Example ?
    Sorry I am not in front of a computer

    Are you able to patch it for your needs ?

    Edit: actually, I thought that I had put aFindSQLite3.cmake in the cmake subdir

    Cheers !

  4. travishaagen commented on Apr 11, 2020

    @travishaagen
    Author

    I can make it work by commenting out the second line in the installed file:

    $ more /usr/local/lib/cmake/SQLiteCpp/SQLiteCppConfig.cmake
    include(CMakeFindDependencyMacro)
    #find_dependency(SQLite3)
    ...
    

    I think the problem is that find_dependency(SQLite3) tells CMake to look for either SQLite3Config.cmake or sqlite3-config.cmake, but since they do not exist, then it fails.

    Is the call to find_dependency(SQLite3) in SQLiteCppConfig.cmake.in just a sanity check to make sure the dependency of SQLite3 is installed?

    I am not a CMake expert, but the following might work and still preserve the existing behavior:

    find_library(SQLITE3_LIB libsqlite3.a sqlite3)
    if (NOT SQLITE3_LIB)
        # sqlite3 library not found, so look for SQLite3Config.cmake or sqlite3-config.cmake
        find_dependency(SQLite3)
    endif ()
    
  5. sum01 commented on May 16, 2020

    @sum01
    Contributor

    The call to find_dependency(SQLite3)
    is necessary if there is public linkage to SQLite3 to the library. This is how you propagate public dependencies automatically for anyone using your library.

    What's going wrong is that the FindSQLite3 (official) module isn't in Cmake until version 3.14, while you're on Cmake version 3.13, but the find_dependency call is trying to use an official module.

    A potential solution here would be to install the project's unofficial FindSQLite3 module so it can be added to the module path before calling find_dependency(SQLite3).

    All that being said, I don't believe SQLite3 is actually a public dependency, no? All the installed headers have zero #include <sqlite3.h> anywhere to be found.
    If that's actually the case, then the call to find_dependency(SQLite3) could be removed, and all calls to target_link_libraries(SQLiteCpp PUBLIC SQLite::SQLite3) should be made PRIVATE.

  6. nidefawl commented on Feb 22, 2022

    @nidefawl

    find_dependency(SQLite3 REQUIRED)

    Should be updated to

    if(NOT @SQLITECPP_INTERNAL_SQLITE@)
        find_dependency(SQLite3 REQUIRED)
    endif()
    
  7. joenano commented on Sep 20, 2022

    @joenano

    This seems like a great library, shame its an absolute nightmare trying to use it.

    Instructions say

    "you can comment out the following line in src/Column.h:

    #define SQLITE_ENABLE_COLUMN_METADATA"

    but the line doesnt exist

  8. SRombauts commented on Sep 30, 2022

    @SRombauts
    Owner

    @joenano I updated the README to say to

    turn off the option(SQLITE_ENABLE_COLUMN_METADATA "Enable Column::getColumnOriginName(). Require support from sqlite3 library." ON) in [CMakeFiles.txt](https://github.com/SRombauts/SQLiteCpp/blob/master/CMakeFiles.txt)

  9. SRombauts commented on Sep 30, 2022

    @SRombauts
    Owner

    Hello, this should be finally fixed by the merge of #277

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions