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