使用vs community 2019 x86 编译
安装包
vcpkg install sqlite3:x86-windows
CMakeLists.txt
# CMake 最低版本号要求
cmake_minimum_required (VERSION 3.16)
SET(DCMAKE_TOOLCHAIN_FILE "E:/usr/vcpkg-master_0107/vcpkg-master/scripts/buildsystems/vcpkg.cmake")
# 没加这行折腾半天
include("E:/usr/vcpkg-master_0107/vcpkg-master/scripts/buildsystems/vcpkg.cmake")
# 项目信息
project (cmakeclang)
find_package(sqlite3 CONFIG REQUIRED)
# 查找当前目录下的所有源文件
# 并将名称保存到 DIR_SRCS 变量
aux_source_directory(. DIR_SRCS)
# 指定生成目标
add_executable(cmakeclang ${DIR_SRCS})
target_link_libraries(cmakeclang PRIVATE sqlite3)
main.cpp
#include <iostream>
#include <sqlite3.h>
using namespace std;
int main()
{
printf("%s\n", sqlite3_libversion());
cout << "Hello, world!" << endl;
return 0;
}
|