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}"
42 # You will also need to define a value for the following variables:
43 # OPENJPEG_INSTALL_BIN_DIR - binary dir (executables)
44 # OPENJPEG_INSTALL_LIB_DIR - library dir (libs)
45 # OPENJPEG_INSTALL_DATA_DIR - share dir (say, examples, data, etc)
46 # OPENJPEG_INSTALL_INCLUDE_DIR - include dir (headers)
48 # --------------------------------------------------------------------------
51 STRING(TOLOWER ${PROJECT_NAME} projectname)
52 SET(subdir "${projectname}-${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}")
54 IF(NOT OPENJPEG_INSTALL_BIN_DIR)
55 SET(OPENJPEG_INSTALL_BIN_DIR "bin")
56 ENDIF(NOT OPENJPEG_INSTALL_BIN_DIR)
58 IF(NOT OPENJPEG_INSTALL_LIB_DIR)
59 SET(OPENJPEG_INSTALL_LIB_DIR "lib")
60 ENDIF(NOT OPENJPEG_INSTALL_LIB_DIR)
62 IF(NOT OPENJPEG_INSTALL_DATA_DIR)
63 SET(OPENJPEG_INSTALL_DATA_DIR "share/${subdir}")
64 ENDIF(NOT OPENJPEG_INSTALL_DATA_DIR)
66 IF(NOT OPENJPEG_INSTALL_INCLUDE_DIR)
67 SET(OPENJPEG_INSTALL_INCLUDE_DIR "include/${subdir}")
68 ENDIF(NOT OPENJPEG_INSTALL_INCLUDE_DIR)
70 IF(NOT OPENJPEG_INSTALL_DOC_DIR)
71 SET(OPENJPEG_INSTALL_DOC_DIR "share/doc/${subdir}")
72 ENDIF(NOT OPENJPEG_INSTALL_DOC_DIR)
74 IF(NOT OPENJPEG_INSTALL_PACKAGE_DIR)
75 SET(OPENJPEG_INSTALL_PACKAGE_DIR ${OPENJPEG_INSTALL_LIB_DIR}/${subdir}
77 ENDIF(NOT OPENJPEG_INSTALL_PACKAGE_DIR)
79 #-----------------------------------------------------------------------------
80 # Test for some required system information.
81 INCLUDE (${CMAKE_ROOT}/Modules/CMakeBackwardCompatibilityC.cmake)
83 #-----------------------------------------------------------------------------
84 # Setup file for setting custom ctest vars
86 ${CMAKE_CURRENT_SOURCE_DIR}/CMake/CTestCustom.cmake.in
87 ${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake
91 #-----------------------------------------------------------------------------
92 # OpenJPEG build configuration options.
93 OPTION(BUILD_SHARED_LIBS "Build OpenJPEG with shared libraries." OFF)
95 #-----------------------------------------------------------------------------
96 SET (EXECUTABLE_OUTPUT_PATH ${OPENJPEG_BINARY_DIR}/bin CACHE PATH "Single output directory for building all executables.")
97 SET (LIBRARY_OUTPUT_PATH ${OPENJPEG_BINARY_DIR}/bin CACHE PATH "Single output directory for building all libraries.")
98 MARK_AS_ADVANCED(LIBRARY_OUTPUT_PATH EXECUTABLE_OUTPUT_PATH)
101 #-----------------------------------------------------------------------------
103 OPTION(BUILD_EXAMPLES "Build the Examples (codec...)." ON)
106 # configure name mangling to allow multiple libraries to coexist
108 IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in)
109 SET(MANGLE_PREFIX ${OPENJPEG_LIBRARY_NAME})
110 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in
111 ${CMAKE_CURRENT_BINARY_DIR}/openjpeg_mangle.h
113 ENDIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in)
115 #-----------------------------------------------------------------------------
116 # Always build the library
117 INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
121 # cmake 2.4.5 has poor java support
133 #-----------------------------------------------------------------------------
134 # Build example only if requested
137 ENDIF(BUILD_EXAMPLES)
139 #-----------------------------------------------------------------------------
140 # For the documentation
141 OPTION(BUILD_DOCUMENTATION "Build the doxygen documentation" OFF)
142 IF(BUILD_DOCUMENTATION)
144 ENDIF(BUILD_DOCUMENTATION)
146 #-----------------------------------------------------------------------------
147 # For openjpeg team if they ever want CDash+CMake
148 OPTION(BUILD_TESTING "Build the tests." OFF)
154 # Adding test with dataset from:
155 # http://www.crc.ricoh.com/~gormish/jpeg2000conformance/
156 # -> wget http://www.crc.ricoh.com/~gormish/jpeg2000conformance/j2kp4files_v1_5.zip
157 # http://www.jpeg.org/jpeg2000guide/testimages/testimages.html
158 #-----------------------------------------------------------------------------
159 # Adding JPEG2000_CONFORMANCE_DATA_ROOT
160 FIND_PATH(JPEG2000_CONFORMANCE_DATA_ROOT testimages.html
161 ${OPENJPEG_SOURCE_DIR}/../jpeg2000testimages
162 $ENV{JPEG2000_CONFORMANCE_DATA_ROOT}
165 #-----------------------------------------------------------------------------
166 # Compiler specific flags:
167 IF(CMAKE_COMPILER_IS_GNUCC)
168 # For all builds, make sure openjpeg is std99 compliant:
169 # SET(CMAKE_C_FLAGS "-Wall -std=c99 ${CMAKE_C_FLAGS}") # FIXME: this setting prevented us from setting a coverage build.
170 # Do not use ffast-math for all build, it would produce incorrect results, only set for release:
171 SET(CMAKE_C_FLAGS_RELEASE "-ffast-math ${CMAKE_C_FLAGS_RELEASE}")
172 ENDIF(CMAKE_COMPILER_IS_GNUCC)
174 # install all targets referenced as OPENJPEGTargets
175 install(EXPORT OpenJPEGTargets DESTINATION ${OPENJPEG_INSTALL_PACKAGE_DIR})
176 CONFIGURE_FILE( ${OPENJPEG_SOURCE_DIR}/CMake/OpenJPEGConfig.cmake.in
177 ${OPENJPEG_BINARY_DIR}/OpenJPEGConfig.cmake
180 INSTALL( FILES ${OPENJPEG_BINARY_DIR}/OpenJPEGConfig.cmake
181 DESTINATION ${OPENJPEG_INSTALL_PACKAGE_DIR}