[trunk] properly handle pkg-config on non-UNIX hosts
[openjpeg.git] / src / lib / openjp2 / CMakeLists.txt
1 include_regular_expression("^.*$")
2
3 #
4 install( FILES  ${CMAKE_CURRENT_BINARY_DIR}/opj_config.h
5  DESTINATION ${OPENJPEG_INSTALL_INCLUDE_DIR} COMPONENT Headers)
6
7 include_directories(
8   ${OPENJPEG_BINARY_DIR}/src/lib/openjp2 # opj_config.h and opj_config_private.h
9 )
10 # Defines the source code for the library
11 set(OPENJPEG_SRCS
12   ${CMAKE_CURRENT_SOURCE_DIR}/bio.c
13   ${CMAKE_CURRENT_SOURCE_DIR}/cio.c
14   ${CMAKE_CURRENT_SOURCE_DIR}/dwt.c
15   ${CMAKE_CURRENT_SOURCE_DIR}/event.c
16   ${CMAKE_CURRENT_SOURCE_DIR}/image.c
17   ${CMAKE_CURRENT_SOURCE_DIR}/invert.c
18   ${CMAKE_CURRENT_SOURCE_DIR}/j2k.c
19   ${CMAKE_CURRENT_SOURCE_DIR}/jp2.c
20   ${CMAKE_CURRENT_SOURCE_DIR}/mct.c
21   ${CMAKE_CURRENT_SOURCE_DIR}/mqc.c
22   ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg.c
23   ${CMAKE_CURRENT_SOURCE_DIR}/opj_clock.c
24   ${CMAKE_CURRENT_SOURCE_DIR}/pi.c
25   ${CMAKE_CURRENT_SOURCE_DIR}/raw.c
26   ${CMAKE_CURRENT_SOURCE_DIR}/t1.c
27   ${CMAKE_CURRENT_SOURCE_DIR}/t2.c
28   ${CMAKE_CURRENT_SOURCE_DIR}/tcd.c
29   ${CMAKE_CURRENT_SOURCE_DIR}/tgt.c
30   ${CMAKE_CURRENT_SOURCE_DIR}/function_list.c
31 )
32 if(BUILD_JPIP)
33   add_definitions(-DUSE_JPIP)
34   set(OPENJPEG_SRCS
35     ${OPENJPEG_SRCS}
36     ${CMAKE_CURRENT_SOURCE_DIR}/cidx_manager.c
37     ${CMAKE_CURRENT_SOURCE_DIR}/phix_manager.c
38     ${CMAKE_CURRENT_SOURCE_DIR}/ppix_manager.c
39     ${CMAKE_CURRENT_SOURCE_DIR}/thix_manager.c
40     ${CMAKE_CURRENT_SOURCE_DIR}/tpix_manager.c
41   )
42 endif()
43
44 # Build the library
45 if(WIN32)
46   if(BUILD_SHARED_LIBS)
47     add_definitions(-DOPJ_EXPORTS)
48   else()
49     add_definitions(-DOPJ_STATIC)
50   endif()
51 endif()
52 add_library(${OPENJPEG_LIBRARY_NAME} ${OPENJPEG_SRCS})
53 if(UNIX)
54   target_link_libraries(${OPENJPEG_LIBRARY_NAME} m)
55 endif()
56 set_target_properties(${OPENJPEG_LIBRARY_NAME} PROPERTIES ${OPENJPEG_LIBRARY_PROPERTIES})
57
58 # Install library
59 install(TARGETS ${OPENJPEG_LIBRARY_NAME}
60   EXPORT OpenJPEGTargets
61   RUNTIME DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
62   LIBRARY DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT Libraries
63   ARCHIVE DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT Libraries
64 )
65
66 # Install includes files
67 install(FILES openjpeg.h opj_stdint.h
68   DESTINATION ${OPENJPEG_INSTALL_INCLUDE_DIR} COMPONENT Headers
69 )
70
71 if(BUILD_DOC)
72 # install man page of the library
73 install(
74   FILES       ${OPENJPEG_SOURCE_DIR}/doc/man/man3/libopenjp2.3
75   DESTINATION ${OPENJPEG_INSTALL_MAN_DIR}/man3)
76 endif()
77
78 # internal utilities to generate t1_luts.h (part of the jp2 lib)
79 # no need to install:
80 add_executable(t1_generate_luts t1_generate_luts.c)
81 if(UNIX)
82   target_link_libraries(t1_generate_luts m)
83 endif()
84
85 # Experimental option; let's how cppcheck performs
86 # Implementation details:
87 # I could not figure out how to easily upload a file to CDash. Instead simply
88 # pretend cppcheck is part of the Build step. Technically cppcheck can even
89 # output gcc formatted error/warning report
90 # Another implementation detail: I could not redirect error to the error
91 # catching mechanism something is busted in cmake 2.8.5, I had to use the
92 # warning regex to catch them.
93 if(OPENJPEG_CPPCHECK)
94   find_package(CPPCHECK REQUIRED)
95   foreach(f ${OPENJPEG_SRCS})
96     # cppcheck complains about too many configuration, pretend to be WIN32:
97     add_custom_command(TARGET ${OPENJPEG_LIBRARY_NAME}
98       COMMAND ${CPPCHECK_EXECUTABLE} -DWIN32 ${f})
99   endforeach()
100 endif()