我有一个C ++项目,我想在它上面使用sqlite3。我正在使用CMake构建并向CMakeLists.txt添加一些行,这里是:
project(Test)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_BUILD_TYPE Debug)
cmake_minimum_required(VERSION 2.8)
aux_source_directory(. SRC_LIST)
add_executable(${PROJECT_NAME} ${SRC_LIST})
set(CMAKE_CXX_FLAGS_DEBUG "-g")
find_path(SQLITE3_INCLUDE_DIR sqlite3.h)
find_library(SQLITE3_LIBRARY sqlite3)
if(NOT SQLITE3_INCLUDE_DIR)
message(SEND_ERROR "Failed to find sqlite3")
endif()
if(NOT SQLITE3_LIBRARY)
message(SEND_ERROR "Failed to find the sqlite3 library")
endif()
当我想朗读cmake命令时,它会让我Failed to find sqlite3
和Failed to find the sqlite3 library
找到它。
我正在使用ubuntu + qtcreator和我安装的sqlite3版本:
> sqlite3 --version
3.8.2 2013-12-06 14:53:30 27392018af4c38cc203a04b8013e2afdb1cebd0d
感谢所有......!
答案 0 :(得分:0)
这是一个大多数工作的例子,即我已经删除了无关紧要的东西cmake ......
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/sqlite3/)
set(sqlite3_srcs
${CMAKE_CURRENT_SOURCE_DIR}/sqlite3/sqlite3.c
${CMAKE_CURRENT_SOURCE_DIR}/sqlite3/sqlite3.h
)
....
add_library(mylib SHARED
${sqlite3_srcs}
)
target_link_libraries(foooo mylib)