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