Avoided ABI breakage
[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   )
7 # Then check if getopt is present:
8 INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
9 SET(DONT_HAVE_GETOPT 1)
10 IF(UNIX) #I am pretty sure only *nix sys have this anyway
11   CHECK_INCLUDE_FILE("getopt.h" CMAKE_HAVE_GETOPT_H)
12   # Seems like we need the contrary:
13   IF(CMAKE_HAVE_GETOPT_H)
14     SET(DONT_HAVE_GETOPT 0)
15   ENDIF(CMAKE_HAVE_GETOPT_H)
16 ENDIF(UNIX)
17
18 # If not getopt was found then add it to the lib:
19 IF(DONT_HAVE_GETOPT)
20   ADD_DEFINITIONS(-DDONT_HAVE_GETOPT)
21   SET(common_SRCS
22     ${common_SRCS}
23     compat/getopt.c
24   )
25 ENDIF(DONT_HAVE_GETOPT)
26
27
28 # Headers file are located here:
29 INCLUDE_DIRECTORIES(
30   ${OPENJPEG_SOURCE_DIR}/libopenjpeg
31   )
32
33 # Do the proper thing when building static...if only there was configured
34 # headers or def files instead
35 IF(NOT BUILD_SHARED_LIBS)
36   ADD_DEFINITIONS(-DOPJ_STATIC)
37 ENDIF(NOT BUILD_SHARED_LIBS)
38
39 FIND_PACKAGE(TIFF REQUIRED)
40
41 # Loop over all executables:
42 FOREACH(exe j2k_to_image image_to_j2k)
43   ADD_EXECUTABLE(${exe} ${exe}.c ${common_SRCS})
44   TARGET_LINK_LIBRARIES(${exe} ${OPJ_PREFIX}openjpeg ${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:
49   IF(UNIX)
50     TARGET_LINK_LIBRARIES(${exe} m)
51   ENDIF(UNIX)
52   # Install exe
53   INSTALL_TARGETS(/bin/ ${exe})
54 ENDFOREACH(exe)
55
56 # Do testing here, once we know the examples are being built:
57 FILE(GLOB_RECURSE OPENJPEG_DATA_IMAGES_GLOB
58   "${JPEG2000_CONFORMANCE_DATA_ROOT}/*.j2k"
59   "${JPEG2000_CONFORMANCE_DATA_ROOT}/*.j2c"
60   "${JPEG2000_CONFORMANCE_DATA_ROOT}/*.jp2"
61   )
62
63 FOREACH(filename ${OPENJPEG_DATA_IMAGES_GLOB})
64   GET_FILENAME_COMPONENT(filename_temp ${filename} NAME)
65   ADD_TEST(j2i-${filename_temp} ${EXECUTABLE_OUTPUT_PATH}/j2k_to_image -i ${filename} -o ${filename_temp}.tif)
66 ENDFOREACH(filename)
67