[CMake] Compiling zlib and libpng with one command
Michael Jackson
mike.jackson at bluequartz.net
Thu Nov 12 18:13:31 EST 2009
Well,
Having gone down this path just this morning with BOTH of those
libraries, here is what I did.
In my png/CMakeList.txt file, I have the following:
include_directories(${CxImage_SOURCE_DIR}/Utilities/cxzlib)
include_directories(${CxImage_BINARY_DIR}/CxZLib)
....
ADD_LIBRARY(CxPng ${LIB_TYPE} ${PNG_SRCS} ${PNG_HDRS})
TARGET_LINK_LIBRARIES(CxPng CxZLib)
In my Top level CMakeLists.txt file I have the following:
add_subdirectory(${CxImage_SOURCE_DIR}/Utilities/cxzlib $
{CxImage_BINARY_DIR}/CxZLib)
add_subdirectory(${CxImage_SOURCE_DIR}/Utilities/cxpng $
{CxImage_BINARY_DIR}/CxPng)
That sets up the dependencies between Png and ZLib. CMake generated
build files should now know to build Zlib first, then Png. You can
take a look at the specific project here:
http://www.bluequartz.net/cgi-bin/gitweb/gitweb.cgi?p=CxImage.git;a=summary
I am porting the CxImage project to CMake so I can use it on more than
just Windows. And just to be fair, I grabbed a lot of the CMake code
to build ZLib and Png from the VTK and ITK projects.
_________________________________________________________
Mike Jackson mike.jackson at bluequartz.net
BlueQuartz Software www.bluequartz.net
Principal Software Engineer Dayton, Ohio
On Nov 12, 2009, at 6:59 PM, Hugh Sorby wrote:
>
> I am trying to compile zlib and libpng with one command, or more
> specifically one series of commands. My aim is to get as simple as
> possible to the following
>
> cmake
> make
> make install
>
> So what I have done so far is to layout my directories like so:
>
> third_party
> |
> --zlib
> |
> --libpng
>
>
> In each directory I have a CMakeLists.txt file that will build the
> libraries. So far so good. Now with a clean system i.e. one where
> libpng can't find zlib (because it hasn't been built yet) I try
> executing:
>
> cmake
>
> Which runs as expected right up until libpng requires the existence
> of zlib. So my problem is how to tell libpng that zlib is on it's
> way if it could only be a little patient. Preferebly without having
> to touch the CMakeLists.txt file inside libpng directory
>
> Also is this strategy likely to fly or is it never going to get off
> the ground?
>
> Chreers.
>
> Also, can CMake apply patches?
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
More information about the CMake
mailing list