[英]libpng with directory tree zlib build error
I have the following cmake file:我有以下 cmake 文件:
cmake_minimum_required(VERSION 3.15)
add_subdirectory(googletest)
add_subdirectory(zlib)
# libpng setup
option(PNG_TESTS OFF)
set(PNG_TESTS OFF)
option(PNG_SHARED OFF)
set(PNG_SHARED OFF)
option(PNG_EXECUTABLES OFF)
set(PNG_EXECUTABLES OFF)
option(PNG_BUILD_ZLIB ON)
set(PNG_BUILD_ZLIB ON)
set(ZLIB_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/zlib" "${CMAKE_CURRENT_BINARY_DIR}/zlib")
set(ZLIB_LIBRARY "zlib")
add_subdirectory(libpng)
This generates the project correctly and zlib
/ googletest
build is OK.这会正确生成项目并且zlib
/ googletest
构建是可以的。 pnglib
on the other hand doesn't build:另一方面, pnglib
不构建:
1>Generating pnglibconf.out
1>Microsoft (R) C/C++ Optimizing Compiler Version 19.28.29337 for x64
1>Copyright (C) Microsoft Corporation. All rights reserved.
1>
1>pnglibconf.c
1>build/thirdparty/libpng/pnglibconf.c(34): fatal error C1083: Cannot open include file: 'zlib.h': No such file or directory
1>CMake Error at scripts/genout.cmake:78 (message):
1> Failed to generate build/thirdparty/libpng/pnglibconf.out.tf1
1>
1>
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(238,5): error MSB8066: Custom build for 'build\CMakeFiles\4c907688e112b5b30b06f56662306981\pnglibconf.out.rule;build\CMakeFiles\4c907688e112b5b30b06f56662306981\pnglibconf.h.rule;build\CMakeFiles\5a2501006db4b4e75991d2f2c16bfadf\sym.out.rule;build\CMakeFiles\4c907688e112b5b30b06f56662306981\libpng.sym.rule;build\CMakeFiles\5a2501006db4b4e75991d2f2c16bfadf\vers.out.rule;build\CMakeFiles\4c907688e112b5b30b06f56662306981\libpng.vers.rule;build\CMakeFiles\5a2501006db4b4e75991d2f2c16bfadf\intprefix.out.rule;build\CMakeFiles\5a2501006db4b4e75991d2f2c16bfadf\prefix.out.rule;build\CMakeFiles\5a2501006db4b4e75991d2f2c16bfadf\symbols.chk.rule;build\CMakeFiles\e5199c38ed750451ee22eda432b56e2c\genfiles.rule' exited with code 1.
1>Done building project "genfiles.vcxproj" -- FAILED.
If I manually copy ${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt
to ${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h
as genfiles
target should do pnglib_static compiles fine.如果我手动将${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt
复制到${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h
作为genfiles
目标应该可以正常编译 pnglib_static。
...
if(NOT AWK OR ANDROID OR IOS)
# No awk available to generate sources; use pre-built pnglibconf.h
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt
${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h)
add_custom_target(genfiles) # Dummy
else()
...
Any idea on how to fix this?关于如何解决这个问题的任何想法? I would like to not alter the CMakeLists.txt
from libpng
to be easier to update to newer versions.我不想改变libpng
中的CMakeLists.txt
以便更容易更新到新版本。 I'm using the latest version from url = git://git.code.sf.net/p/libpng/code
as documented on http://www.libpng.org/pub/png/libpng.html I'm using the latest version from url = git://git.code.sf.net/p/libpng/code
as documented on http://www.libpng.org/pub/png/libpng.html
After reading genout.cmake
I've found this line:阅读genout.cmake
后,我发现了这一行:
set(AWK "C:/Program Files/Git/usr/bin/gawk.exe")
If I run CMake from cmd
instead of git bash
genout.cmake
contains: If I run CMake from cmd
instead of git bash
genout.cmake
contains:
set(AWK "AWK-NOTFOUND")
Probably running CMake from git bash
confuses the build system, but running CMake from cmd
generates the project correctly. Probably running CMake from git bash
the build system, but running CMake from cmd
generates the project correctly.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.