Question

I'm trying to compile a libpng library. The thing is that I need a specific version of this library - 1.2.37 - because the project I'm using it in is written with this version. I've found the source code of this version here (GnuWin32 project).

But the folder structure looks something like this:

libpng-1.2.37-src/
   contrib/
   projects/
   scripts/
      CMakeLists.txt
   png.h
   pngread.c
   pngwrite.c
   ...

See, the CMakeLists.txt is one level deeper than the source files.

I've tried:

  1. source directory libpng-1.2.37-src/ -> resulted in error: The source directory does not appear to contain CMakeLists.txt
  2. source directory libpng-1.2.37-src/scripts -> resulted in multiple errors: File libpng-1.2.37-src/scripts/scripts/libpng.pc.in does not exist.
  3. copy CMakeLists.txt from /scripts to /libpng-1.2.37-src and set source directory to /libpng-1.2.37-src -> resulted in error: The source "/libpng-1.2.37-src/CMakeLists.txt" does not match the source "/libpng-1.2.37-src/scripts/CMakeLists.txt" used to generate cache.

What should I do to make it work? I don't know why the CMakeLists.txt file would be included if it can't be used.

Était-ce utile?

La solution

The INSTALL file explicitely says:

If you want to use "cmake" (see www.cmake.org), copy CMakeLists.txt
from the "scripts" directory to this directory and type

   cmake . [-DPNG_MMX=YES] -DCMAKE_INSTALL_PREFIX=/path
   make
   make install

And as a side note, before this it says that the classic way to install it is:

On Unix/Linux and similar systems, you can simply type

    ./configure [--prefix=/path]
    make check
    make install

It sounds like you did right with 3), however you forgot to cleanup the build dir before trying again.

Autres conseils

If it's library which you use in your project you can build it automatically via technique called 'superbuild' (use ExternalProject_Add). By specifying SOURCE_SUBDIR as is described here to subdirectory with CMakeLists.txt you can do something like this

  ExternalProject_Add(libpng
  GIT_REPOSITORY    url-to-your-repository.git
  GIT_TAG           v1.2.37
  SOURCE_SUBDIR     "scripts"
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top