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)
49 # On Visual Studio 8 MS deprecated C. This removes all 1.276E1265 security
55 IF(NOT ITK_ENABLE_VISUAL_STUDIO_DEPRECATED_C_WARNINGS)
57 -D_CRT_FAR_MAPPINGS_NO_DEPRECATE
58 -D_CRT_IS_WCTYPE_NO_DEPRECATE
59 -D_CRT_MANAGED_FP_NO_DEPRECATE
60 -D_CRT_NONSTDC_NO_DEPRECATE
61 -D_CRT_SECURE_NO_DEPRECATE
62 -D_CRT_SECURE_NO_DEPRECATE_GLOBALS
63 -D_CRT_SETERRORMODE_BEEP_SLEEP_NO_DEPRECATE
64 -D_CRT_TIME_FUNCTIONS_NO_DEPRECATE
65 -D_CRT_VCCLRIT_NO_DEPRECATE
66 -D_SCL_SECURE_NO_DEPRECATE
68 ENDIF(NOT ITK_ENABLE_VISUAL_STUDIO_DEPRECATED_C_WARNINGS)
75 # --------------------------------------------------------------------------
78 STRING(TOLOWER ${PROJECT_NAME} projectname)
79 SET(subdir "${projectname}-${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}")
81 IF(NOT OPENJPEG_INSTALL_BIN_DIR)
82 SET(OPENJPEG_INSTALL_BIN_DIR "bin")
83 ENDIF(NOT OPENJPEG_INSTALL_BIN_DIR)
85 IF(NOT OPENJPEG_INSTALL_LIB_DIR)
86 SET(OPENJPEG_INSTALL_LIB_DIR "lib")
87 ENDIF(NOT OPENJPEG_INSTALL_LIB_DIR)
89 IF(NOT OPENJPEG_INSTALL_DATA_DIR)
90 SET(OPENJPEG_INSTALL_DATA_DIR "share/${subdir}")
91 ENDIF(NOT OPENJPEG_INSTALL_DATA_DIR)
93 IF(NOT OPENJPEG_INSTALL_INCLUDE_DIR)
94 SET(OPENJPEG_INSTALL_INCLUDE_DIR "include/${subdir}")
95 ENDIF(NOT OPENJPEG_INSTALL_INCLUDE_DIR)
97 IF(NOT OPENJPEG_INSTALL_DOC_DIR)
98 SET(OPENJPEG_INSTALL_DOC_DIR "share/doc/${subdir}")
99 ENDIF(NOT OPENJPEG_INSTALL_DOC_DIR)
101 IF(NOT OPENJPEG_INSTALL_PACKAGE_DIR)
102 SET(OPENJPEG_INSTALL_PACKAGE_DIR ${OPENJPEG_INSTALL_LIB_DIR}/${subdir}
104 ENDIF(NOT OPENJPEG_INSTALL_PACKAGE_DIR)
106 #-----------------------------------------------------------------------------
107 # Test for some required system information.
108 INCLUDE (${CMAKE_ROOT}/Modules/CMakeBackwardCompatibilityC.cmake)
110 #-----------------------------------------------------------------------------
111 # Test for getopt being available in this system
112 INCLUDE (${PROJECT_SOURCE_DIR}/CMake/CheckHaveGetopt.cmake )
114 #-----------------------------------------------------------------------------
115 # Setup file for setting custom ctest vars
117 ${CMAKE_CURRENT_SOURCE_DIR}/CMake/CTestCustom.cmake.in
118 ${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake
122 #-----------------------------------------------------------------------------
123 # OpenJPEG build configuration options.
124 OPTION(BUILD_SHARED_LIBS "Build OpenJPEG with shared libraries." OFF)
126 #-----------------------------------------------------------------------------
127 SET (EXECUTABLE_OUTPUT_PATH ${OPENJPEG_BINARY_DIR}/bin CACHE PATH "Single output directory for building all executables.")
128 SET (LIBRARY_OUTPUT_PATH ${OPENJPEG_BINARY_DIR}/bin CACHE PATH "Single output directory for building all libraries.")
129 MARK_AS_ADVANCED(LIBRARY_OUTPUT_PATH EXECUTABLE_OUTPUT_PATH)
132 #-----------------------------------------------------------------------------
134 OPTION(BUILD_EXAMPLES "Build the Examples (codec...)." ON)
137 # configure name mangling to allow multiple libraries to coexist
139 IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in)
140 SET(MANGLE_PREFIX ${OPENJPEG_LIBRARY_NAME})
141 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in
142 ${CMAKE_CURRENT_BINARY_DIR}/openjpeg_mangle.h
144 ENDIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in)
146 #-----------------------------------------------------------------------------
147 # Always build the library
148 INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
162 #-----------------------------------------------------------------------------
163 # Build example only if requested
166 ENDIF(BUILD_EXAMPLES)
168 #-----------------------------------------------------------------------------
169 # For the documentation
170 OPTION(BUILD_DOCUMENTATION "Build the doxygen documentation" OFF)
171 IF(BUILD_DOCUMENTATION)
173 ENDIF(BUILD_DOCUMENTATION)
175 #-----------------------------------------------------------------------------
176 # For openjpeg team if they ever want CDash+CMake
177 OPTION(BUILD_TESTING "Build the tests." OFF)
183 # Adding test with dataset from:
184 # http://www.crc.ricoh.com/~gormish/jpeg2000conformance/
185 # -> wget http://www.crc.ricoh.com/~gormish/jpeg2000conformance/j2kp4files_v1_5.zip
186 # http://www.jpeg.org/jpeg2000guide/testimages/testimages.html
187 #-----------------------------------------------------------------------------
188 # Adding JPEG2000_CONFORMANCE_DATA_ROOT
189 FIND_PATH(JPEG2000_CONFORMANCE_DATA_ROOT testimages.html
190 ${OPENJPEG_SOURCE_DIR}/../jpeg2000testimages
191 $ENV{JPEG2000_CONFORMANCE_DATA_ROOT}
194 #-----------------------------------------------------------------------------
195 # Compiler specific flags:
196 IF(CMAKE_COMPILER_IS_GNUCC)
197 # For all builds, make sure openjpeg is std99 compliant:
198 # SET(CMAKE_C_FLAGS "-Wall -std=c99 ${CMAKE_C_FLAGS}") # FIXME: this setting prevented us from setting a coverage build.
199 # Do not use ffast-math for all build, it would produce incorrect results, only set for release:
200 SET(CMAKE_C_FLAGS_RELEASE "-ffast-math ${CMAKE_C_FLAGS_RELEASE}")
201 ENDIF(CMAKE_COMPILER_IS_GNUCC)
203 # install all targets referenced as OPENJPEGTargets
204 install(EXPORT OpenJPEGTargets DESTINATION ${OPENJPEG_INSTALL_PACKAGE_DIR})
205 CONFIGURE_FILE( ${OPENJPEG_SOURCE_DIR}/CMake/OpenJPEGConfig.cmake.in
206 ${OPENJPEG_BINARY_DIR}/OpenJPEGConfig.cmake
209 INSTALL( FILES ${OPENJPEG_BINARY_DIR}/OpenJPEGConfig.cmake
210 DESTINATION ${OPENJPEG_INSTALL_PACKAGE_DIR}