improved some CMakeLists files linked to the build of applications which used thirdparty
authorMickael Savinaud <savmickael@users.noreply.github.com>
Wed, 13 Jul 2011 16:49:53 +0000 (16:49 +0000)
committerMickael Savinaud <savmickael@users.noreply.github.com>
Wed, 13 Jul 2011 16:49:53 +0000 (16:49 +0000)
CHANGES
CMake/FindLCMS.cmake [new file with mode: 0644]
CMake/FindLCMS2.cmake [new file with mode: 0644]
CMakeLists.txt
applications/CMakeLists.txt
applications/codec/CMakeLists.txt
opj_configh.cmake.in
thirdparty/CMakeLists.txt
thirdparty/FindLCMS.cmake [deleted file]
thirdparty/FindLCMS2.cmake [deleted file]

diff --git a/CHANGES b/CHANGES
index 94175175bd32f25d8bef1782f1ea409467da4166..486ed83f92f8c2eab7e268621e82d1a6f9632738 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -5,6 +5,9 @@ What's New for OpenJPEG
 ! : changed
 + : added
 
+July 10, 2011
+! [mickael] improved some CMakeLists files linked to the build of applications which used thirdparty
+
 _______ R812 : 'openjpeg-1.5' branch created ______________________________
 
 July 10, 2011
diff --git a/CMake/FindLCMS.cmake b/CMake/FindLCMS.cmake
new file mode 100644 (file)
index 0000000..1a476a4
--- /dev/null
@@ -0,0 +1,31 @@
+# - Find LCMS library
+# Find the native LCMS includes and library
+# Once done this will define
+#
+#  LCMS_INCLUDE_DIR    - Where to find lcms.h, etc.
+#  LCMS_LIBRARIES      - Libraries to link against to use LCMS.
+#  LCMS_FOUND          - If false, do not try to use LCMS.
+#
+# also defined, but not for general use are
+#  LCMS_LIBRARY, where to find the LCMS library.
+
+#=============================================================================
+#=============================================================================
+
+FIND_PATH(LCMS_INCLUDE_DIR lcms.h  PATHS /usr/include /usr/local/include /opt/include /opt/local/include)
+
+SET(LCMS_NAMES ${LCMS_NAMES} lcms liblcms liblcms_static)
+
+FIND_LIBRARY(LCMS_LIBRARY NAMES ${LCMS_NAMES} )
+
+MARK_AS_ADVANCED(LCMS_INCLUDE_DIR LCMS_LIBRARY)
+
+# handle the QUIETLY and REQUIRED arguments and set LCMS_FOUND to TRUE if
+# all listed variables are TRUE
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(LCMS  DEFAULT_MSG  LCMS_LIBRARY  LCMS_INCLUDE_DIR)
+
+IF(LCMS_FOUND)
+  SET( LCMS_INCLUDE_DIRS ${LCMS_INCLUDE_DIR})
+  SET( LCMS_LIBRARIES ${LCMS_LIBRARY} )
+ENDIF(LCMS_FOUND)
diff --git a/CMake/FindLCMS2.cmake b/CMake/FindLCMS2.cmake
new file mode 100644 (file)
index 0000000..b781d84
--- /dev/null
@@ -0,0 +1,31 @@
+# - Find LCMS2 library
+# Find the native LCMS2 includes and library
+# Once done this will define
+#
+#  LCMS2_INCLUDE_DIR    - Where to find lcms2.h, etc.
+#  LCMS2_LIBRARIES      - Libraries to link against to use LCMS2.
+#  LCMS2_FOUND          - If false, do not try to use LCMS2.
+#
+# also defined, but not for general use are
+#  LCMS2_LIBRARY        - Where to find the LCMS2 library.
+
+#=============================================================================
+#=============================================================================
+
+FIND_PATH(LCMS2_INCLUDE_DIR lcms2.h PATHS /usr/include /usr/local/include /opt/include /opt/local/include)
+
+SET(LCMS2_NAMES ${LCMS2_NAMES} lcms2 liblcms2 liblcms2_static)
+
+FIND_LIBRARY(LCMS2_LIBRARY NAMES ${LCMS2_NAMES} )
+
+MARK_AS_ADVANCED(LCMS2_INCLUDE_DIR LCMS2_LIBRARY)
+
+# handle the QUIETLY and REQUIRED arguments and set LCMS2_FOUND to TRUE if 
+# all listed variables are TRUE
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(LCMS2  DEFAULT_MSG  LCMS2_LIBRARY  LCMS2_INCLUDE_DIR)
+
+IF(LCMS2_FOUND)
+  SET( LCMS2_INCLUDE_DIRS ${LCMS2_INCLUDE_DIR})
+  SET( LCMS2_LIBRARIES ${LCMS2_LIBRARY} )
+ENDIF(LCMS2_FOUND)
index d88594144a7c112d6909ab65c17ed27c8ad34682..032b8ab44a18b2689c9e33d3d192d7bc57e8a04a 100644 (file)
@@ -39,6 +39,12 @@ SET(OPENJPEG_LIBRARY_PROPERTIES
   SOVERSION "${OPENJPEG_VERSION_MAJOR}"
 )
 
+
+# Path to additional CMake modules
+SET(CMAKE_MODULE_PATH
+    ${CMAKE_SOURCE_DIR}/CMake
+    ${CMAKE_MODULE_PATH})
+
 # On Visual Studio 8 MS deprecated C. This removes all 1.276E1265 security
 # warnings
 IF(WIN32)
@@ -150,7 +156,7 @@ IF(CMAKE_COMPILER_IS_GNUCC)
 ENDIF(CMAKE_COMPILER_IS_GNUCC)
 
 #-----------------------------------------------------------------------------
-# opj_config.h generation
+# opj_config.h generation (1/2)
 FIND_FILE(HAVE_STRINGS_H_FOUND strings.h)
 IF(NOT HAVE_STRINGS_H_FOUND STREQUAL "HAVE_STRINGS_H_FOUND-NOTFOUND")
   FIND_FILE(HAVE_STRINGS_H strings.h)
@@ -196,10 +202,6 @@ IF(NOT HAVE_UNISTD_H_FOUND STREQUAL "HAVE_UNISTD_H_FOUND-NOTFOUND")
   FIND_FILE(HAVE_UNISTD_H unistd.h)
   SET(HAS_UNISTD_H 1)
 ENDIF()
-CONFIGURE_FILE("${OPENJPEG_SOURCE_DIR}/opj_configh.cmake.in"
- "${OPENJPEG_BINARY_DIR}/opj_config.h"
- @ONLY
- )
 
 #-----------------------------------------------------------------------------
 # CDash+CMake : to be updated
@@ -218,7 +220,19 @@ ADD_SUBDIRECTORY(libopenjpeg)
 # Build Applications
 OPTION(BUILD_CODEC "Build the CODEC executables" ON)
 OPTION(BUILD_MJ2 "Build the MJ2 executables." OFF)
-ADD_SUBDIRECTORY(applications)
+
+IF(BUILD_CODEC OR BUILD_MJ2)
+  OPTION(BUILD_THIRDPARTY "Build the thirdparty executables if it is needed" OFF)
+  ADD_SUBDIRECTORY(thirdparty)
+  ADD_SUBDIRECTORY(applications)
+ENDIF (BUILD_CODEC OR BUILD_MJ2)
+
+#-----------------------------------------------------------------------------
+# opj_config.h generation (2/2)
+CONFIGURE_FILE("${OPENJPEG_SOURCE_DIR}/opj_configh.cmake.in"
+ "${OPENJPEG_BINARY_DIR}/opj_config.h"
+ @ONLY
+ )
 
 #-----------------------------------------------------------------------------
 # Build JPWL-flavoured library and executables
index 5f413169a26f516f8d711923e330cf9d96e981ef..3b65ade1ff49e69d25a5862d9b67a845cbe4f3b1 100644 (file)
@@ -1,130 +1,9 @@
-IF(BUILD_CODEC OR BUILD_MJ2)
-#
-#
-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()
-#
- FIND_PACKAGE(ZLIB)
-#
- IF(ZLIB_LIBRARY STREQUAL "ZLIB_LIBRARY-NOTFOUND")
-   SET(ZLIB_FOUND 0)
- ENDIF(ZLIB_LIBRARY STREQUAL "ZLIB_LIBRARY-NOTFOUND")
-#
- IF(ZLIB_FOUND)
-   SET(HAVE_ZLIB_H 1)
-   SET(HABE_LIBZ 1)
-   SET(Z_LIBNAME ${ZLIB_LIBRARIES})
-   SET(Z_INCLUDE_DIRNAME ${ZLIB_INCLUDE_DIR}) 
- ENDIF(ZLIB_FOUND)
-#
- FIND_PACKAGE(PNG)
-#
- IF(PNG_LIBRARY STREQUAL "PNG_LIBRARY-NOTFOUND")
-   SET(PNG_FOUND 0)
- ENDIF(PNG_LIBRARY STREQUAL "PNG_LIBRARY-NOTFOUND")
-#
- IF(PNG_FOUND)
-   SET(HAVE_PNG_H 1)
-   SET(HAVE_LIBPNG 1)
-   SET(PNG_LIBNAME ${PNG_LIBRARIES})
-   SET(PNG_INCLUDE_DIRNAME ${PNG_INCLUDE_DIR})
- ENDIF(PNG_FOUND)
-#
- FIND_PACKAGE(TIFF)
-#
- IF(TIFF_LIBRARY STREQUAL "TIFF_LIBRARY-NOTFOUND")
-   SET(TIFF_FOUND 0)
- ENDIF(TIFF_LIBRARY STREQUAL "TIFF_LIBRARY-NOTFOUND")
-#
- IF(TIFF_FOUND)
-   SET(HAVE_TIFF_H 1)
-   SET(HAVE_LIBTIFF 1)
-   SET(TIFF_LIBNAME ${TIFF_LIBRARIES})
-   SET(TIFF_INCLUDE_DIRNAME ${TIFF_INCLUDE_DIR})
- ENDIF(TIFF_FOUND)
-#
- SET(LCMS12_MISSING 1)
- INCLUDE(${OPENJPEG_SOURCE_DIR}/thirdparty/FindLCMS2.cmake OPTIONAL)
-#
- IF(LCMS2_FOUND)
-  SET(LCMS12_MISSING 0)
-  SET(HAVE_LCMS2_H 1)
-  SET(HAVE_LIBLCMS2 1)
-  SET(LCMS_LIBNAME ${LCMS2_LIBRARY})
-  SET(LCMS_INCLUDE_DIRNAME ${LCMS2_INCLUDE_DIR})
- ENDIF(LCMS2_FOUND)
-#
- IF(NOT LCMS2_FOUND)
-  INCLUDE(${OPENJPEG_SOURCE_DIR}/thirdparty/FindLCMS.cmake OPTIONAL)
-#
-  IF(LCMS_FOUND)
-   SET(LCMS12_MISSING 0)
-   SET(HAVE_LCMS1_H 1)
-    SET(HAVE_LIBLCMS1 1)
-    SET(LCMS_LIBNAME ${LCMS_LIBRARY} )
-    SET(LCMS_INCLUDE_DIRNAME ${LCMS_INCLUDE_DIR})
-  ENDIF(LCMS_FOUND)
- ENDIF(NOT LCMS2_FOUND)
-#-------------------------------------------------------------
- OPTION(BUILD_THIRDPARTY "Build the thirdparty executables" ON)
-#
- IF(NOT ZLIB_FOUND OR NOT PNG_FOUND OR NOT TIFF_FOUND OR LCMS12_MISSING) 
-  IF(BUILD_THIRDPARTY)
-   SET(HAVE_ZLIB_H 1)
-   SET(HAVE_LIBZ 1)
-   SET(HAVE_PNG_H 1)
-   SET(HAVE_LIBPNG 1)
-   SET(HAVE_TIFF_H 1)
-   SET(HAVE_LIBTIFF 1)
-   SET(HAVE_LCMS2_H 1)
-   SET(HAVE_LIBLCMS2 1)
-#
-#ADD_SUBDIRECTORY(${OPENJPEG_SOURCE_DIR}/thirdparty)
-#
-   LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/thirdparty/lib)
-#
-   IF(NOT ZLIB_FOUND)
-    INCLUDE_DIRECTORIES(${OPENJPEG_SOURCE_DIR}/thirdparty/include)
-    SET(ZLIB_INCLUDE_DIRNAME ${OPENJPEG_SOURCE_DIR}/thirdparty/include)
-    SET(Z_LIBNAME z)
-    SET(ZLIB_FOUND 1)
-   ENDIF(NOT ZLIB_FOUND)
-#
-   IF(NOT PNG_FOUND)
-    SET(PNG_INCLUDE_DIRNAME ${OPENJPEG_SOURCE_DIR}/thirdparty/libpng)
-    SET(PNG_LIBNAME png)
-    SET(PNG_FOUND 1)
-   ENDIF(NOT PNG_FOUND)
-#
-   IF(NOT LCMS_FOUND AND NOT LCMS2_FOUND)
-    SET(LCMS_INCLUDE_DIRNAME ${OPENJPEG_SOURCE_DIR}/thirdparty/liblcms2/include)
-    SET(LCMS_LIBNAME lcms2)
-    SET(LCMS2_FOUND 1)
-   ENDIF(NOT LCMS_FOUND AND NOT LCMS2_FOUND)
-#
-   IF(NOT TIFF_FOUND)
-    SET(TIFF_INCLUDE_DIRNAME ${OPENJPEG_SOURCE_DIR}/thirdparty/libtiff)
-    SET(TIFF_LIBNAME tiff)
-    SET(TIFF_FOUND 1)
-   ENDIF(NOT TIFF_FOUND)
-#
-  ENDIF(BUILD_THIRDPARTY)
- ENDIF(NOT ZLIB_FOUND OR NOT PNG_FOUND OR NOT TIFF_FOUND OR LCMS12_MISSING)
-#
-ENDIF(BUILD_CODEC OR BUILD_MJ2)
-#
+# Build the each application if it needed
+
 IF(BUILD_CODEC)
  ADD_SUBDIRECTORY(codec)
 ENDIF(BUILD_CODEC)
-#
+
 IF(BUILD_MJ2)
  ADD_SUBDIRECTORY(mj2)
 ENDIF(BUILD_MJ2)
-#
index 1a25d3101fc0ab07ce0d9c9ce2241fe8e40ab9cf..e39f41f30c8b23a6dcf8a84cfa10f24daf99b847 100644 (file)
@@ -1,4 +1,4 @@
-  # Build the demo app, small examples
+# Build the demo app, small examples
 
 # First thing define the common source:
 SET(common_SRCS
@@ -37,11 +37,7 @@ 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})
-
-  IF(LCMS_FOUND OR LCMS2_FOUND)
-    TARGET_LINK_LIBRARIES(${exe} ${LCMS_LIBNAME})
-  ENDIF(LCMS_FOUND OR LCMS2_FOUND)
+${Z_LIBNAME} ${PNG_LIBNAME} ${TIFF_LIBNAME} ${LCMS_LIBNAME} )
 
   ADD_TEST(${exe} ${EXECUTABLE_OUTPUT_PATH}/${exe})
   # calling those exe without option will make them fail always:
index f510a710761ed9f1a9c811593a4b25813f46303d..c05d8d5540b3efff71fa87131a24e0477cf0155c 100644 (file)
@@ -1,6 +1,6 @@
 /* create config.h for CMake */
 #define PACKAGE_VERSION "@PACKAGE_VERSION@"
-#
+
 #cmakedefine HAVE_INTTYPES_H @HAS_INTTYPES_H@
 #cmakedefine HAVE_MEMORY_H @HAS_MEMORY_H@
 #cmakedefine HAVE_STDINT_H @HAS_STDINT_H@
@@ -14,9 +14,9 @@
 #cmakedefine HAVE_PNG_H  @HAVE_PNG_H@
 #cmakedefine HAVE_LIBTIFF @HAVE_LIBTIFF@
 #cmakedefine HAVE_TIFF_H @HAVE_TIFF_H@
-#
+
 #cmakedefine HAVE_LIBLCMS1 @HAVE_LIBLCMS1@
 #cmakedefine HAVE_LIBLCMS2 @HAVE_LIBLCMS2@
 #cmakedefine HAVE_LCMS1_H @HAVE_LCMS1_H@
 #cmakedefine HAVE_LCMS2_H @HAVE_LCMS2_H@
-#
+
index 08710380d083322169b197c7e9194271da7c8189..c779ff953167614cf81d836b557bf4cf5439f467 100644 (file)
 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-IF(BUILD_THIRDPARTY)
-#
-IF(NOT ZLIB_FOUND)
-  ADD_SUBDIRECTORY(libz)
-ENDIF(NOT ZLIB_FOUND)
-#
-IF(NOT PNG_FOUND)
-  ADD_SUBDIRECTORY(libpng)
-ENDIF(NOT PNG_FOUND)
-#
-IF(NOT LCMS2_FOUND)
-  ADD_SUBDIRECTORY(liblcms2)
-ENDIF(NOT LCMS2_FOUND)
-#
-IF(NOT TIFF_FOUND)
-  ADD_SUBDIRECTORY(libtiff)
-ENDIF(NOT TIFF_FOUND)
-#
-ENDIF(BUILD_THIRDPARTY)
+
+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 used 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")
+    ADD_SUBDIRECTORY(libz)
+    SET(Z_LIBNAME ${ZLIB_LIBRARIES} PARENT_SCOPE)
+    SET(Z_INCLUDE_DIRNAME ${ZLIB_INCLUDE_DIRS} PARENT_SCOPE)
+    SET(ZLIB_FOUND 1)
+  ELSE (BUILD_THIRDPARTY)
+    message("Z lib not found, activate BUILD_THIRDPARTY if you want build it (necessary to build libPNG)")
+  ENDIF(BUILD_THIRDPARTY) 
+    
+ENDIF(ZLIB_FOUND)
+
+#------------
+# Try to find lib PNG (which depends to zlib)
+IF (ZLIB_FOUND)
+  FIND_PACKAGE(PNG)
+
+  IF(PNG_FOUND)
+
+    message("Your system seems to have a PNG lib available, we will used it")
+    SET(HAVE_PNG_H 1 PARENT_SCOPE)
+    SET(HAVE_LIBPNG 1 PARENT_SCOPE)
+    SET(PNG_LIBNAME ${PNG_LIBRARIES} PARENT_SCOPE)
+    SET(PNG_INCLUDE_DIRNAME ${PNG_INCLUDE_DIR} PARENT_SCOPE) 
+    
+  ELSE(PNG_FOUND) # not found
+    
+    IF(BUILD_THIRDPARTY)
+      # Try to build it
+      message("We will build PNG lib from thirdparty")
+      ADD_SUBDIRECTORY(libpng)
+      SET(HAVE_PNG_H 1 PARENT_SCOPE)
+      SET(HAVE_LIBPNG 1 PARENT_SCOPE)
+      SET(PNG_LIBNAME ${PNG_LIBRARIES} PARENT_SCOPE)
+      SET(PNG_INCLUDE_DIRNAME ${PNG_INCLUDE_DIR} PARENT_SCOPE)
+    ELSE (BUILD_THIRDPARTY)
+      SET(HAVE_PNG_H 0 PARENT_SCOPE)
+      SET(HAVE_LIBPNG 0 PARENT_SCOPE)
+      message("PNG lib not found, activate BUILD_THIRDPARTY if you want build it")
+    ENDIF(BUILD_THIRDPARTY) 
+
+  ENDIF(PNG_FOUND)
+  
+ELSE (ZLIB_FOUND)
+  message(WARNING "To add lib PNG we need that ZLIB was previously found")
+ENDIF (ZLIB_FOUND)
+
+#------------
+# Try to find lib TIFF
+FIND_PACKAGE(TIFF)
+
+IF(TIFF_FOUND)
+
+  message("Your system seems to have a TIFF lib available, we will used it")
+  SET(HAVE_TIFF_H 1 PARENT_SCOPE)
+  SET(HAVE_LIBTIFF 1 PARENT_SCOPE)
+  SET(TIFF_LIBNAME ${TIFF_LIBRARIES} PARENT_SCOPE)
+  SET(TIFF_INCLUDE_DIRNAME ${TIFF_INCLUDE_DIR} PARENT_SCOPE) 
+
+ELSE (TIFF_FOUND) # not found
+  
+  IF(BUILD_THIRDPARTY)
+    # Try to build it
+    message("We will build TIFF lib from thirdparty")
+    ADD_SUBDIRECTORY(libtiff)
+    SET(TIFF_LIBNAME ${TIFF_LIBRARIES} PARENT_SCOPE)
+    SET(TIFF_INCLUDE_DIRNAME ${TIFF_INCLUDE_DIR} PARENT_SCOPE)
+    SET(HAVE_TIFF_H 1 PARENT_SCOPE)
+    SET(HAVE_LIBTIFF 1 PARENT_SCOPE)
+  ELSE (BUILD_THIRDPARTY)
+    SET(HAVE_TIFF_H 0 PARENT_SCOPE)
+    SET(HAVE_LIBTIFF 0 PARENT_SCOPE)
+    message("TIFF lib not found, activate BUILD_THIRDPARTY if you want build it")
+  ENDIF(BUILD_THIRDPARTY) 
+    
+ENDIF(TIFF_FOUND)
+
+#------------
+# Try to find lib LCMS2 (or by default LCMS)
+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)
+
+
diff --git a/thirdparty/FindLCMS.cmake b/thirdparty/FindLCMS.cmake
deleted file mode 100644 (file)
index 8125e62..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-# - Find LCMS library
-# Find the native LCMS includes and library
-# This module defines
-#  LCMS_INCLUDE_DIR, where to find tiff.h, etc.
-#  LCMS_LIBRARIES, libraries to link against to use LCMS.
-#  LCMS_FOUND, If false, do not try to use LCMS.
-# also defined, but not for general use are
-#  LCMS_LIBRARY, where to find the LCMS library.
-#
-FIND_PATH(LCMS_INCLUDE_DIR lcms.h  PATHS /usr/include /usr/local/include /opt/include /opt/local/include)
-#
-SET(LCMS_NAMES ${LCMS_NAMES} lcms liblcms liblcms_static)
-FIND_LIBRARY(LCMS_LIBRARY NAMES ${LCMS_NAMES} )
-#
-# handle the QUIETLY and REQUIRED arguments and set LCMS_FOUND to TRUE if
-# all listed variables are TRUE
-INCLUDE(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(LCMS  DEFAULT_MSG  LCMS_LIBRARY  LCMS_INCLUDE_DIR)
-#
-IF(LCMS_FOUND)
-  SET( LCMS_LIBRARIES ${LCMS_LIBRARY} )
-ENDIF(LCMS_FOUND)
-
-MARK_AS_ADVANCED(LCMS_INCLUDE_DIR LCMS_LIBRARY)
diff --git a/thirdparty/FindLCMS2.cmake b/thirdparty/FindLCMS2.cmake
deleted file mode 100644 (file)
index 219800e..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-# - Find LCMS2 library
-# Find the native LCMS2 includes and library
-# This module defines
-#  LCMS2_INCLUDE_DIR, where to find tiff.h, etc.
-#  LCMS2_LIBRARIES, libraries to link against to use LCMS2.
-#  LCMS2_FOUND, If false, do not try to use LCMS2.
-# also defined, but not for general use are
-#  LCMS2_LIBRARY, where to find the LCMS2 library.
-#
-FIND_PATH(LCMS2_INCLUDE_DIR lcms2.h PATHS /usr/include /usr/local/include /opt/include /opt/local/include)
-SET(LCMS2_NAMES ${LCMS2_NAMES} lcms2 liblcms2 liblcms2_static)
-FIND_LIBRARY(LCMS2_LIBRARY NAMES ${LCMS2_NAMES} )
-
-# handle the QUIETLY and REQUIRED arguments and set LCMS2_FOUND to TRUE if 
-# all listed variables are TRUE
-INCLUDE(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(LCMS2  DEFAULT_MSG  LCMS2_LIBRARY  LCMS2_INCLUDE_DIR)
-#
-IF(LCMS2_FOUND)
-  SET( LCMS2_LIBRARIES ${LCMS2_LIBRARY} )
-ENDIF(LCMS2_FOUND)
-#
-MARK_AS_ADVANCED(LCMS2_INCLUDE_DIR LCMS2_LIBRARY)