配置 Aspose.Words为C++ 在CMake项目中

Aspose.Words为C++ API适用于任何GNU/Linux操作系统的CMake。 它可以是 从官方网站下载.

给定CMake项目

假设您有以下CMake项目:

CMakeLists.txt:

cmake_minimum_required(VERSION 3.18 FATAL_ERROR)
project(app CXX)
add_executable(app main.cpp)

main.cpp:

int main()
{
    return 0;
}

手动配置

按照以下说明手动配置 Aspose.Words为C++ 在你的CMake:

  1. 下载最新版本 Aspose.Words为C++ 包裹

  2. 复制Aspose.Words.Cpp和CodePorting.Native.Cs2Cpp_api_*.*文件夹,您有CMakeLists。txt的

  3. 将以下行添加到您CMakeLists。txt的:

    	# find Aspose.Words for C++ package and it's dependencies
    	find_package(CodePorting.Native.Cs2Cpp REQUIRED CONFIG PATHS ${CMAKE_CURRENT_SOURCE_DIR} NO_DEFAULT_PATH)
    	find_package(Aspose.Words.Cpp REQUIRED CONFIG PATHS ${CMAKE_CURRENT_SOURCE_DIR} NO_DEFAULT_PATH)
    	find_package(Threads REQUIRED)
    
    	# Link target application with Aspose.Words for C++
    	target_link_libraries(app PRIVATE Aspose::Words Threads::Threads)
    	
    

  4. 现在您可以使用以下方法构建应用程序 Aspose.Words为C++:

    	cd <path_to_dir_with_CMakeLists.txt>
    	cmake -S . -B build -D CMAKE_BUILD_TYPE=Release
    	cmake --build build
    	./build/app