windows - CMake 在 64 位平台上找到 32 位 GDI+

标签 windows cmake

我想构建一个在 32 位和 64 位 Windows 上都需要 GDI+ 的程序。 我正在使用 CMake 3.3.2、Windows 10 64 位、Visual Studio 2015。 作为一个最小的情况,我有这个 CMakeLists.txt:

cmake_minimum_required(VERSION 3.3)
find_library(GDIP gdiplus)

我在构建子目录中运行它

cmake ..

cmake -A x64 ..

如果我比较两次运行的 CMakeCache.txt,我发现它肯定选择了 32 或 64 位选项(例如 CMAKE_LINKER),但它找到了 32 位 gdiplus.lib 在这两种情况下

//Path to a library.
GDIP:FILEPATH=C:/Program Files (x86)/Windows Kits/8.1/Lib/winv6.3/um/x86/gdiplus.lib

它应该找到 64 位版本 C:/Program Files (x86)/Windows Kits/8.1/Lib/winv6.3/um/x64/gdiplus.lib

有办法解决这个问题吗?

最佳答案

我在 CMake 邮件列表上询问。我感谢谢尔盖·尼库洛夫的回答: http://public.kitware.com/pipermail/cmake/2015-October/061806.html

One idea, how I've created workaround it for odbc lib: Remove find_library(GDIPLUS_LIBRARY NAMES libgdiplus gdiplus) and set(GDIPLUS_LIBRARY gdiplus) or another proper name. Visual studio will pick it from proper path depending on target x86 or x86_64."

我认为这并不理想,但它确实有效。谢谢谢尔盖。

关于windows - CMake 在 64 位平台上找到 32 位 GDI+,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33124745/

相关文章:

linux - 如果只能执行 Windows 批处理脚本,为什么 bash 脚本需要执行位?

Windows:批处理文件:仅以管理员身份运行

c++ - 使用 CMake 的 OpenGL + Qt

macos - CMake include_directories 跳过 OS X 框架

c++ - 如何在 CMake 中启用 C++17

c++ - 如何知道电脑是否处于游戏模式

c++ - 用非零值填充内存比用零填充内存慢吗?

windows - Pyinstaller onefile 在某些 Windows 7 机器上无法启动

macos - 如何在 CMake 脚本中获取应用程序包的路径以将其提供给 fixup_bundle()?

带有模块和外部库的 Fortran 程序的 cmake