From 6b1e9d1b4e3487a576dd62a99736f73aaef1599d Mon Sep 17 00:00:00 2001 From: Mathieu Malaterre Date: Wed, 21 Dec 2011 15:19:46 +0000 Subject: [PATCH] Attempt to fix building of universal exe --- CMakeLists.txt | 3 +++ applications/codec/CMakeLists.txt | 11 +++++++++-- thirdparty/CMakeLists.txt | 20 ++------------------ 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e8c7c99f..a223fb31 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -196,6 +196,9 @@ IF(NOT CURL_FOUND) SET(BUILD_JPIP OFF) ENDIF (NOT CURL_FOUND) +# Try to find lib Z +FIND_PACKAGE(ZLIB) + IF(BUILD_CODEC OR BUILD_MJ2 OR BUILD_JPIP) OPTION(BUILD_THIRDPARTY "Build the thirdparty executables if it is needed" OFF) ADD_SUBDIRECTORY(thirdparty) diff --git a/applications/codec/CMakeLists.txt b/applications/codec/CMakeLists.txt index 77759f7b..31009c34 100644 --- a/applications/codec/CMakeLists.txt +++ b/applications/codec/CMakeLists.txt @@ -30,7 +30,14 @@ ENDIF(WIN32) FOREACH(exe j2k_to_image image_to_j2k j2k_dump) ADD_EXECUTABLE(${exe} ${exe}.c ${common_SRCS}) TARGET_LINK_LIBRARIES(${exe} ${OPENJPEG_LIBRARY_NAME} -${Z_LIBNAME} ${PNG_LIBNAME} ${TIFF_LIBNAME} ${LCMS_LIBNAME} ) + ${PNG_LIBNAME} ${TIFF_LIBNAME} ${LCMS_LIBNAME} + ) + # To support universal exe: + IF(ZLIB_FOUND AND APPLE) + TARGET_LINK_LIBRARIES(${exe} z) + ELSe(ZLIB_FOUND AND APPLE) + TARGET_LINK_LIBRARIES(${exe} ${Z_LIBNAME}) + ENDIF(ZLIB_FOUND AND APPLE) # On unix you need to link to the math library: IF(UNIX) @@ -89,4 +96,4 @@ IF(BUILD_JPWL) INSTALL(TARGETS JPWL_image_to_j2k JPWL_j2k_to_image DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications ) -ENDIF(BUILD_JPWL) \ No newline at end of file +ENDIF(BUILD_JPWL) diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index a3f95095..10173847 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -1,30 +1,14 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) - -IF(UNIX OR CYGWIN) - SET(CMAKE_INCLUDE_PATH /usr/include /usr/local/include /opt/include - /opt/local/include /usr/include/libpng /usr/include/libpng14 - /usr/include/libpng12 /usr/local/include/libpng - /usr/local/include/libpng14 /usr/local/include/libpng12 - /opt/include/libpng /opt/include/libpng14 /opt/include/libpng12 - /opt/local/include/libpng /opt/local/include/libpng14) - SET(CMAKE_LIBRARY_PATH /usr/lib /usr/local/lib /opt/lib /opt/local/lib) -ENDIF(UNIX OR CYGWIN) - -#------------ -# Try to find lib Z -FIND_PACKAGE(ZLIB) - IF(ZLIB_FOUND) SET(Z_LIBNAME ${ZLIB_LIBRARIES} PARENT_SCOPE) SET(Z_INCLUDE_DIRNAME ${ZLIB_INCLUDE_DIRS} PARENT_SCOPE) - message("Your system seems to have a Z lib available, we will use it to generate PNG lib") + message(STATUS "Your system seems to have a Z lib available, we will use it to generate PNG lib") ELSE (ZLIB_FOUND) # not found IF(BUILD_THIRDPARTY) # Try to build it - message("We will build Z lib from thirdparty") + message(STATUS "We will build Z lib from thirdparty") ADD_SUBDIRECTORY(libz) SET(Z_LIBNAME z PARENT_SCOPE) SET(Z_INCLUDE_DIRNAME ${OPENJPEG_SOURCE_DIR}/thirdparty/include PARENT_SCOPE)