From 8612e3d20e047c976f72584e9d8013de882ebcd9 Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Fri, 26 Sep 2014 21:18:00 +0930 Subject: [PATCH] Update cmake for openjpeg2 --- CMakeLists.txt | 18 ++++++++++++++---- cmake/modules/FindLIBOPENJPEG.cmake | 1 + cmake/modules/FindLIBOPENJPEG2.cmake | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 cmake/modules/FindLIBOPENJPEG2.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 81d10f0..39caaea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -152,9 +152,13 @@ if(ENABLE_ZLIB) set(ENABLE_ZLIB ${ZLIB_FOUND}) endif(ENABLE_ZLIB) if(ENABLE_LIBOPENJPEG) - find_package(LIBOPENJPEG) - set(ENABLE_LIBOPENJPEG ${LIBOPENJPEG_FOUND}) - set(HAVE_OPENJPEG_H ON) + find_package(LIBOPENJPEG2) + set(USE_OPENJPEG ${LIBOPENJPEG2_FOUND}) + if(NOT LIBOPENJPEG2_FOUND) + find_package(LIBOPENJPEG) + set(USE_OPENJPEG ${LIBOPENJPEG_FOUND}) + set(HAVE_OPENJPEG_H ON) + endif(NOT LIBOPENJPEG2_FOUND) endif(ENABLE_LIBOPENJPEG) if(ENABLE_CMS STREQUAL "auto") find_package(LCMS2) @@ -678,7 +682,13 @@ show_end_message_yesno("use libpng" ENABLE_LIBPNG) show_end_message_yesno("use libtiff" ENABLE_LIBTIFF) show_end_message_yesno("use zlib" ENABLE_ZLIB) show_end_message_yesno("use curl" ENABLE_LIBCURL) -show_end_message_yesno("use libopenjpeg" LIBOPENJPEG_FOUND) +show_end_message_yesno("use libopenjpeg" USE_OPENJPEG) +if(LIBOPENJPEG_FOUND) + message(" with openjpeg1") +endif(LIBOPENJPEG_FOUND) +if(LIBOPENJPEG2_FOUND) + message(" with openjpeg2") +endif(LIBOPENJPEG2_FOUND) show_end_message_yesno("use cms" USE_CMS) if(LCMS_FOUND) message(" with lcms1") diff --git a/cmake/modules/FindLIBOPENJPEG.cmake b/cmake/modules/FindLIBOPENJPEG.cmake index d9c1369..45f5198 100644 --- a/cmake/modules/FindLIBOPENJPEG.cmake +++ b/cmake/modules/FindLIBOPENJPEG.cmake @@ -43,6 +43,7 @@ int main() set(CMAKE_REQUIRED_LIBRARIES) set(LIBOPENJPEG_FOUND TRUE) + add_definitions(-DUSE_OPENJPEG1) endif(LIBOPENJPEG_INCLUDE_DIR AND LIBOPENJPEG_LIBRARIES) include(FindPackageHandleStandardArgs) diff --git a/cmake/modules/FindLIBOPENJPEG2.cmake b/cmake/modules/FindLIBOPENJPEG2.cmake new file mode 100644 index 0000000..f7af6d0 --- /dev/null +++ b/cmake/modules/FindLIBOPENJPEG2.cmake @@ -0,0 +1,33 @@ +# - Try to find the libopenjpeg2 library +# Once done this will define +# +# LIBOPENJPEG2_FOUND - system has libopenjpeg +# LIBOPENJPEG2_INCLUDE_DIRS - the libopenjpeg include directories +# LIBOPENJPEG2_LIBRARIES - Link these to use libopenjpeg +# LIBOPENJPEG2_INCLUDE_DIR is internal and deprecated for use + +# Copyright (c) 2008, Albert Astals Cid, +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + + +if (LIBOPENJPEG2_LIBRARIES AND LIBOPENJPEG2_INCLUDE_DIR) + + # in cache already + set(LIBOPENJPEG2_FOUND TRUE) + +else (LIBOPENJPEG2_LIBRARIES AND LIBOPENJPEG2_INCLUDE_DIR) + + find_package(PkgConfig REQUIRED) + pkg_check_modules(OJP2 libopenjp2) + if (OJP2_FOUND) + include_directories(${OJP2_INCLUDE_DIRS}) + link_directories(${OJP2_LIBRARY_DIRS}) + set(LIBOPENJPEG2_FOUND TRUE) + add_definitions(${OJP2_CFLAGS_OTHER}) + add_definitions(-DUSE_OPENJPEG2) + endif (OJP2_FOUND) +endif (LIBOPENJPEG2_LIBRARIES AND LIBOPENJPEG2_INCLUDE_DIR) + +set(LIBOPENJPEG2_INCLUDE_DIRS ${LIBOPENJPEG2_INCLUDE_DIR}) -- 2.1.0