Patch from Callum Lerwick. Fixed the library linking so it links with the soversion...
[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_SOVERSION 2)
28 SET(OPENJPEG_MAJOR_VERSION 1)
29 SET(OPENJPEG_MINOR_VERSION 2)
30 SET(OPENJPEG_BUILD_VERSION 0)
31 SET(OPENJPEG_VERSION
32   "${OPENJPEG_MAJOR_VERSION}.${OPENJPEG_MINOR_VERSION}.${OPENJPEG_BUILD_VERSION}")
33
34 #-----------------------------------------------------------------------------
35 # OpenJPEG build configuration options.
36 OPTION(BUILD_SHARED_LIBS "Build OpenJPEG with shared libraries." OFF)
37
38 #-----------------------------------------------------------------------------
39 SET (EXECUTABLE_OUTPUT_PATH ${OPENJPEG_BINARY_DIR}/bin CACHE PATH "Single output directory for building all executables.")
40 SET (LIBRARY_OUTPUT_PATH ${OPENJPEG_BINARY_DIR}/bin CACHE PATH "Single output directory for building all libraries.")
41 MARK_AS_ADVANCED(LIBRARY_OUTPUT_PATH EXECUTABLE_OUTPUT_PATH)
42
43
44 #-----------------------------------------------------------------------------
45 # For the codec...
46 OPTION(BUILD_EXAMPLES "Build the Examples (codec...)." OFF)
47
48
49 # configure name mangling to allow multiple libraries to coexist
50 # peacefully
51 IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in)
52 SET(MANGLE_PREFIX ${OPENJPEG_LIBRARY_NAME})
53 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in
54                ${CMAKE_CURRENT_BINARY_DIR}/openjpeg_mangle.h
55                @ONLY IMMEDIATE)
56 ENDIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/openjpeg_mangle.h.in)
57
58 #-----------------------------------------------------------------------------
59 # Always build the library
60 INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
61 SUBDIRS(
62   libopenjpeg
63   mj2
64   # cmake 2.4.5 has poor java support
65   #j2kviewer/src
66   )
67
68 IF(NOT UNIX)
69 SUBDIRS(
70   jpwl
71   jp3d
72   indexer_JPIP
73   )
74 ENDIF(NOT UNIX)
75
76 #-----------------------------------------------------------------------------
77 # Build example only if requested
78 IF(BUILD_EXAMPLES)
79   SUBDIRS(codec)
80 ENDIF(BUILD_EXAMPLES)
81
82 #-----------------------------------------------------------------------------
83 # For the documentation
84 OPTION(BUILD_DOCUMENTATION "Build the doxygen documentation" OFF)
85 IF(BUILD_DOCUMENTATION)
86   SUBDIRS(doc)
87 ENDIF(BUILD_DOCUMENTATION)
88
89 #-----------------------------------------------------------------------------
90 # For openjpeg team if they ever want Dart+CMake
91 IF(OPENJPEG_STANDALONE)
92   INCLUDE(Dart)
93   MARK_AS_ADVANCED(BUILD_TESTING DART_ROOT TCL_TCLSH)
94   IF(BUILD_TESTING)
95     ENABLE_TESTING()
96     SET(BUILDNAME "OpenJPEG-${CMAKE_SYSTEM}-${CMAKE_C_COMPILER}" CACHE STRING "Name of build on the dashboard")
97     MARK_AS_ADVANCED(BUILDNAME)
98   ENDIF(BUILD_TESTING)
99 ENDIF(OPENJPEG_STANDALONE)
100
101 # Adding test with dataset from:
102 # http://www.crc.ricoh.com/~gormish/jpeg2000conformance/
103 # http://www.jpeg.org/jpeg2000guide/testimages/testimages.html
104
105 #-----------------------------------------------------------------------------
106 # Adding JPEG2000_CONFORMANCE_DATA_ROOT
107 FIND_PATH(JPEG2000_CONFORMANCE_DATA_ROOT testimages.html
108   ${OPENJPEG_SOURCE_DIR}/../jpeg2000testimages
109   $ENV{JPEG2000_CONFORMANCE_DATA_ROOT}
110 )
111
112 IF(CMAKE_COMPILER_IS_GNUCC)
113   SET(CMAKE_WARN_FLAGS "-Wall -Wextra -Wshadow -Wcast-align -Wstrict-prototypes -Wold-style-definition -Wdisabled-optimization -Wfloat-equal")
114   SET(CMAKE_C_FLAGS "${CMAKE_WARN_FLAGS} -ffast-math -fstrict-aliasing -std=c99 ${CMAKE_C_FLAGS}")
115 ENDIF(CMAKE_COMPILER_IS_GNUCC)