Reactivate ctest
[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 FIND_PACKAGE(PNG REQUIRED)
42
43 # Loop over all executables:
44 FOREACH(exe j2k_to_image image_to_j2k)
45   ADD_EXECUTABLE(${exe} ${exe}.c ${common_SRCS})
46   TARGET_LINK_LIBRARIES(${exe} ${OPJ_PREFIX}openjpeg ${TIFF_LIBRARIES} ${PNG_LIBRARIES})
47   ADD_TEST(${exe} ${EXECUTABLE_OUTPUT_PATH}/${exe})
48   # calling those exe without option will make them fail always:
49   SET_TESTS_PROPERTIES(${exe} PROPERTIES WILL_FAIL TRUE)
50   # On unix you need to link to the math library:
51   IF(UNIX)
52     TARGET_LINK_LIBRARIES(${exe} m)
53   ENDIF(UNIX)
54   # Install exe
55   INSTALL_TARGETS(/bin/ ${exe})
56 ENDFOREACH(exe)
57
58 # Do testing here, once we know the examples are being built:
59 FILE(GLOB_RECURSE OPENJPEG_DATA_IMAGES_GLOB
60   "${JPEG2000_CONFORMANCE_DATA_ROOT}/*.j2k"
61   "${JPEG2000_CONFORMANCE_DATA_ROOT}/*.j2c"
62   "${JPEG2000_CONFORMANCE_DATA_ROOT}/*.jp2"
63   )
64
65 FOREACH(filename ${OPENJPEG_DATA_IMAGES_GLOB})
66   GET_FILENAME_COMPONENT(filename_temp ${filename} NAME)
67   ADD_TEST(j2i-${filename_temp} ${EXECUTABLE_OUTPUT_PATH}/j2k_to_image -i ${filename} -o ${filename_temp}.tif)
68 ENDFOREACH(filename)
69