can not pass compile when pass 'PNG_PREFIX' by using cmake
lanewei120 opened this issue · comments
On Linux ubuntu 22.04, Steps to reproduce
- clone codes, store at /home/user.name/libpng
- cd libpng
- mkdir build;mkdir install_dir
- cmake ../ -DPNG_SHARED=OFF -DPNG_STATIC=ON -DPNG_TESTS=OFF -DPNG_PREFIX=test_ -DCMAKE_PREFIX_PATH="/home/user.name/libpng" -DCMAKE_INSTALL_PREFIX="/home/user.name/libpng"
- cmake --build . --target install --config Release -j4
-- Symbol prefix:
-- Configuring done
-- Generating done
-- Build files have been written to: /home/user.name/libpng/build
[ 1%] Built target scripts_symbols_out
[ 2%] Built target scripts_pnglibconf_c
[ 4%] Built target pnglibconf_c
Scanning dependencies of target symbol-check
Scanning dependencies of target pnglibconf_out
[ 5%] Generating scripts/symbols.chk
[ 6%] Generating pnglibconf.out
[ 8%] Built target symbol-check
[ 9%] Built target pnglibconf_out
Scanning dependencies of target scripts_prefix_out
Scanning dependencies of target pnglibconf_h
[ 10%] Generating scripts/prefix.out
[ 12%] Generating scripts/prefix.out
CMake Error at scripts/genout.cmake:90 (file):
file RENAME failed to rename
/home/user.name/libpng/build/scripts/prefix.out.tf2
to
/home/user.name/libpng/build/scripts/prefix.out
because: No such file or directory
make[2]: *** [CMakeFiles/pnglibconf_h.dir/build.make:74: scripts/prefix.out] Error 1
make[2]: *** Deleting file 'scripts/prefix.out'
make[1]: *** [CMakeFiles/Makefile2:494: CMakeFiles/pnglibconf_h.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 14%] Built target scripts_prefix_out
make: *** [Makefile:141: all] Error 2
it seems after this commit, it can not pass compile anymore with flag '-DPNG_PREFIX=xxx'
commit cbf8c64b58d50038aa051cdcd595923f57191295
Author: Gleb Mazovetskiy <glex.spb@gmail.com>
Date: Sat Dec 4 11:23:42 2021 +0000
cmake: Correctly handle generated files
Generated files depend on other generated files, and this previously
resulted in the same custom command output being a dependency of
multiple other custom commands without a shared custom targets.
Adds a top-level target for each generated file and ensures that
commands that depend on generated files also depend on the corresponding
custom targets.
Per CMake documentation:
> Do not list the output in more than one independent target
> that may build in parallel or the two instances of the rule
> may conflict (instead use add_custom_target to drive the command
> and make the other targets depend on that one).
Signed-off-by: Cosmin Truta <ctruta@gmail.com>