1 # Main CMakeLists.txt to build the OpenJPEG project using CMake (www.cmake.org)
2 # Written by Mathieu Malaterre
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
9 # SET(OPENJPEG_NAMESPACE "GDCMOPENJPEG")
10 CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
12 IF(NOT OPENJPEG_NAMESPACE)
13 SET(OPENJPEG_NAMESPACE "OPENJPEG")
14 SET(OPENJPEG_STANDALONE 1)
15 ENDIF(NOT OPENJPEG_NAMESPACE)
17 STRING(TOLOWER ${OPENJPEG_NAMESPACE} OPENJPEG_LIBRARY_NAME)
19 IF(COMMAND CMAKE_POLICY)
20 CMAKE_POLICY(SET CMP0003 NEW)
21 ENDIF(COMMAND CMAKE_POLICY)
23 PROJECT(${OPENJPEG_NAMESPACE} C)
25 # Do full dependency headers.
26 INCLUDE_REGULAR_EXPRESSION("^.*$")
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)
34 "${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
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}"
43 #-----------------------------------------------------------------------------
44 # Test for some required system information.
45 INCLUDE (${CMAKE_ROOT}/Modules/CMakeBackwardCompatibilityC.cmake)
47 #-----------------------------------------------------------------------------
48 # Setup file for setting custom ctest vars
50 ${CMAKE_CURRENT_SOURCE_DIR}/CTestCustom.cmake.in
51 ${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake
55 #-----------------------------------------------------------------------------
56 # OpenJPEG build configuration options.
57 OPTION(BUILD_SHARED_LIBS "Build OpenJPEG with shared libraries." OFF)
58 OPTION(ENABLE_PROFILING "Enable profiling for the library" OFF)
60 #-----------------------------------------------------------------------------
61 SET (EXECUTABLE_OUTPUT_PATH ${OPENJPEG_BINARY_DIR}/bin CACHE PATH "Single output directory for building all executables.")
62 SET (LIBRARY_OUTPUT_PATH ${OPENJPEG_BINARY_DIR}/bin CACHE PATH "Single output directory for building all libraries.")
63 MARK_AS_ADVANCED(LIBRARY_OUTPUT_PATH EXECUTABLE_OUTPUT_PATH)
66 #-----------------------------------------------------------------------------
68 OPTION(BUILD_EXAMPLES "Build the Examples (codec...)." OFF)
71 # configure name mangling to allow multiple libraries to coexist
73 IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in)
74 SET(MANGLE_PREFIX ${OPENJPEG_LIBRARY_NAME})
75 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in
76 ${CMAKE_CURRENT_BINARY_DIR}/openjpeg_mangle.h
78 ENDIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in)
80 #-----------------------------------------------------------------------------
81 # Configure files with settings for use by the build.
82 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/opj_configure.h.in
83 ${CMAKE_CURRENT_BINARY_DIR}/opj_configure.h)
86 #-----------------------------------------------------------------------------
87 # Always build the library
88 INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
93 test_Free_image_V2_tile_handling
95 # cmake 2.4.5 has poor java support
107 #-----------------------------------------------------------------------------
108 # Build example only if requested
111 #ENDIF(BUILD_EXAMPLES)
113 #-----------------------------------------------------------------------------
114 # For the documentation
115 OPTION(BUILD_DOCUMENTATION "Build the doxygen documentation" OFF)
116 IF(BUILD_DOCUMENTATION)
118 ENDIF(BUILD_DOCUMENTATION)
120 #-----------------------------------------------------------------------------
121 # For openjpeg team if they ever want Dart+CMake
122 IF(OPENJPEG_STANDALONE)
124 #MARK_AS_ADVANCED(BUILD_TESTING DART_ROOT TCL_TCLSH)
127 SET(BUILDNAME "OpenJPEG-${CMAKE_SYSTEM}-${CMAKE_C_COMPILER}" CACHE STRING "Name of build on the dashboard")
128 MARK_AS_ADVANCED(BUILDNAME)
130 ENDIF(OPENJPEG_STANDALONE)
132 # Adding test with dataset from:
133 # http://www.crc.ricoh.com/~gormish/jpeg2000conformance/
134 # http://www.jpeg.org/jpeg2000guide/testimages/testimages.html
136 #-----------------------------------------------------------------------------
137 # Adding JPEG2000_CONFORMANCE_DATA_ROOT
138 FIND_PATH(JPEG2000_CONFORMANCE_DATA_ROOT testimages.html
139 ${OPENJPEG_SOURCE_DIR}/../jpeg2000testimages
140 $ENV{JPEG2000_CONFORMANCE_DATA_ROOT}
143 #-----------------------------------------------------------------------------
144 # Compiler specific flags:
145 IF(CMAKE_COMPILER_IS_GNUCC)
146 # For all builds, make sure openjpeg is std99 compliant:
147 SET(CMAKE_C_FLAGS "-Wall -std=c99 ${CMAKE_C_FLAGS}")
148 # Do not use ffast-math for all build, it would produce incorrect results, only set for release:
149 SET(CMAKE_C_FLAGS_RELEASE "-ffast-math ${CMAKE_C_FLAGS_RELEASE}")
150 ENDIF(CMAKE_COMPILER_IS_GNUCC)