opj_decompress: use clock_gettime() instead of getrusage() so as to get the time...
[openjpeg.git] / src / bin / jp2 / 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   convert.h
7   convertbmp.c
8   index.c
9   index.h
10   ${OPENJPEG_SOURCE_DIR}/src/bin/common/color.c
11   ${OPENJPEG_SOURCE_DIR}/src/bin/common/color.h
12   ${OPENJPEG_SOURCE_DIR}/src/bin/common/opj_getopt.c
13   ${OPENJPEG_SOURCE_DIR}/src/bin/common/opj_getopt.h
14   ${OPENJPEG_SOURCE_DIR}/src/bin/common/opj_string.h
15   )
16
17 if(OPJ_HAVE_LIBTIFF)
18         list(APPEND common_SRCS converttif.c)
19 endif()
20 if(OPJ_HAVE_LIBPNG)
21         list(APPEND common_SRCS convertpng.c)
22 endif()
23
24 # Headers file are located here:
25 include_directories(
26   ${OPENJPEG_BINARY_DIR}/src/lib/openjp2 # opj_config.h
27   ${OPENJPEG_BINARY_DIR}/src/bin/common # opj_apps_config.h
28   ${OPENJPEG_SOURCE_DIR}/src/lib/openjp2
29   ${OPENJPEG_SOURCE_DIR}/src/bin/common
30   ${LCMS_INCLUDE_DIRNAME}
31   ${Z_INCLUDE_DIRNAME}
32   ${PNG_INCLUDE_DIRNAME}
33   ${TIFF_INCLUDE_DIRNAME}
34   )
35
36 if(WIN32)
37   if(BUILD_SHARED_LIBS)
38     add_definitions(-DOPJ_EXPORTS)
39   else()
40     add_definitions(-DOPJ_STATIC)
41   endif()
42 endif()
43
44 # Loop over all executables:
45 foreach(exe opj_decompress opj_compress opj_dump)
46   add_executable(${exe} ${exe}.c ${common_SRCS})
47   target_link_libraries(${exe} ${OPENJPEG_LIBRARY_NAME}
48     ${PNG_LIBNAME} ${TIFF_LIBNAME} ${LCMS_LIBNAME}
49     )
50   # To support universal exe:
51   if(ZLIB_FOUND AND APPLE)
52     target_link_libraries(${exe} z)
53   else(ZLIB_FOUND AND APPLE)
54     target_link_libraries(${exe} ${Z_LIBNAME})
55   endif()
56
57   # On unix you need to link to the math library:
58   if(UNIX)
59     target_link_libraries(${exe} m)
60     IF("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
61       target_link_libraries(${exe} rt)
62     endif()
63   endif()
64   # Install exe
65   install(TARGETS ${exe}
66     EXPORT OpenJPEGTargets
67     DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
68   )
69   if(OPJ_USE_DSYMUTIL)
70     add_custom_command(TARGET ${exe} POST_BUILD
71     COMMAND "dsymutil" "$<TARGET_FILE:${exe}>"
72     COMMENT "dsymutil $<TARGET_FILE:${exe}>"
73     DEPENDS ${exe})
74   endif()
75 endforeach()
76
77 if(BUILD_DOC)
78 # Install man pages
79 install(
80   FILES       ${OPENJPEG_SOURCE_DIR}/doc/man/man1/opj_compress.1
81               ${OPENJPEG_SOURCE_DIR}/doc/man/man1/opj_decompress.1
82               ${OPENJPEG_SOURCE_DIR}/doc/man/man1/opj_dump.1
83   DESTINATION ${OPENJPEG_INSTALL_MAN_DIR}/man1)
84 #
85 endif()