Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can not pass compile when pass 'PNG_PREFIX' by using cmake #490

Open
lanewei120 opened this issue Aug 17, 2023 · 2 comments
Open

can not pass compile when pass 'PNG_PREFIX' by using cmake #490

lanewei120 opened this issue Aug 17, 2023 · 2 comments

Comments

@lanewei120
Copy link

lanewei120 commented Aug 17, 2023

On Linux ubuntu 22.04, Steps to reproduce

  1. clone codes, store at /home/user.name/libpng
  2. cd libpng
  3. mkdir build;mkdir install_dir
  4. 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"
  5. 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

@lanewei120
Copy link
Author

lanewei120 commented Aug 30, 2023

it seems after this commit, it can not pass compile anymore with flag '-DPNG_PREFIX=xxx'

@glebm

commit cbf8c64b58d50038aa051cdcd595923f57191295
Author: Gleb Mazovetskiy <[email protected]>
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 <[email protected]>


@jbowler
Copy link
Contributor

jbowler commented Sep 4, 2024

Hum:

../configure --with-libpng-prefix=conf; make -j; make -j check works and symbols are prefixed with conf

cmake .. -DPNG_PREFIX=cmake; make; make test works and the symbols are prefixed with cmake

cmake .. -DPNG_PREFIX=cmake; make -j fails, as reported

So pngprefix.h is being built twice in the same place (apparently). A work-round is to build without -j. This works:

cmake .. -DPNG_PREFIX=cmake; make -j; make; make -j test

The double build of pngprefix.h can be seen in the make output; Generating scripts/prefix.out appears twice with make -j

That said I can't even find where the dependencies on scripts/prefix.out are; needs a fix from @ctruta. Building -DPNG_SHARED=off doesn't help either (as reported.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants