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 PROJECT(${OPENJPEG_NAMESPACE} C)
21 # Do full dependency headers.
22 INCLUDE_REGULAR_EXPRESSION("^.*$")
24 #-----------------------------------------------------------------------------
25 # OPENJPEG version number, useful for packaging and doxygen doc:
26 SET(OPENJPEG_VERSION_MAJOR 1)
27 SET(OPENJPEG_VERSION_MINOR 3)
28 SET(OPENJPEG_VERSION_BUILD 0)
30 "${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
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}"
40 #-----------------------------------------------------------------------------
41 # OpenJPEG build configuration options.
42 OPTION(BUILD_SHARED_LIBS "Build OpenJPEG with shared libraries." OFF)
44 #-----------------------------------------------------------------------------
45 SET (EXECUTABLE_OUTPUT_PATH ${OPENJPEG_BINARY_DIR}/bin CACHE PATH "Single output directory for building all executables.")
46 SET (LIBRARY_OUTPUT_PATH ${OPENJPEG_BINARY_DIR}/bin CACHE PATH "Single output directory for building all libraries.")
47 MARK_AS_ADVANCED(LIBRARY_OUTPUT_PATH EXECUTABLE_OUTPUT_PATH)
50 #-----------------------------------------------------------------------------
52 OPTION(BUILD_EXAMPLES "Build the Examples (codec...)." OFF)
55 # configure name mangling to allow multiple libraries to coexist
57 IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in)
58 SET(MANGLE_PREFIX ${OPENJPEG_LIBRARY_NAME})
59 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in
60 ${CMAKE_CURRENT_BINARY_DIR}/openjpeg_mangle.h
62 ENDIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in)
64 #-----------------------------------------------------------------------------
65 # Always build the library
66 INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
70 # cmake 2.4.5 has poor java support
82 #-----------------------------------------------------------------------------
83 # Build example only if requested
88 #-----------------------------------------------------------------------------
89 # For the documentation
90 OPTION(BUILD_DOCUMENTATION "Build the doxygen documentation" OFF)
91 IF(BUILD_DOCUMENTATION)
93 ENDIF(BUILD_DOCUMENTATION)
95 #-----------------------------------------------------------------------------
96 # For openjpeg team if they ever want Dart+CMake
97 IF(OPENJPEG_STANDALONE)
99 MARK_AS_ADVANCED(BUILD_TESTING DART_ROOT TCL_TCLSH)
102 SET(BUILDNAME "OpenJPEG-${CMAKE_SYSTEM}-${CMAKE_C_COMPILER}" CACHE STRING "Name of build on the dashboard")
103 MARK_AS_ADVANCED(BUILDNAME)
105 ENDIF(OPENJPEG_STANDALONE)
107 # Adding test with dataset from:
108 # http://www.crc.ricoh.com/~gormish/jpeg2000conformance/
109 # http://www.jpeg.org/jpeg2000guide/testimages/testimages.html
111 #-----------------------------------------------------------------------------
112 # Adding JPEG2000_CONFORMANCE_DATA_ROOT
113 FIND_PATH(JPEG2000_CONFORMANCE_DATA_ROOT testimages.html
114 ${OPENJPEG_SOURCE_DIR}/../jpeg2000testimages
115 $ENV{JPEG2000_CONFORMANCE_DATA_ROOT}
118 #-----------------------------------------------------------------------------
119 # Compiler specific flags:
120 IF(CMAKE_COMPILER_IS_GNUCC)
121 # For all builds, make sure openjpeg is std99 compliant:
122 SET(CMAKE_C_FLAGS "-Wall -std=c99 ${CMAKE_C_FLAGS}")
123 # Do not use ffast-math for all build, it would produce incorrect results, only set for release:
124 SET(CMAKE_C_FLAGS_RELEASE "-ffast-math ${CMAKE_C_FLAGS_RELEASE}")
125 ENDIF(CMAKE_COMPILER_IS_GNUCC)