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