[trunk] WIP: fix bug when decoding an area or a tile with special resolution
[openjpeg.git] / CMakeLists.txt
index c4297e703d6f99bbd3b73129f7cc48cadc73b745..47ebfdcd19886a7555275cb56210b529345594d1 100644 (file)
@@ -28,7 +28,7 @@ INCLUDE_REGULAR_EXPRESSION("^.*$")
 #-----------------------------------------------------------------------------
 # OPENJPEG version number, useful for packaging and doxygen doc:
 SET(OPENJPEG_VERSION_MAJOR 1)
-SET(OPENJPEG_VERSION_MINOR 4)
+SET(OPENJPEG_VERSION_MINOR 99)
 SET(OPENJPEG_VERSION_BUILD 0)
 SET(OPENJPEG_VERSION
   "${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}.${OPENJPEG_VERSION_BUILD}")
@@ -39,6 +39,13 @@ SET(OPENJPEG_LIBRARY_PROPERTIES
   SOVERSION "${OPENJPEG_VERSION_MAJOR}"
 )
 
+# --------------------------------------------------------------------------
+# Path to additional CMake modules
+SET(CMAKE_MODULE_PATH
+    ${CMAKE_SOURCE_DIR}/CMake
+    ${CMAKE_MODULE_PATH})
+
+# --------------------------------------------------------------------------
 # On Visual Studio 8 MS deprecated C. This removes all 1.276E1265 security
 # warnings
 IF(WIN32)
@@ -102,17 +109,14 @@ ENDIF(NOT OPENJPEG_INSTALL_PACKAGE_DIR)
 
 #-----------------------------------------------------------------------------
 # Test for some required system information.
+# For example this macro test the endianness (CMAKE_WORDS_BIGENDIAN)
 INCLUDE (${CMAKE_ROOT}/Modules/CMakeBackwardCompatibilityC.cmake)
 
-#-----------------------------------------------------------------------------
-# Test for getopt being available in this system
-INCLUDE (${OPENJPEG_SOURCE_DIR}/CMake/CheckHaveGetopt.cmake )
-
 #-----------------------------------------------------------------------------
 # Setup file for setting custom ctest vars
 CONFIGURE_FILE(
-  ${CMAKE_SOURCE_DIR}/testing/CTestCustom.cmake.in
-  ${CMAKE_BINARY_DIR}/testing/CTestCustom.cmake
+  ${CMAKE_SOURCE_DIR}/CMake/CTestCustom.cmake.in
+  ${CMAKE_BINARY_DIR}/CTestCustom.cmake
   @ONLY
   )
 
@@ -150,7 +154,7 @@ IF(CMAKE_COMPILER_IS_GNUCC)
 ENDIF(CMAKE_COMPILER_IS_GNUCC)
 
 #-----------------------------------------------------------------------------
-# opj_config.h generation
+# opj_config.h generation (1/2)
 FIND_FILE(HAVE_STRINGS_H_FOUND strings.h)
 IF(NOT HAVE_STRINGS_H_FOUND STREQUAL "HAVE_STRINGS_H_FOUND-NOTFOUND")
   FIND_FILE(HAVE_STRINGS_H strings.h)
@@ -196,10 +200,6 @@ IF(NOT HAVE_UNISTD_H_FOUND STREQUAL "HAVE_UNISTD_H_FOUND-NOTFOUND")
   FIND_FILE(HAVE_UNISTD_H unistd.h)
   SET(HAS_UNISTD_H 1)
 ENDIF()
-CONFIGURE_FILE("${OPENJPEG_SOURCE_DIR}/opj_configh.cmake.in"
- "${OPENJPEG_BINARY_DIR}/opj_config.h"
- @ONLY
- )
 
 #-----------------------------------------------------------------------------
 # Build Library
@@ -210,8 +210,20 @@ ADD_SUBDIRECTORY(libopenjpeg)
 # Build Applications
 OPTION(BUILD_CODEC "Build the CODEC executables" ON)
 OPTION(BUILD_MJ2 "Build the MJ2 executables." OFF)
-OPTION(BUILD_INDEXER_JPIP "Build the INDEXER_JPIP executables" OFF)
-ADD_SUBDIRECTORY(applications)
+OPTION(BUILD_JPIP "Build the JPIP library and executables." OFF)
+
+IF(BUILD_CODEC OR BUILD_MJ2 OR BUILD_JPIP)
+  OPTION(BUILD_THIRDPARTY "Build the thirdparty executables if it is needed" OFF)
+  ADD_SUBDIRECTORY(thirdparty)
+  ADD_SUBDIRECTORY(applications)
+ENDIF (BUILD_CODEC OR BUILD_MJ2 OR BUILD_JPIP)
+
+#-----------------------------------------------------------------------------
+# opj_config.h generation (2/2)
+CONFIGURE_FILE("${OPENJPEG_SOURCE_DIR}/opj_config.h.cmake.in"
+ "${OPENJPEG_BINARY_DIR}/opj_config.h"
+ @ONLY
+ )
 
 #-----------------------------------------------------------------------------
 # Build JPWL-flavoured library and executables
@@ -219,24 +231,36 @@ OPTION(BUILD_JPWL "Build the JPWL library and executables" OFF)
 
 #-----------------------------------------------------------------------------
 # Build DOCUMENTATION (not in ALL target and only if Doxygen is found)
-ADD_SUBDIRECTORY(doc)
+OPTION(BUILD_DOC "Build the HTML documentation (with doxygen if available)." OFF)
+IF(BUILD_DOC)
+    ADD_SUBDIRECTORY(doc)
+ENDIF(BUILD_DOC)
 
 #-----------------------------------------------------------------------------
-# CDash+CMake : to be updated
+# Buld Testing
 OPTION(BUILD_TESTING "Build the tests." OFF)
 IF(BUILD_TESTING)
-  ENABLE_TESTING()
-  INCLUDE(CTest)
+  IF(BUILD_CODEC)
+    ENABLE_TESTING()
+    INCLUDE(CTest)
+  
+    # Search openjpeg data needed for the tests
+    # They could be found via svn on the OpenJPEG google code project
+    # svn checkout http://openjpeg.googlecode.com/svn/data (about 70 Mo) 
+    FIND_PATH(OPJ_DATA_ROOT README-OPJ-Data 
+              PATHS $ENV{OPJ_DATA_ROOT} ${CMAKE_SOURCE_DIR}/../data)
+  
+    # For encoding tests we need the path to the ref decoder exe/lib (kakadu)           
+    SET (REF_DECODER_BIN_PATH "NOTFOUND" CACHE PATH "Single directory where find the reference decoder binaries to enable encoding test suite.")
+    MARK_AS_ADVANCED(REF_DECODER_BIN_PATH)
+    
+    # Add repository where to find tests
+    ADD_SUBDIRECTORY(tests)
+    
+  ELSE(BUILD_CODEC)
+    message(FATAL_ERROR "You need build codec to run the tests")
+  ENDIF(BUILD_CODEC)
 ENDIF(BUILD_TESTING)
-# Adding test with dataset from:
-# http://www.crc.ricoh.com/~gormish/jpeg2000conformance/
-# -> wget http://www.crc.ricoh.com/~gormish/jpeg2000conformance/j2kp4files_v1_5.zip
-# http://www.jpeg.org/jpeg2000guide/testimages/testimages.html
-# Adding JPEG2000_CONFORMANCE_DATA_ROOT
-FIND_PATH(JPEG2000_CONFORMANCE_DATA_ROOT testimages.html
-  ${OPENJPEG_SOURCE_DIR}/../jpeg2000testimages
-  $ENV{JPEG2000_CONFORMANCE_DATA_ROOT}
-)
 
 #-----------------------------------------------------------------------------
 # install all targets referenced as OPENJPEGTargets