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.6)
12 if(COMMAND cmake_policy)
13 cmake_policy(SET CMP0003 NEW)
14 endif(COMMAND cmake_policy)
16 IF(NOT OPENJPEG_NAMESPACE)
17 SET(OPENJPEG_NAMESPACE "OPENJPEG")
18 SET(OPENJPEG_STANDALONE 1)
19 ENDIF(NOT OPENJPEG_NAMESPACE)
21 STRING(TOLOWER ${OPENJPEG_NAMESPACE} OPENJPEG_LIBRARY_NAME)
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 1)
31 SET(OPENJPEG_VERSION_MINOR 4)
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}"
44 #-----------------------------------------------------------------------------
45 # OpenJPEG build configuration options.
46 OPTION(BUILD_SHARED_LIBS "Build OpenJPEG with shared libraries." OFF)
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)
54 #-----------------------------------------------------------------------------
56 OPTION(BUILD_EXAMPLES "Build the Examples (codec...)." OFF)
59 # configure name mangling to allow multiple libraries to coexist
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
66 ENDIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in)
68 #-----------------------------------------------------------------------------
69 # Always build the library
70 INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
74 # cmake 2.4.5 has poor java support
86 #-----------------------------------------------------------------------------
87 # Build example only if requested
92 #-----------------------------------------------------------------------------
93 # For the documentation
94 OPTION(BUILD_DOCUMENTATION "Build the doxygen documentation" OFF)
95 IF(BUILD_DOCUMENTATION)
97 ENDIF(BUILD_DOCUMENTATION)
99 #-----------------------------------------------------------------------------
100 # For openjpeg team if they ever want Dart+CMake
101 IF(OPENJPEG_STANDALONE)
103 #MARK_AS_ADVANCED(BUILD_TESTING DART_ROOT TCL_TCLSH)
106 SET(BUILDNAME "OpenJPEG-${CMAKE_SYSTEM}-${CMAKE_C_COMPILER}" CACHE STRING "Name of build on the dashboard")
107 MARK_AS_ADVANCED(BUILDNAME)
109 ENDIF(OPENJPEG_STANDALONE)
111 # Adding test with dataset from:
112 # http://www.crc.ricoh.com/~gormish/jpeg2000conformance/
113 # -> wget http://www.crc.ricoh.com/~gormish/jpeg2000conformance/j2kp4files_v1_5.zip
114 # http://www.jpeg.org/jpeg2000guide/testimages/testimages.html
115 #-----------------------------------------------------------------------------
116 # Adding JPEG2000_CONFORMANCE_DATA_ROOT
117 FIND_PATH(JPEG2000_CONFORMANCE_DATA_ROOT testimages.html
118 ${OPENJPEG_SOURCE_DIR}/../jpeg2000testimages
119 $ENV{JPEG2000_CONFORMANCE_DATA_ROOT}
122 #-----------------------------------------------------------------------------
123 # Compiler specific flags:
124 IF(CMAKE_COMPILER_IS_GNUCC)
125 # For all builds, make sure openjpeg is std99 compliant:
126 SET(CMAKE_C_FLAGS "-Wall -std=c99 ${CMAKE_C_FLAGS}")
127 # Do not use ffast-math for all build, it would produce incorrect results, only set for release:
128 SET(CMAKE_C_FLAGS_RELEASE "-ffast-math ${CMAKE_C_FLAGS_RELEASE}")
129 ENDIF(CMAKE_COMPILER_IS_GNUCC)