[trunk] import JPIP modifications for build-system from 1.5
[openjpeg.git] / thirdparty / CMakeLists.txt
1 # 3rd party libs  
2
3 #------------
4 # Try to find lib Z
5 IF(BUILD_THIRDPARTY)
6   # Try to build it
7   message(STATUS "We will build Z lib from thirdparty")
8   ADD_SUBDIRECTORY(libz)
9   SET(Z_LIBNAME z PARENT_SCOPE)
10   SET(Z_INCLUDE_DIRNAME ${OPENJPEG_SOURCE_DIR}/thirdparty/include PARENT_SCOPE)
11   SET(ZLIB_FOUND 1)
12 ELSE (BUILD_THIRDPARTY)
13   # Try to find lib Z
14   FIND_PACKAGE(ZLIB)
15   IF(ZLIB_FOUND)
16     SET(Z_LIBNAME ${ZLIB_LIBRARIES} PARENT_SCOPE)
17     SET(Z_INCLUDE_DIRNAME ${ZLIB_INCLUDE_DIRS} PARENT_SCOPE) 
18     message(STATUS "Your system seems to have a Z lib available, we will use it to generate PNG lib")
19   ELSE (ZLIB_FOUND) # not found
20     message(STATUS "Z lib not found, activate BUILD_THIRDPARTY if you want build it (necessary to build libPNG)")
21   ENDIF(ZLIB_FOUND)
22 ENDIF(BUILD_THIRDPARTY) 
23     
24
25 #------------
26 # Try to find lib PNG (which depends on zlib)
27 IF(BUILD_THIRDPARTY)
28   # Try to build it
29   message(STATUS "We will build PNG lib from thirdparty")
30   ADD_SUBDIRECTORY(libpng)
31   SET(HAVE_PNG_H 1 PARENT_SCOPE)
32   SET(HAVE_LIBPNG 1 PARENT_SCOPE)
33   SET(PNG_LIBNAME png PARENT_SCOPE)
34   SET(PNG_INCLUDE_DIRNAME ${OPENJPEG_SOURCE_DIR}/thirdparty/libpng PARENT_SCOPE)
35 ELSE (BUILD_THIRDPARTY)
36   IF (ZLIB_FOUND)
37     FIND_PACKAGE(PNG)
38     IF(PNG_FOUND)
39       message(STATUS "Your system seems to have a PNG lib available, we will use it")
40       SET(HAVE_PNG_H 1 PARENT_SCOPE)
41       SET(HAVE_LIBPNG 1 PARENT_SCOPE)
42       SET(PNG_LIBNAME ${PNG_LIBRARIES} PARENT_SCOPE)
43       SET(PNG_INCLUDE_DIRNAME ${PNG_PNG_INCLUDE_DIR} PARENT_SCOPE) 
44     ELSE(PNG_FOUND) # not found
45       SET(HAVE_PNG_H 0 PARENT_SCOPE)
46       SET(HAVE_LIBPNG 0 PARENT_SCOPE)
47       message(STATUS "PNG lib not found, activate BUILD_THIRDPARTY if you want build it")
48     ENDIF(PNG_FOUND)
49   ENDIF (ZLIB_FOUND)
50 ENDIF(BUILD_THIRDPARTY) 
51
52 #------------
53 # Try to find lib TIFF
54   
55 IF(BUILD_THIRDPARTY)
56   # Try to build it
57   message(STATUS "We will build TIFF lib from thirdparty")
58   ADD_SUBDIRECTORY(libtiff)
59   SET(TIFF_LIBNAME tiff PARENT_SCOPE)
60   SET(TIFF_INCLUDE_DIRNAME ${OPENJPEG_SOURCE_DIR}/thirdparty/libtiff PARENT_SCOPE)
61   SET(HAVE_TIFF_H 1 PARENT_SCOPE)
62   SET(HAVE_LIBTIFF 1 PARENT_SCOPE)
63 ELSE (BUILD_THIRDPARTY)
64   FIND_PACKAGE(TIFF)
65   IF(TIFF_FOUND)
66     message(STATUS "Your system seems to have a TIFF lib available, we will use it")
67     SET(HAVE_TIFF_H 1 PARENT_SCOPE)
68     SET(HAVE_LIBTIFF 1 PARENT_SCOPE)
69     SET(TIFF_LIBNAME ${TIFF_LIBRARIES} PARENT_SCOPE)
70     SET(TIFF_INCLUDE_DIRNAME ${TIFF_INCLUDE_DIR} PARENT_SCOPE) 
71   ELSE (TIFF_FOUND) # not found
72     SET(HAVE_TIFF_H 0 PARENT_SCOPE)
73     SET(HAVE_LIBTIFF 0 PARENT_SCOPE)
74     message(STATUS "TIFF lib not found, activate BUILD_THIRDPARTY if you want build it")
75   ENDIF(TIFF_FOUND)
76 ENDIF(BUILD_THIRDPARTY) 
77
78 #------------
79 # Try to find lib LCMS2 (or by default LCMS)
80 SET(HAVE_LCMS_H 0 PARENT_SCOPE)
81 SET(HAVE_LIBLCMS 0 PARENT_SCOPE)
82
83 IF( BUILD_THIRDPARTY)
84   # Try to build lcms2
85   message(STATUS "We will build LCMS2 lib from thirdparty")
86   ADD_SUBDIRECTORY(liblcms2)
87   SET(LCMS_LIBNAME lcms2 PARENT_SCOPE)
88   SET(LCMS_INCLUDE_DIRNAME ${OPENJPEG_SOURCE_DIR}/thirdparty/liblcms2/include PARENT_SCOPE) #
89   SET(HAVE_LCMS2_H 1 PARENT_SCOPE)
90   SET(HAVE_LIBLCMS2 1 PARENT_SCOPE)
91 ELSE (BUILD_THIRDPARTY)
92   FIND_PACKAGE(LCMS2)
93   IF(LCMS2_FOUND)
94     message(STATUS "Your system seems to have a LCMS2 lib available, we will use it")
95     SET(HAVE_LCMS2_H 1 PARENT_SCOPE)
96     SET(HAVE_LIBLCMS2 1 PARENT_SCOPE)
97     SET(LCMS_LIBNAME ${LCMS2_LIBRARIES} PARENT_SCOPE)
98     SET(LCMS_INCLUDE_DIRNAME ${LCMS2_INCLUDE_DIRS} PARENT_SCOPE) 
99   ELSE (LCMS2_FOUND) # not found lcms2
100     # try to find LCMS
101     FIND_PACKAGE(LCMS)  
102     IF(LCMS_FOUND)
103       message(STATUS "Your system seems to have a LCMS lib available, we will use it")
104       SET(HAVE_LCMS_H 1 PARENT_SCOPE)
105       SET(HAVE_LIBLCMS 1 PARENT_SCOPE)
106       SET(LCMS_LIBNAME ${LCMS_LIBRARIES} PARENT_SCOPE)
107       SET(LCMS_INCLUDE_DIRNAME ${LCMS_INCLUDE_DIRS} PARENT_SCOPE) 
108     ELSE (LCMS_FOUND) # not found lcms
109       SET(HAVE_LCMS2_H 0 PARENT_SCOPE)
110       SET(HAVE_LIBLCMS2 0 PARENT_SCOPE)
111       message(STATUS "LCMS2 or LCMS lib not found, activate BUILD_THIRDPARTY if you want build it")
112     ENDIF (LCMS_FOUND)
113   ENDIF(LCMS2_FOUND)
114 ENDIF(BUILD_THIRDPARTY)