1 # Build the demo app, small examples
3 # First thing define the common source:
7 ${OPENJPEG_SOURCE_DIR}/common/color.c
10 # If not getopt was found then add it to the lib:
14 ${OPENJPEG_SOURCE_DIR}/common/getopt.c
16 ENDIF(DONT_HAVE_GETOPT)
18 # Headers file are located here:
20 ${OPENJPEG_SOURCE_DIR}/libopenjpeg
21 ${LCMS_INCLUDE_DIRNAME}
22 ${OPENJPEG_SOURCE_DIR}/common
24 ${PNG_INCLUDE_DIRNAME}
25 ${TIFF_INCLUDE_DIRNAME}
30 ADD_DEFINITIONS(-DOPJ_EXPORTS)
31 ELSE(BUILD_SHARED_LIBS)
32 ADD_DEFINITIONS(-DOPJ_STATIC)
33 ENDIF(BUILD_SHARED_LIBS)
36 # Loop over all executables:
37 FOREACH(exe j2k_to_image image_to_j2k j2k_dump)
38 ADD_EXECUTABLE(${exe} ${exe}.c ${common_SRCS})
39 TARGET_LINK_LIBRARIES(${exe} ${OPENJPEG_LIBRARY_NAME}
40 ${LCMS_LIBNAME} ${Z_LIBNAME} ${PNG_LIBNAME} ${TIFF_LIBNAME})
42 ADD_TEST(${exe} ${EXECUTABLE_OUTPUT_PATH}/${exe})
43 # calling those exe without option will make them fail always:
44 SET_TESTS_PROPERTIES(${exe} PROPERTIES WILL_FAIL TRUE)
45 # On unix you need to link to the math library:
47 TARGET_LINK_LIBRARIES(${exe} m)
50 INSTALL(TARGETS ${exe}
51 EXPORT OpenJPEGTargets
52 DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
58 FILES ../doc/man/man1/image_to_j2k.1
59 ../doc/man/man1/j2k_dump.1
60 ../doc/man/man1/j2k_to_image.1
61 DESTINATION ${OPENJPEG_INSTALL_MAN_DIR}/man1)
65 # Do testing here, once we know the examples are being built:
66 FILE(GLOB_RECURSE OPENJPEG_DATA_IMAGES_GLOB
67 "${JPEG2000_CONFORMANCE_DATA_ROOT}/*.j2k"
68 "${JPEG2000_CONFORMANCE_DATA_ROOT}/*.j2c"
69 "${JPEG2000_CONFORMANCE_DATA_ROOT}/*.jp2"
72 foreach(filename ${OPENJPEG_DATA_IMAGES_GLOB})
73 get_filename_component(filename_temp ${filename} NAME)
74 get_filename_component(filename_ext ${filename} EXT)
75 execute_process(COMMAND ${EXECUTABLE_OUTPUT_PATH}/j2k_dump -i ${filename}
76 OUTPUT_VARIABLE dump_success
77 OUTPUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/${filename_temp}.dump
81 file(READ ${CMAKE_CURRENT_BINARY_DIR}/${filename_temp}.dump numcomp_file)
82 string(REGEX REPLACE ".*numcomps=([0-9]+).*" "\\1"
83 numcomps "${numcomp_file}")
84 #message( "found:${output_variable} for ${filename_temp}" )
86 ADD_TEST(dump-${filename_temp} ${EXECUTABLE_OUTPUT_PATH}/j2k_dump -i ${filename})
87 foreach(codec_type ppm pgx bmp tif raw tga png)
88 ADD_TEST(j2i-${filename_temp}-${codec_type} ${EXECUTABLE_OUTPUT_PATH}/j2k_to_image -i ${filename} -o ${filename_temp}.${codec_type})
89 endforeach(codec_type)
90 foreach(codec_type ppm bmp tif tga png)
91 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})
93 # ADD_TEST(cmp-${filename_temp}-${codec_type} cmp ${filename} ${filename_temp}.${codec_type}${filename_ext})
95 endforeach(codec_type)