如何在CMakeLists.txt中使用本地修改的库,而不是在/ usr中安装一个库?

时间:2018-06-22 14:30:26

标签: c++ cmake poppler

我正在将$ git clone https://anongit.freedesktop.org/git/poppler/poppler.git pdf前端库用于演示PDF阅读器应用程序,并且我已经完成以下步骤来构建和安装poppler:
1. $ cd poppler && mkdir build && cd build
2. $ cmake -DCMAKE_INSTALL_LIBDIR="~/devinstall/poppler" -DENABLE_XPDF_HEADERS=ON -DCMAKE_INSTALL_PREFIX=~/devinstall/poppler ..
3. $ make -j8 && make install
4. ~/devinstall/poppler

poppler安装在$ mkdir demoApp && cd demoApp上,现在我创建了一个目录CMakeLists.txt,将在其中写入我的main.cpp$ vim main.cpp //written code for the demo app that will use poppler library to open a PDF document and show annotations on it源文件:
1. $ vim CMakeLists.txt
2. CMakeLists.txt
这是我的cmake_minimum_required(VERSION 2.8.12) project(demoApp) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) include(KDEInstallDirs) include(KDECMakeSettings) include(KDECompilerSettings) include(FeatureSummary) find_package(Qt5Core) find_package(Qt5Gui) find_package(Qt5Widgets) find_package(KF5 5.2 REQUIRED COMPONENTS TextWidgets) # On Ubuntu: apt-get install extra-cmake-modules # It includes /usr/share/ECM/find-modules/FindPoppler.cmake find_package(ECM REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_MODULE_PATH}) # Point CMake to the pkgconfig files (*.pc) of our local poppler installation # Assumption: Poppler was configured like # $ cmake -DCMAKE_INSTALL_LIBDIR="~/devinstall/poppler" -DENABLE_XPDF_HEADERS=ON [...] set(ENV{PKG_CONFIG_PATH} "$ENV{HOME}/devinstall/poppler/lib/pkgconfig") find_package(PkgConfig REQUIRED) find_package(Poppler REQUIRED Qt5) add_executable(demoApp main.cpp) target_include_directories(demoApp PRIVATE ${Poppler_INCLUDE_DIRS}) target_link_libraries(demoApp Qt5::Core Qt5::Gui Qt5::Widgets Poppler::Qt5 KF5::TextWidgets) 文件:

$ mkdir build && cd build
  1. $ cmake .. && make -j8
  2. $ ./demoApp
  3. {"marker":[{"@attributes":{"start":"Im Berge", "finish":"Eichelberger Stra\u00dfe" ...

demoApp成功运行,但是克隆poppler之后注释的字体颜色中包含的更改不会反映出来。我认为它正在使用Ubuntu安装poppler库。如何使demoApp使用本地修改的poppler而不是已安装的poppler?

0 个答案:

没有答案