How can I bind CMake and SQLite without an external script?

I have the following CMakeLists:

cmake_minimum_required (VERSION 2.8.12.2)
project (Tutorial)
find_package (sqlite3)
if (SQLITE3_FOUND)
  include_directories(${SQLITE3_INCLUDE_DIRS})
  target_link_libraries (new ${SQLITE3_LIBRARIES})
endif (SQLITE3_FOUND)
add_executable(Tutorial new.cpp)

However, when I cmake, I get the following message:

CMake Warning at CMakeLists.txt:3 (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.

I also tried this and this for alternate CMakeLists files, but none of them worked.

I also tried this and it did not work:

FIND_PATH(SQLITE3_INCLUDE_DIR NAMES sqlite3.h)
FIND_LIBRARY(SQLITE3_LIBRARY NAMES sqlite)
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SQLITE3 DEFAULT_MSG SQLITE3_LIBRARY SQLITE3_INCLUDE_DIR)
IF(SQLITE3_FOUND)
    SET(SQLITE3_LIBRARIES ${SQLITE3_LIBRARY})
    SET(SQLITE3_INCLUDE_DIRS ${SQLITE3_INCLUDE_DIR})
ELSE(SQLITE3_FOUND)
    SET(SQLITE3_LIBRARIES)
    SET(SQLITE3_INCLUDE_DIRS)
ENDIF(SQLITE3_FOUND)

MARK_AS_ADVANCED(SQLITE3_INCLUDE_DIRS SQLITE3_LIBRARIES)

How to bind SQLite without using the extension?

Thank!

+4
source share
2 answers

:
1) FindSQLite3.cmake cmake , : FindSQLite3.cmake , -

cmake_minimum_required (VERSION 2.8.12.2)
project (Tutorial)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
add_executable(tutorial new.cpp)
find_package (SQLite3)
if (SQLITE3_FOUND)
  include_directories(${SQLITE3_INCLUDE_DIRS})
  target_link_libraries (tutorial ${SQLITE3_LIBRARIES})
endif (SQLITE3_FOUND)

2) sqlite3 include, , CMakeLists.txt - link_directories() include_directories(), , :

cmake_minimum_required (VERSION 2.8.12.2)
project (Tutorial)
add_executable(tutorial new.cpp)
include_directories(/usr/include)
link_directories(/usr/lib)
target_link_libraries(tutorial sqlite3)

- .
.

+6

CMakeLists.txt, .

find_package (SQLite3)

include_directories(${SQLite3_INCLUDE_DIRS})
target_link_libraries (${OUT_TARGET} ${SQLite3_LIBRARIES})

cmake 3.14.3

0

Source: https://habr.com/ru/post/1666740/


All Articles