// short version
How can I get CMake to use the zlib I provided (which it should also build from the source) and not the finder found without breaking the search for other libs (OpenGL)?
ZLib should be used by the main project, as well as libPNG, which is also the source.
The primary target platform is Windows.
// longer version:
In my project, I need to set the link to libpng, zlib and OpenGL. C libpng depends on zlib. But zlib is also required for the main project.
I need to provide source code for all libraries except OpenGL, and assemble these libraries together with the main project in order to approve the link to the correct version and simplify the creation on Windows.
I found ways to do all this with custom libraries where there is no built-in crawler, but I cannot override the crawler correctly only for zlib. If I changed the search path for libs, then OpenGL will not be found.
However, I cannot get cmake to use my supplied zlib instead of rouge zlib.DLL, which the search engine finds somewhere on my system. (One of the turtle git)
I tried setting ZLIB_LIBRARY to a specific file path, but this only works on MinGW, and I also think that this is not a way to do this.
(And also I had to explicitly refer to png16_static, and not just libpng, for an unexplained reason.)
Any help on this is greatly appreciated. Maybe I take it wrong?
Target & Development Platform:
Windows7 Visual Studio 2010 and MinGW (both need to work)
My (simplified example) CMakeLists.txt:
cmake_minimum_required (VERSION 2.6) project (MyProject) find_package(OpenGL) add_executable(MyProject main.cpp) include_directories(${INCLUDE_DIRECTORIES} "${PROJECT_BINARY_DIR}") include_directories(${INCLUDE_DIRECTORIES} "external_libs/lpng162") include_directories(${INCLUDE_DIRECTORIES} "external_libs/zlib-1.2.8") include_directories(${INCLUDE_DIRECTORIES} "${PROJECT_BINARY_DIR}/external_libs/zlib-1.2.8") add_subdirectory("external_libs/zlib-1.2.8") link_directories(${LINK_DIRECTORIES} "${PROJECT_BINARY_DIR}/external_libs/zlib-1.2.8")
Project structure (simplified example):
./main.cpp ./CMakeLists.txt ./external_libs/zlib-1.2.8/ <- contains respective source ./external_libs/lpng162/ <- contains respective source