- 发现有些包cvpkg中没有(比如字典树),conan里有。
安装conan
- https://conan.io/downloads
配置conan
PS C:\Users\multisim> conan config home
C:\Users\multisim\.conan2 # Conan 主文件夹的路径,https://docs.conan.io/2/reference/commands/config.html
- 自动检测大概配置
PS C:\Users\multisim\.conan2> conan profile detect
- 在项目中创建
conanfile.txt
,并根据https://conan.io/center/recipes/tsl-hat-trie?version=0.6.0的指示添加配置项目:
[requires]
tsl-hat-trie/0.6.0
[generators]
CMakeDeps
CMakeToolchain
[layout]
cmake_layout
conan install . # there is a conanfile.txt or a conanfile.py in the cwd https://docs.conan.io/2/reference/commands/install.html
- 运行后会生成build的配置文件(资源文件在conan config home目录):
构建项目
- CMakLists.txt文件
cmake_minimum_required(VERSION 3.15)
project(Foo)
find_package(tsl-hat-trie REQUIRED)
add_executable(Foo CMakeProject4.cpp)
target_link_libraries(Foo tsl::hat_trie)
PS C:\Users\multisim\source\repos\CMakeProject4\build> cmake .. -G "Visual Studio 17 2022" -DCMAKE_TOOLCHAIN_FILE="./generators/conan_toolchain.cmake"
-- Using Conan toolchain: C:/Users/multisim/source/repos/CMakeProject4/build/generators/conan_toolchain.cmake
-- Conan toolchain: CMAKE_GENERATOR_TOOLSET=v143
-- Conan toolchain: Setting CMAKE_MSVC_RUNTIME_LIBRARY=$<$<CONFIG:Release>:MultiThreadedDLL>
-- Conan toolchain: C++ Standard 14 with extensions OFF
-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.19044.
-- Conan: Component target declared 'tsl::hat_trie'
-- Conan: Component target declared 'tsl::array_hash'
-- Configuring done (0.0s)
-- Generating done (0.0s)
CMake Warning:
Manually-specified variables were not used by the project:
CMAKE_TOOLCHAIN_FILE
-- Build files have been written to: C:/Users/multisim/source/repos/CMakeProject4/build
-
VS 版本对应关系
-
然后再进行FOO的编译就能
find_package
了
-
去https://github.com/Tessil/hat-trie找个例子,运行如下: