ENH: Start building mj2
[openjpeg.git] / CMakeLists.txt
1 # Main CMakeLists.txt to build the OpenJPEG project using CMake (www.cmake.org)
2 # Written by Mathieu Malaterre
3
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
8 # e.g.:
9 # SET(OPENJPEG_NAMESPACE "GDCMOPENJPEG")
10 PROJECT(OPENJPEG C)
11 CMAKE_MINIMUM_REQUIRED(VERSION 2.2)
12
13 IF(NOT OPENJPEG_NAMESPACE)
14   SET(OPENJPEG_NAMESPACE "OPENJPEG")
15   SET(OPENJPEG_STANDALONE 1)
16 ENDIF(NOT OPENJPEG_NAMESPACE)
17 # In all cases:
18 STRING(TOLOWER ${OPENJPEG_NAMESPACE} OPENJPEG_LIBRARY_NAME)
19
20 PROJECT(${JPEG_NAMESPACE} C)
21
22 # Do full dependency headers.
23 INCLUDE_REGULAR_EXPRESSION("^.*$")
24
25 #-----------------------------------------------------------------------------
26 # OPENJPEG version number, usefull for packaging and doxygen doc:
27 SET(OPENJPEG_MAJOR_VERSION 1)
28 SET(OPENJPEG_MINOR_VERSION 0)
29 SET(OPENJPEG_BUILD_VERSION 0)
30 SET(OPENJPEG_VERSION
31   "${OPENJPEG_MAJOR_VERSION}.${OPENJPEG_MINOR_VERSION}.${OPENJPEG_BUILD_VERSION}")
32
33 #-----------------------------------------------------------------------------
34 # OpenJPEG build configuration options.
35 OPTION(BUILD_SHARED_LIBS "Build OpenJPEG with shared libraries." OFF)
36
37 #-----------------------------------------------------------------------------
38 # For the codec...
39 OPTION(BUILD_EXAMPLES "Build the Examples (codec...)." OFF)
40
41
42 # configure name mangling to allow multiple libraries to coexist
43 # peacefully
44 IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in)
45 SET(MANGLE_PREFIX ${OPENJPEG_LIBRARY_NAME})
46 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in
47                ${CMAKE_CURRENT_BINARY_DIR}/openjpeg_mangle.h
48                @ONLY IMMEDIATE)
49 ENDIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in)
50
51 #-----------------------------------------------------------------------------
52 # Always build the library
53 INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
54 SUBDIRS(
55   libopenjpeg
56   mj2
57   )
58 #-----------------------------------------------------------------------------
59 # Build example only if requested
60 IF(BUILD_EXAMPLES)
61   SUBDIRS(codec)
62 ENDIF(BUILD_EXAMPLES)
63
64 #-----------------------------------------------------------------------------
65 # For openjpeg team if they ever want Dart+CMake
66 IF(OPJ_STANDALONE)
67   INCLUDE(Dart)
68   MARK_AS_ADVANCED(BUILD_TESTING DART_ROOT TCL_TCLSH)
69   IF(BUILD_TESTING)
70     ENABLE_TESTING()
71     SET(BUILDNAME "OpenJPEG-${CMAKE_SYSTEM}-${CMAKE_C_COMPILER}" CACHE STRING "Name of build on the dashboard")
72     MARK_AS_ADVANCED(BUILDNAME)
73   ENDIF(BUILD_TESTING)
74 ENDIF(OPJ_STANDALONE)
75
76 # TODO, technically we should add tests, e.g:
77 # http://www.crc.ricoh.com/~gormish/jpeg2000conformance/
78