d583c2e6bb16c9e6b46893d97eeb202369b50d7a
[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   endif()
61   # Install exe
62   install(TARGETS ${exe}
63     EXPORT OpenJPEGTargets
64     DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
65   )
66   if(OPJ_USE_DSYMUTIL)
67     add_custom_command(TARGET ${exe} POST_BUILD 
68     COMMAND "dsymutil" "$<TARGET_FILE:${exe}>"
69     COMMENT "dsymutil $<TARGET_FILE:${exe}>"
70     DEPENDS ${exe})
71   endif()
72 endforeach()
73
74 if(BUILD_DOC)
75 # Install man pages
76 install(
77   FILES       ${OPENJPEG_SOURCE_DIR}/doc/man/man1/opj_compress.1
78               ${OPENJPEG_SOURCE_DIR}/doc/man/man1/opj_decompress.1
79               ${OPENJPEG_SOURCE_DIR}/doc/man/man1/opj_dump.1
80   DESTINATION ${OPENJPEG_INSTALL_MAN_DIR}/man1)
81 #
82 endif()