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