First import of JAVAOpenJPEG, a Java wrapper of OpenJPEG, developed by Patrick Piscag...
[openjpeg.git] / codec / CMakeLists.txt
1 # Build the demo app, small examples
2
3 # First thing define the common source:
4 SET(common_SRCS
5   convert.c
6   index.c
7 )
8
9 # Then check if getopt is present:
10 INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
11 SET(DONT_HAVE_GETOPT 1)
12 IF(UNIX) #I am pretty sure only *nix sys have this anyway
13   CHECK_INCLUDE_FILE("getopt.h" CMAKE_HAVE_GETOPT_H)
14   # Seems like we need the contrary:
15   IF(CMAKE_HAVE_GETOPT_H)
16     SET(DONT_HAVE_GETOPT 0)
17   ENDIF(CMAKE_HAVE_GETOPT_H)
18 ENDIF(UNIX)
19
20 # If not getopt was found then add it to the lib:
21 IF(DONT_HAVE_GETOPT)
22   ADD_DEFINITIONS(-DDONT_HAVE_GETOPT)
23   SET(common_SRCS
24     ${common_SRCS}
25     compat/getopt.c
26   )
27 ENDIF(DONT_HAVE_GETOPT)
28
29 # Headers file are located here:
30 INCLUDE_DIRECTORIES(
31   ${OPENJPEG_SOURCE_DIR}/libopenjpeg
32   )
33
34 # Do the proper thing when building static...if only there was configured
35 # headers or def files instead
36 IF(NOT BUILD_SHARED_LIBS)
37   ADD_DEFINITIONS(-DOPJ_STATIC)
38 ENDIF(NOT BUILD_SHARED_LIBS)
39
40 FIND_PACKAGE(TIFF REQUIRED)
41
42 # Loop over all executables:
43 FOREACH(exe j2k_to_image image_to_j2k)
44   ADD_EXECUTABLE(${exe} ${exe}.c ${common_SRCS})
45   TARGET_LINK_LIBRARIES(${exe} ${OPJ_PREFIX}openjpeg ${TIFF_LIBRARIES})
46   ADD_TEST(${exe} ${EXECUTABLE_OUTPUT_PATH}/${exe})
47   # calling those exe without option will make them fail always:
48   SET_TESTS_PROPERTIES(${exe} PROPERTIES WILL_FAIL TRUE)
49   # On unix you need to link to the math library:
50   IF(UNIX)
51     TARGET_LINK_LIBRARIES(${exe} m)
52   ENDIF(UNIX)
53   # Install exe
54   INSTALL_TARGETS(/bin/ ${exe})
55 ENDFOREACH(exe)
56
57 # Do testing here, once we know the examples are being built:
58 FILE(GLOB_RECURSE OPENJPEG_DATA_IMAGES_GLOB
59   "${JPEG2000_CONFORMANCE_DATA_ROOT}/*.j2k"
60   "${JPEG2000_CONFORMANCE_DATA_ROOT}/*.j2c"
61   "${JPEG2000_CONFORMANCE_DATA_ROOT}/*.jp2"
62   )
63
64 FOREACH(filename ${OPENJPEG_DATA_IMAGES_GLOB})
65   GET_FILENAME_COMPONENT(filename_temp ${filename} NAME)
66   ADD_TEST(j2i-${filename_temp} ${EXECUTABLE_OUTPUT_PATH}/j2k_to_image -i ${filename} -o ${filename_temp}.tif)
67 ENDFOREACH(filename)
68