ENH: Add cmake code to do testing if user has properly setup a testimages directory
[openjpeg.git] / CMakeLists.txt
1 # Main CMakeLists.txt to build the OpenJPEG project using CMake (www.cmake.org)
2 # Written by Mathieu Malaterre
3
4 # This CMake project will by default create a library called openjpeg
5 # But if you want to use this project within your own (CMake) project
6 # you will eventually like to prefix the library to avoid linking confusion
7 # For this purpose you can define a CMake var: OPENJPEG_NAMESPACE to whatever you like
8 # e.g.:
9 # SET(OPENJPEG_NAMESPACE "GDCMOPENJPEG")
10 PROJECT(OPENJPEG C)
11 CMAKE_MINIMUM_REQUIRED(VERSION 2.2)
12
13 IF(NOT OPENJPEG_NAMESPACE)
14   SET(OPENJPEG_NAMESPACE "OPENJPEG")
15   SET(OPENJPEG_STANDALONE 1)
16 ENDIF(NOT OPENJPEG_NAMESPACE)
17 # In all cases:
18 STRING(TOLOWER ${OPENJPEG_NAMESPACE} OPENJPEG_LIBRARY_NAME)
19
20 PROJECT(${JPEG_NAMESPACE} C)
21
22 # Do full dependency headers.
23 INCLUDE_REGULAR_EXPRESSION("^.*$")
24
25 #-----------------------------------------------------------------------------
26 # OPENJPEG version number, usefull for packaging and doxygen doc:
27 SET(OPENJPEG_MAJOR_VERSION 1)
28 SET(OPENJPEG_MINOR_VERSION 0)
29 SET(OPENJPEG_BUILD_VERSION 0)
30 SET(OPENJPEG_VERSION
31   "${OPENJPEG_MAJOR_VERSION}.${OPENJPEG_MINOR_VERSION}.${OPENJPEG_BUILD_VERSION}")
32
33 #-----------------------------------------------------------------------------
34 # OpenJPEG build configuration options.
35 OPTION(BUILD_SHARED_LIBS "Build OpenJPEG with shared libraries." OFF)
36
37 #-----------------------------------------------------------------------------
38 SET (EXECUTABLE_OUTPUT_PATH ${OPENJPEG_BINARY_DIR}/bin CACHE PATH "Single output directory for building all executables.")
39 SET (LIBRARY_OUTPUT_PATH ${OPENJPEG_BINARY_DIR}/bin CACHE PATH "Single output directory for building all libraries.")
40 MARK_AS_ADVANCED(LIBRARY_OUTPUT_PATH EXECUTABLE_OUTPUT_PATH)
41
42
43 #-----------------------------------------------------------------------------
44 # For the codec...
45 OPTION(BUILD_EXAMPLES "Build the Examples (codec...)." OFF)
46
47
48 # configure name mangling to allow multiple libraries to coexist
49 # peacefully
50 IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in)
51 SET(MANGLE_PREFIX ${OPENJPEG_LIBRARY_NAME})
52 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in
53                ${CMAKE_CURRENT_BINARY_DIR}/openjpeg_mangle.h
54                @ONLY IMMEDIATE)
55 ENDIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in)
56
57 #-----------------------------------------------------------------------------
58 # Always build the library
59 INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
60 SUBDIRS(
61   libopenjpeg
62   mj2
63   jpwl
64   jp3d
65   indexer_JPIP
66   # cmake 2.4.5 has poor java support
67   #j2kviewer/src
68   )
69 #-----------------------------------------------------------------------------
70 # Build example only if requested
71 IF(BUILD_EXAMPLES)
72   SUBDIRS(codec)
73 ENDIF(BUILD_EXAMPLES)
74
75 #-----------------------------------------------------------------------------
76 # For the documentation
77 OPTION(BUILD_DOCUMENTATION "Build the doxygen documentation" OFF)
78 IF(BUILD_DOCUMENTATION)
79   SUBDIRS(doc)
80 ENDIF(BUILD_DOCUMENTATION)
81
82 #-----------------------------------------------------------------------------
83 # For openjpeg team if they ever want Dart+CMake
84 IF(OPENJPEG_STANDALONE)
85   INCLUDE(Dart)
86   MARK_AS_ADVANCED(BUILD_TESTING DART_ROOT TCL_TCLSH)
87   IF(BUILD_TESTING)
88     ENABLE_TESTING()
89     SET(BUILDNAME "OpenJPEG-${CMAKE_SYSTEM}-${CMAKE_C_COMPILER}" CACHE STRING "Name of build on the dashboard")
90     MARK_AS_ADVANCED(BUILDNAME)
91   ENDIF(BUILD_TESTING)
92 ENDIF(OPENJPEG_STANDALONE)
93
94 # Adding test with dataset from:
95 # http://www.crc.ricoh.com/~gormish/jpeg2000conformance/
96 # http://www.jpeg.org/jpeg2000guide/testimages/testimages.html
97
98 FILE(GLOB_RECURSE OPENJPEG_DATA_IMAGES_GLOB
99 #  "${OPENJPEG_SOURCE_DIR}/testing1/*.j2k"
100 #  "${OPENJPEG_SOURCE_DIR}/testing1/*.jp2"
101   "${OPENJPEG_SOURCE_DIR}/testimages/*.j2k"
102   "${OPENJPEG_SOURCE_DIR}/testimages/*.j2c"
103   "${OPENJPEG_SOURCE_DIR}/testimages/*.jp2"
104   )
105
106 FOREACH(filename ${OPENJPEG_DATA_IMAGES_GLOB})
107   GET_FILENAME_COMPONENT(filename_temp ${filename} NAME)
108   ADD_TEST(j2i-${filename_temp} ${EXECUTABLE_OUTPUT_PATH}/j2k_to_image -i ${filename} -o ${filename_temp}.tif)
109 ENDFOREACH(filename)
110