-FIND_PACKAGE(LCMS2)
-
-IF(LCMS2_FOUND)
-
- message("Your system seems to have a LCMS2 lib available, we will used it")
- SET(HAVE_LCMS2_H 1 PARENT_SCOPE)
- SET(HAVE_LIBLCMS2 1 PARENT_SCOPE)
- SET(LCMS_LIBNAME ${LCMS2_LIBRARIES} PARENT_SCOPE)
- SET(LCMS_INCLUDE_DIRNAME ${LCMS2_INCLUDE_DIRS} PARENT_SCOPE)
-
-ELSE (LCMS2_FOUND) # not found lcms2
- # try to find LCMS
- FIND_PACKAGE(LCMS)
-
- IF(LCMS_FOUND)
-
- message("Your system seems to have a LCMS lib available, we will used it")
- SET(HAVE_LCMS_H 1 PARENT_SCOPE)
- SET(HAVE_LIBLCMS 1 PARENT_SCOPE)
- SET(LCMS_LIBNAME ${LCMS_LIBRARIES} PARENT_SCOPE)
- SET(LCMS_INCLUDE_DIRNAME ${LCMS_INCLUDE_DIRS} PARENT_SCOPE)
-
- ELSE (LCMS_FOUND) # not found lcms
- SET(HAVE_LCMS_H 0 PARENT_SCOPE)
- SET(HAVE_LIBLCMS 0 PARENT_SCOPE)
-
- IF( BUILD_THIRDPARTY)
-
- # Try to build lcms2
- message("We will build LCMS2 lib from thirdparty")
- ADD_SUBDIRECTORY(liblcms2)
- SET(LCMS_LIBNAME lcms2 PARENT_SCOPE)
- SET(LCMS_INCLUDE_DIRNAME ${OPENJPEG_SOURCE_DIR}/thirdparty/liblcms2/include PARENT_SCOPE) #
- SET(HAVE_LCMS2_H 1 PARENT_SCOPE)
- SET(HAVE_LIBLCMS2 1 PARENT_SCOPE)
- ELSE (BUILD_THIRDPARTY)
- SET(HAVE_LCMS2_H 0 PARENT_SCOPE)
- SET(HAVE_LIBLCMS2 0 PARENT_SCOPE)
- message("LCMS2 or LCMS lib not found, activate BUILD_THIRDPARTY if you want build it")
- ENDIF(BUILD_THIRDPARTY)
-
- ENDIF (LCMS_FOUND)
-ENDIF(LCMS2_FOUND)
+set(OPJ_HAVE_LCMS_H 0 PARENT_SCOPE)
+set(OPJ_HAVE_LIBLCMS 0 PARENT_SCOPE)
+
+if( BUILD_THIRDPARTY)
+ # Try to build lcms2
+ message(STATUS "We will build LCMS2 lib from thirdparty")
+ add_subdirectory(liblcms2)
+ set(LCMS_LIBNAME lcms2 PARENT_SCOPE)
+ set(LCMS_INCLUDE_DIRNAME ${OPENJPEG_SOURCE_DIR}/thirdparty/liblcms2/include PARENT_SCOPE) #
+ set(OPJ_HAVE_LCMS2_H 1 PARENT_SCOPE)
+ set(OPJ_HAVE_LIBLCMS2 1 PARENT_SCOPE)
+else(BUILD_THIRDPARTY)
+ find_package(LCMS2)
+ # Static only build:
+ # it is necessary to invoke pkg_check_module on lcms2 since it may have
+ # several other dependencies not declared by its cmake module, but they are
+ # in the its pkgconfig module.
+ if(PKG_CONFIG_FOUND)
+ pkg_check_modules(PC_LCMS2 QUIET lcms2)
+ endif(PKG_CONFIG_FOUND)
+ if(LCMS2_FOUND)
+ message(STATUS "Your system seems to have a LCMS2 lib available, we will use it")
+ set(OPJ_HAVE_LCMS2_H 1 PARENT_SCOPE)
+ set(OPJ_HAVE_LIBLCMS2 1 PARENT_SCOPE)
+ if(BUILD_STATIC_LIBS AND NOT BUILD_SHARED_LIBS)
+ # Probably incorrect as PC_LCMS2_STATIC_LIBRARIES will lack the path to the libraries
+ # and will only work if they are in system directories
+ set(LCMS_LIBNAME ${PC_LCMS2_STATIC_LIBRARIES} PARENT_SCOPE)
+ set(LCMS_INCLUDE_DIRNAME ${PC_LCMS2_STATIC_INCLUDE_DIRS} PARENT_SCOPE)
+ else()
+ set(LCMS_LIBNAME ${LCMS2_LIBRARIES} PARENT_SCOPE)
+ set(LCMS_INCLUDE_DIRNAME ${LCMS2_INCLUDE_DIRS} PARENT_SCOPE)
+ endif()
+ else(LCMS2_FOUND) # not found lcms2
+ # try to find LCMS
+ find_package(LCMS)
+ if(LCMS_FOUND)
+ message(STATUS "Your system seems to have a LCMS lib available, we will use it")
+ set(OPJ_HAVE_LCMS_H 1 PARENT_SCOPE)
+ set(OPJ_HAVE_LIBLCMS 1 PARENT_SCOPE)
+ set(LCMS_LIBNAME ${LCMS_LIBRARIES} PARENT_SCOPE)
+ set(LCMS_INCLUDE_DIRNAME ${LCMS_INCLUDE_DIRS} PARENT_SCOPE)
+ else(LCMS_FOUND) # not found lcms
+ set(OPJ_HAVE_LCMS2_H 0 PARENT_SCOPE)
+ set(OPJ_HAVE_LIBLCMS2 0 PARENT_SCOPE)
+ message(STATUS "LCMS2 or LCMS lib not found, activate BUILD_THIRDPARTY if you want build it")
+ endif(LCMS_FOUND)
+ endif(LCMS2_FOUND)
+endif(BUILD_THIRDPARTY)