[trunk] use everywhere the new opj_ prefix for HAVE variables and use the opj_apps_co...
[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     message(STATUS "DEBUG: ${ZLIB_INCLUDE_DIRS} vs ${ZLIB_INCLUDE_DIR}")
20   ELSE (ZLIB_FOUND) # not found
21     message(STATUS "Z lib not found, activate BUILD_THIRDPARTY if you want build it (necessary to build libPNG)")
22   ENDIF(ZLIB_FOUND)
23 ENDIF(BUILD_THIRDPARTY)
24
25
26 #------------
27 # Try to find lib PNG (which depends on zlib)
28 IF(BUILD_THIRDPARTY)
29   # Try to build it
30   message(STATUS "We will build PNG lib from thirdparty")
31   ADD_SUBDIRECTORY(libpng)
32   SET(OPJ_HAVE_PNG_H 1 PARENT_SCOPE)
33   SET(OPJ_HAVE_LIBPNG 1 PARENT_SCOPE)
34   SET(PNG_LIBNAME png PARENT_SCOPE)
35   SET(PNG_INCLUDE_DIRNAME ${OPENJPEG_SOURCE_DIR}/thirdparty/libpng PARENT_SCOPE)
36 ELSE (BUILD_THIRDPARTY)
37   IF (ZLIB_FOUND)
38     FIND_PACKAGE(PNG)
39     IF(PNG_FOUND)
40       message(STATUS "Your system seems to have a PNG lib available, we will use it")
41       SET(OPJ_HAVE_PNG_H 1 PARENT_SCOPE)
42       SET(OPJ_HAVE_LIBPNG 1 PARENT_SCOPE)
43       SET(PNG_LIBNAME ${PNG_LIBRARIES} PARENT_SCOPE)
44       SET(PNG_INCLUDE_DIRNAME ${PNG_PNG_INCLUDE_DIR} PARENT_SCOPE)
45     ELSE(PNG_FOUND) # not found
46       SET(OPJ_HAVE_PNG_H 0 PARENT_SCOPE)
47       SET(OPJ_HAVE_LIBPNG 0 PARENT_SCOPE)
48       message(STATUS "PNG lib not found, activate BUILD_THIRDPARTY if you want build it")
49     ENDIF(PNG_FOUND)
50   ENDIF (ZLIB_FOUND)
51 ENDIF(BUILD_THIRDPARTY)
52
53 #------------
54 # Try to find lib TIFF
55
56 IF(BUILD_THIRDPARTY)
57   # Try to build it
58   message(STATUS "We will build TIFF lib from thirdparty")
59   ADD_SUBDIRECTORY(libtiff)
60   SET(TIFF_LIBNAME tiff PARENT_SCOPE)
61   SET(TIFF_INCLUDE_DIRNAME
62     ${OPENJPEG_SOURCE_DIR}/thirdparty/libtiff
63     ${OPENJPEG_BINARY_DIR}/thirdparty/libtiff
64     PARENT_SCOPE)
65   SET(OPJ_HAVE_TIFF_H 1 PARENT_SCOPE)
66   SET(OPJ_HAVE_LIBTIFF 1 PARENT_SCOPE)
67 ELSE (BUILD_THIRDPARTY)
68   FIND_PACKAGE(TIFF)
69   IF(TIFF_FOUND)
70     message(STATUS "Your system seems to have a TIFF lib available, we will use it")
71     SET(OPJ_HAVE_TIFF_H 1 PARENT_SCOPE)
72     SET(OPJ_HAVE_LIBTIFF 1 PARENT_SCOPE)
73     SET(TIFF_LIBNAME ${TIFF_LIBRARIES} PARENT_SCOPE)
74     SET(TIFF_INCLUDE_DIRNAME ${TIFF_INCLUDE_DIR} PARENT_SCOPE)
75   ELSE (TIFF_FOUND) # not found
76     SET(OPJ_HAVE_TIFF_H 0 PARENT_SCOPE)
77     SET(OPJ_HAVE_LIBTIFF 0 PARENT_SCOPE)
78     message(STATUS "TIFF lib not found, activate BUILD_THIRDPARTY if you want build it")
79   ENDIF(TIFF_FOUND)
80 ENDIF(BUILD_THIRDPARTY)
81
82 #------------
83 # Try to find lib LCMS2 (or by default LCMS)
84 SET(OPJ_HAVE_LCMS_H 0 PARENT_SCOPE)
85 SET(OPJ_HAVE_LIBLCMS 0 PARENT_SCOPE)
86
87 IF( BUILD_THIRDPARTY)
88   # Try to build lcms2
89   message(STATUS "We will build LCMS2 lib from thirdparty")
90   ADD_SUBDIRECTORY(liblcms2)
91   SET(LCMS_LIBNAME lcms2 PARENT_SCOPE)
92   SET(LCMS_INCLUDE_DIRNAME ${OPENJPEG_SOURCE_DIR}/thirdparty/liblcms2/include PARENT_SCOPE) #
93   SET(OPJ_HAVE_LCMS2_H 1 PARENT_SCOPE)
94   SET(OPJ_HAVE_LIBLCMS2 1 PARENT_SCOPE)
95 ELSE (BUILD_THIRDPARTY)
96   FIND_PACKAGE(LCMS2)
97   IF(LCMS2_FOUND)
98     message(STATUS "Your system seems to have a LCMS2 lib available, we will use it")
99     SET(OPJ_HAVE_LCMS2_H 1 PARENT_SCOPE)
100     SET(OPJ_HAVE_LIBLCMS2 1 PARENT_SCOPE)
101     SET(LCMS_LIBNAME ${LCMS2_LIBRARIES} PARENT_SCOPE)
102     SET(LCMS_INCLUDE_DIRNAME ${LCMS2_INCLUDE_DIRS} PARENT_SCOPE)
103   ELSE (LCMS2_FOUND) # not found lcms2
104     # try to find LCMS
105     FIND_PACKAGE(LCMS)
106     IF(LCMS_FOUND)
107       message(STATUS "Your system seems to have a LCMS lib available, we will use it")
108       SET(OPJ_HAVE_LCMS_H 1 PARENT_SCOPE)
109       SET(OPJ_HAVE_LIBLCMS 1 PARENT_SCOPE)
110       SET(LCMS_LIBNAME ${LCMS_LIBRARIES} PARENT_SCOPE)
111       SET(LCMS_INCLUDE_DIRNAME ${LCMS_INCLUDE_DIRS} PARENT_SCOPE)
112     ELSE (LCMS_FOUND) # not found lcms
113       SET(OPJ_HAVE_LCMS2_H 0 PARENT_SCOPE)
114       SET(OPJ_HAVE_LIBLCMS2 0 PARENT_SCOPE)
115       message(STATUS "LCMS2 or LCMS lib not found, activate BUILD_THIRDPARTY if you want build it")
116     ENDIF (LCMS_FOUND)
117   ENDIF(LCMS2_FOUND)
118 ENDIF(BUILD_THIRDPARTY)