1 # Build the demo app, small examples
3 # First thing define the common source:
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)
20 # If not getopt was found then add it to the lib:
22 ADD_DEFINITIONS(-DDONT_HAVE_GETOPT)
27 ENDIF(DONT_HAVE_GETOPT)
29 # Headers file are located here:
31 ${OPENJPEG_SOURCE_DIR}/libopenjpeg
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)
40 FIND_PACKAGE(TIFF REQUIRED)
41 FIND_PACKAGE(PNG REQUIRED)
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:
52 TARGET_LINK_LIBRARIES(${exe} m)
55 INSTALL(TARGETS ${exe}
56 EXPORT OpenJPEGTargets
57 DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
62 # Do testing here, once we know the examples are being built:
63 FILE(GLOB_RECURSE OPENJPEG_DATA_IMAGES_GLOB
64 "${JPEG2000_CONFORMANCE_DATA_ROOT}/*.j2k"
65 "${JPEG2000_CONFORMANCE_DATA_ROOT}/*.j2c"
66 "${JPEG2000_CONFORMANCE_DATA_ROOT}/*.jp2"
69 foreach(filename ${OPENJPEG_DATA_IMAGES_GLOB})
70 get_filename_component(filename_temp ${filename} NAME)
71 get_filename_component(filename_ext ${filename} EXT)
72 foreach(codec_type ppm pgx bmp tif raw tga)
73 ADD_TEST(j2i-${filename_temp}-${codec_type} ${EXECUTABLE_OUTPUT_PATH}/j2k_to_image -i ${filename} -o ${filename_temp}.${codec_type})
74 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})
76 # ADD_TEST(cmp-${filename_temp}-${codec_type} cmp ${filename} ${filename_temp}.${codec_type}${filename_ext})
78 endforeach(codec_type)