Reputation: 20780
I have the following cmake file:
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. pnglib
on the other hand doesn't build:
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.
...
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. 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
Upvotes: 1
Views: 603
Reputation: 20780
After reading genout.cmake
I've found this line:
set(AWK "C:/Program Files/Git/usr/bin/gawk.exe")
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.
Upvotes: 1