[trunk] properly handle pkg-config on non-UNIX hosts
[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   index.c
7   ${OPENJPEG_SOURCE_DIR}/src/bin/common/color.c
8   ${OPENJPEG_SOURCE_DIR}/src/bin/common/opj_getopt.c
9   )
10
11 # Headers file are located here:
12 include_directories(
13   ${OPENJPEG_BINARY_DIR}/src/lib/openjp2 # opj_config.h
14   ${OPENJPEG_BINARY_DIR}/src/bin/common # opj_apps_config.h
15   ${OPENJPEG_SOURCE_DIR}/src/lib/openjp2
16   ${OPENJPEG_SOURCE_DIR}/src/bin/common
17   ${LCMS_INCLUDE_DIRNAME}
18   ${Z_INCLUDE_DIRNAME}
19   ${PNG_INCLUDE_DIRNAME}
20   ${TIFF_INCLUDE_DIRNAME}
21   )
22
23 if(WIN32)
24   if(BUILD_SHARED_LIBS)
25     add_definitions(-DOPJ_EXPORTS)
26   else()
27     add_definitions(-DOPJ_STATIC)
28   endif()
29 endif()
30
31 # Loop over all executables:
32 foreach(exe opj_decompress opj_compress opj_dump)
33   add_executable(${exe} ${exe}.c ${common_SRCS})
34   target_link_libraries(${exe} ${OPENJPEG_LIBRARY_NAME}
35     ${PNG_LIBNAME} ${TIFF_LIBNAME} ${LCMS_LIBNAME}
36     )
37   # To support universal exe:
38   if(ZLIB_FOUND AND APPLE)
39     target_link_libraries(${exe} z)
40   else(ZLIB_FOUND AND APPLE)
41     target_link_libraries(${exe} ${Z_LIBNAME})
42   endif()
43
44   # On unix you need to link to the math library:
45   if(UNIX)
46     target_link_libraries(${exe} m)
47   endif()
48   # Install exe
49   install(TARGETS ${exe}
50     EXPORT OpenJPEGTargets
51     DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
52   )
53 endforeach()
54
55 if(BUILD_DOC)
56 # Install man pages
57 install(
58   FILES       ${OPENJPEG_SOURCE_DIR}/doc/man/man1/opj_compress.1
59               ${OPENJPEG_SOURCE_DIR}/doc/man/man1/opj_decompress.1
60               ${OPENJPEG_SOURCE_DIR}/doc/man/man1/opj_dump.1
61   DESTINATION ${OPENJPEG_INSTALL_MAN_DIR}/man1)
62 #
63 endif()