1 # Build the demo app, small examples
3 # First thing define the common source:
9 # If not getopt was found then add it to the lib:
15 ENDIF(DONT_HAVE_GETOPT)
17 # Do the proper thing when building static...if only there was configured
18 # headers or def files instead
19 IF(NOT BUILD_SHARED_LIBS)
20 ADD_DEFINITIONS(-DOPJ_STATIC)
21 ENDIF(NOT BUILD_SHARED_LIBS)
23 # Headers file are located here:
25 ${OPENJPEG_SOURCE_DIR}/libopenjpeg
29 INCLUDE_DIRECTORIES(${PNG_INCLUDE_DIR})
32 INCLUDE_DIRECTORIES(${TIFF_INCLUDE_DIR})
35 # Loop over all executables:
36 FOREACH(exe j2k_to_image image_to_j2k j2k_dump)
37 ADD_EXECUTABLE(${exe} ${exe}.c ${common_SRCS})
38 TARGET_LINK_LIBRARIES(${exe} ${OPJ_PREFIX}openjpeg ${LCMS_LIB})
40 TARGET_LINK_LIBRARIES(${exe} ${PNG_LIBRARIES})
43 TARGET_LINK_LIBRARIES(${exe} ${TIFF_LIBRARIES})
45 ADD_TEST(${exe} ${EXECUTABLE_OUTPUT_PATH}/${exe})
46 # calling those exe without option will make them fail always:
47 SET_TESTS_PROPERTIES(${exe} PROPERTIES WILL_FAIL TRUE)
48 # On unix you need to link to the math library:
50 TARGET_LINK_LIBRARIES(${exe} m)
53 INSTALL(TARGETS ${exe}
54 EXPORT OpenJPEGTargets
55 DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
60 # Do testing here, once we know the examples are being built:
61 FILE(GLOB_RECURSE OPENJPEG_DATA_IMAGES_GLOB
62 "${JPEG2000_CONFORMANCE_DATA_ROOT}/*.j2k"
63 "${JPEG2000_CONFORMANCE_DATA_ROOT}/*.j2c"
64 "${JPEG2000_CONFORMANCE_DATA_ROOT}/*.jp2"
67 foreach(filename ${OPENJPEG_DATA_IMAGES_GLOB})
68 get_filename_component(filename_temp ${filename} NAME)
69 get_filename_component(filename_ext ${filename} EXT)
70 execute_process(COMMAND ${EXECUTABLE_OUTPUT_PATH}/j2k_dump -i ${filename}
71 OUTPUT_VARIABLE dump_success
72 OUTPUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/${filename_temp}.dump
76 file(READ ${CMAKE_CURRENT_BINARY_DIR}/${filename_temp}.dump numcomp_file)
77 string(REGEX REPLACE ".*numcomps=([0-9]+).*" "\\1"
78 numcomps "${numcomp_file}")
79 #message( "found:${output_variable} for ${filename_temp}" )
81 ADD_TEST(dump-${filename_temp} ${EXECUTABLE_OUTPUT_PATH}/j2k_dump -i ${filename})
82 foreach(codec_type ppm pgx bmp tif raw tga png)
83 ADD_TEST(j2i-${filename_temp}-${codec_type} ${EXECUTABLE_OUTPUT_PATH}/j2k_to_image -i ${filename} -o ${filename_temp}.${codec_type})
84 ADD_TEST(i2j-${filename_temp}-${codec_type} ${EXECUTABLE_OUTPUT_PATH}/image_to_j2k -i ${filename_temp}.${codec_type} -o ${filename_temp}.${codec_type}${filename_ext})
86 # ADD_TEST(cmp-${filename_temp}-${codec_type} cmp ${filename} ${filename_temp}.${codec_type}${filename_ext})
88 endforeach(codec_type)