msys2下用cmake构建poppler

文章参考链接:cmake-toolchains(7) — CMake 3.22.1 Documentation

CMAKE_TOOLCHAIN_FILE — CMake 3.22.1 Documentation

 CMAKE_<LANG>_COMPILER — CMake 3.22.1 Documentation

cmake-generators(7) — CMake 3.22.1 Documentation

CMake 使用实用工具链来编译、链接库和创建档案,以及驱动构建的其他任务。

可用的工具链实用程序取决于启用的语言。在正常构建中,CMake 会根据系统自省和默认值自动确定主机构建的工具链。在交叉编译场景中,可以使用有关编译器和实用程序路径的信息指定工具链文件。

DCMAKE_TOOLCHAIN_FILE指定一个文件被提前加载来设置编译器相关参数值。

toolchain-mingw32.cmake

# Sample toolchain file for building.
#
# Typical usage:
#    *) cd build
#    *) cmake -DCMAKE_TOOLCHAIN_FILE=~/Toolchain-Ubuntu-mingw32.cmake ..

set(CMAKE_SYSTEM_NAME Windows)
set(TOOLCHAIN_PREFIX mingw-w64-i686)

# cross compilers to use for C and C++
set(CMAKE_C_COMPILER D:/msys32/mingw32/bin/gcc.exe)
set(CMAKE_CXX_COMPILER D:/msys32/mingw32/bin/g++.exe)
set(CMAKE_RC_COMPILER D:/msys32/mingw32/bin/windres.exe)
set(CMAKE_ASM_YASM_COMPILER D:/msys32/mingw32/bin/yasm.exe)

# target environment on the build host system
#   set 1st to dir with the cross compiler's C/C++ headers/libs
# set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})

# modify default behavior of FIND_XXX() commands to
# search for headers/libs in the target environment and
# search for programs in the build host environment
# set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
# set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

 生成配置文件makefile并执行make进行构建


cd poppler
rm -rf build
mkdir build
cd build
cmake  -G "MSYS Makefiles"                               \
  -DCMAKE_TOOLCHAIN_FILE=/home/49938/pdf2htmlEX/toolchain-mingw32.cmake  \
  -DCMAKE_BUILD_TYPE=Debug                \
  -DCMAKE_INSTALL_PREFIX=$PDF2HTMLEX_PREFIX \
  -DENABLE_UNSTABLE_API_ABI_HEADERS=OFF     \
  -DBUILD_GTK_TESTS=OFF                     \
  -DBUILD_QT5_TESTS=OFF                     \
  -DBUILD_CPP_TESTS=OFF                     \
  -DENABLE_SPLASH=ON                        \
  -DENABLE_UTILS=OFF                        \
  -DENABLE_CPP=OFF                          \
  -DENABLE_GLIB=ON                          \
  -DENABLE_GOBJECT_INTROSPECTION=OFF        \
  -DENABLE_GTK_DOC=OFF                      \
  -DENABLE_QT5=OFF                          \
  -DENABLE_LIBOPENJPEG="none"               \
  -DENABLE_CMS="none"                       \
  -DENABLE_DCTDECODER="libjpeg"             \
  -DENABLE_LIBCURL=OFF                      \
  -DENABLE_ZLIB=ON                          \
  -DENABLE_ZLIB_UNCOMPRESS=OFF              \
  -DUSE_FLOAT=OFF                           \
  -DBUILD_SHARED_LIBS=OFF                   \
  -DRUN_GPERF_IF_PRESENT=OFF                \
  -DEXTRA_WARN=OFF                          \
  -DWITH_JPEG=ON                            \
  -DWITH_PNG=ON                             \
  -DWITH_TIFF=OFF                           \
  -DWITH_NSS3=OFF                           \
  -DWITH_Cairo=ON                           \
  ..

make $MAKE_PARALLEL

上一篇:VSCode中C/C++编译


下一篇:windows下编译ffmpeg以及遇到的坑