How can I link CMake and SQLite without an external script?
You have basically two options:
1) have a FindSQLite3.cmake
in a directory called cmake
inside your project's root directory like the following FindSQLite3.cmake
that you already tried but you need to have something like the following
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) since you know the location of your sqlite3 include directory and library you could directly set the path to those, in your CMakeLists.txt
you will have something like link_directories()
and include_directories()
, e.g. you will have the following lines:
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)
Something along those two directions should work.
Personally, I would suggest the first approach.