ENH: Enabling the lines that configure testing for the Dashboard.
[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 CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
11
12 IF(NOT OPENJPEG_NAMESPACE)
13   SET(OPENJPEG_NAMESPACE "OPENJPEG")
14   SET(OPENJPEG_STANDALONE 1)
15 ENDIF(NOT OPENJPEG_NAMESPACE)
16 # In all cases:
17 STRING(TOLOWER ${OPENJPEG_NAMESPACE} OPENJPEG_LIBRARY_NAME)
18
19 IF(COMMAND CMAKE_POLICY)
20   CMAKE_POLICY(SET CMP0003 NEW)
21 ENDIF(COMMAND CMAKE_POLICY)
22
23 PROJECT(${OPENJPEG_NAMESPACE} C)
24
25 # Do full dependency headers.
26 INCLUDE_REGULAR_EXPRESSION("^.*$")
27
28 #-----------------------------------------------------------------------------
29 # OPENJPEG version number, useful for packaging and doxygen doc:
30 SET(OPENJPEG_VERSION_MAJOR 2)
31 SET(OPENJPEG_VERSION_MINOR 0)
32 SET(OPENJPEG_VERSION_BUILD 0)
33 SET(OPENJPEG_VERSION
34   "${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
35
36 # This setting of SOVERSION assumes that any API change
37 # will increment either the minor or major version number of openjpeg
38 SET(OPENJPEG_LIBRARY_PROPERTIES
39   VERSION   "${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}"
40   SOVERSION "${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}"
41 )
42
43 #-----------------------------------------------------------------------------
44 # Test for some required system information.
45 INCLUDE (${CMAKE_ROOT}/Modules/CMakeBackwardCompatibilityC.cmake)
46
47 #-----------------------------------------------------------------------------
48 # OpenJPEG build configuration options.
49 OPTION(BUILD_SHARED_LIBS "Build OpenJPEG with shared libraries." OFF)
50 OPTION(ENABLE_PROFILING "Enable profiling for the library" OFF)
51
52 #-----------------------------------------------------------------------------
53 SET (EXECUTABLE_OUTPUT_PATH ${OPENJPEG_BINARY_DIR}/bin CACHE PATH "Single output directory for building all executables.")
54 SET (LIBRARY_OUTPUT_PATH ${OPENJPEG_BINARY_DIR}/bin CACHE PATH "Single output directory for building all libraries.")
55 MARK_AS_ADVANCED(LIBRARY_OUTPUT_PATH EXECUTABLE_OUTPUT_PATH)
56
57
58 #-----------------------------------------------------------------------------
59 # For the codec...
60 OPTION(BUILD_EXAMPLES "Build the Examples (codec...)." OFF)
61
62
63 # configure name mangling to allow multiple libraries to coexist
64 # peacefully
65 IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in)
66 SET(MANGLE_PREFIX ${OPENJPEG_LIBRARY_NAME})
67 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in
68                ${CMAKE_CURRENT_BINARY_DIR}/openjpeg_mangle.h
69                @ONLY IMMEDIATE)
70 ENDIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in)
71
72 #-----------------------------------------------------------------------------
73 # Configure files with settings for use by the build.
74 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/opj_configure.h.in 
75                ${CMAKE_CURRENT_BINARY_DIR}/opj_configure.h)
76
77
78 #-----------------------------------------------------------------------------
79 # Always build the library
80 INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
81 SUBDIRS(
82   libopenjpeg
83   codec
84   test_V2_tile_handling
85   test_Free_image_V2_tile_handling
86   # mj2
87   # cmake 2.4.5 has poor java support
88   #j2kviewer/src
89   )
90
91 #IF(NOT UNIX)
92 #SUBDIRS(
93 #  jpwl
94 #  jp3d
95 #  indexer_JPIP
96 #  )
97 #ENDIF(NOT UNIX)
98
99 #-----------------------------------------------------------------------------
100 # Build example only if requested
101 #IF(BUILD_EXAMPLES)
102 #  SUBDIRS(codec)
103 #ENDIF(BUILD_EXAMPLES)
104
105 #-----------------------------------------------------------------------------
106 # For the documentation
107 OPTION(BUILD_DOCUMENTATION "Build the doxygen documentation" OFF)
108 IF(BUILD_DOCUMENTATION)
109   SUBDIRS(doc)
110 ENDIF(BUILD_DOCUMENTATION)
111
112 #-----------------------------------------------------------------------------
113 # For openjpeg team if they ever want Dart+CMake
114 IF(OPENJPEG_STANDALONE)
115   INCLUDE(CTest)
116   #MARK_AS_ADVANCED(BUILD_TESTING DART_ROOT TCL_TCLSH)
117   IF(BUILD_TESTING)
118     ENABLE_TESTING()
119     SET(BUILDNAME "OpenJPEG-${CMAKE_SYSTEM}-${CMAKE_C_COMPILER}" CACHE STRING "Name of build on the dashboard")
120     MARK_AS_ADVANCED(BUILDNAME)
121   ENDIF(BUILD_TESTING)
122 ENDIF(OPENJPEG_STANDALONE)
123
124 # Adding test with dataset from:
125 # http://www.crc.ricoh.com/~gormish/jpeg2000conformance/
126 # http://www.jpeg.org/jpeg2000guide/testimages/testimages.html
127
128 #-----------------------------------------------------------------------------
129 # Adding JPEG2000_CONFORMANCE_DATA_ROOT
130 FIND_PATH(JPEG2000_CONFORMANCE_DATA_ROOT testimages.html
131   ${OPENJPEG_SOURCE_DIR}/../jpeg2000testimages
132   $ENV{JPEG2000_CONFORMANCE_DATA_ROOT}
133 )
134
135 #-----------------------------------------------------------------------------
136 # Compiler specific flags:
137 IF(CMAKE_COMPILER_IS_GNUCC)
138   # For all builds, make sure openjpeg is std99 compliant:
139   SET(CMAKE_C_FLAGS "-Wall -std=c99 ${CMAKE_C_FLAGS}")
140   # Do not use ffast-math for all build, it would produce incorrect results, only set for release:
141   SET(CMAKE_C_FLAGS_RELEASE "-ffast-math ${CMAKE_C_FLAGS_RELEASE}")
142 ENDIF(CMAKE_COMPILER_IS_GNUCC)
143