-IF(NOT UNIX)
-SUBDIRS(
- jpwl
- jp3d
- indexer_JPIP
- )
-ENDIF(NOT UNIX)
-
-#-----------------------------------------------------------------------------
-# Build example only if requested
-IF(BUILD_EXAMPLES)
- SUBDIRS(codec)
-ENDIF(BUILD_EXAMPLES)
-
-#-----------------------------------------------------------------------------
-# For the documentation
-OPTION(BUILD_DOCUMENTATION "Build the doxygen documentation" OFF)
-IF(BUILD_DOCUMENTATION)
- SUBDIRS(doc)
-ENDIF(BUILD_DOCUMENTATION)
-
-#-----------------------------------------------------------------------------
-# For openjpeg team if they ever want Dart+CMake
-IF(OPENJPEG_STANDALONE)
- INCLUDE(CTest)
- #MARK_AS_ADVANCED(BUILD_TESTING DART_ROOT TCL_TCLSH)
- IF(BUILD_TESTING)
- ENABLE_TESTING()
- #SET(BUILDNAME "OpenJPEG-${CMAKE_SYSTEM}-${CMAKE_C_COMPILER}" CACHE STRING "Name of build on the dashboard")
- MARK_AS_ADVANCED(BUILDNAME)
- ENDIF(BUILD_TESTING)
-ENDIF(OPENJPEG_STANDALONE)
-
-# 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}
+#-----------------------------------------------------------------------------
+# opj_config.h generation (1/2)
+
+# Check if some include files are provided by the system
+include(EnsureFileInclude)
+# These files are mandatory
+ensure_file_include("string.h" HAVE_STRING_H YES)
+ensure_file_include("memory.h" HAVE_MEMORY_H YES)
+ensure_file_include("stdlib.h" HAVE_STDLIB_H YES)
+ensure_file_include("stdio.h" HAVE_STDIO_H YES)
+ensure_file_include("math.h" HAVE_MATH_H YES)
+ensure_file_include("float.h" HAVE_FLOAT_H YES)
+ensure_file_include("time.h" HAVE_TIME_H YES)
+ensure_file_include("stdarg.h" HAVE_STDARG_H YES)
+ensure_file_include("ctype.h" HAVE_CTYPE_H YES)
+ensure_file_include("assert.h" HAVE_ASSERT_H YES)
+
+# For the following files, we provide an alternative, they are not mandatory
+ensure_file_include("stdint.h" OPJ_HAVE_STDINT_H NO)
+ensure_file_include("inttypes.h" OPJ_HAVE_INTTYPES_H NO)
+
+# why check this one ? for openjpip ?
+include (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
+CHECK_INCLUDE_FILE("strings.h" HAVE_STRINGS_H)
+CHECK_INCLUDE_FILE("sys/stat.h" HAVE_SYS_STAT_H)
+CHECK_INCLUDE_FILE("sys/types.h" HAVE_SYS_TYPES_H)
+CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTD_H)
+
+# Enable Large file support
+include(TestLargeFiles)
+OPJ_TEST_LARGE_FILES(OPJ_HAVE_LARGEFILES)
+
+#-----------------------------------------------------------------------------
+# Build Library
+if(BUILD_JPIP_SERVER)
+ find_package(CURL REQUIRED)
+ find_package(FCGI REQUIRED)
+ find_package(Threads REQUIRED)
+ if(NOT CMAKE_USE_PTHREADS_INIT)
+ message(FATAL_ERROR "Only pthread are supported")
+ endif()
+endif()
+add_subdirectory(src/lib)
+
+#-----------------------------------------------------------------------------
+# Build Applications
+option(BUILD_CODEC "Build the CODEC executables" ON)
+option(BUILD_MJ2 "Build the MJ2 executables." OFF)
+option(BUILD_JPWL "Build the JPWL library and executables" OFF)
+option(BUILD_JPIP "Build the JPIP library and executables." OFF)
+if(BUILD_JPIP)
+ option(BUILD_JPIP_SERVER "Build the JPIP server." OFF)
+endif()
+option(BUILD_VIEWER "Build the OPJViewer executable (C++)" OFF)
+option(BUILD_JAVA "Build the openjpeg jar (Java)" OFF)
+option(BUILD_JP3D "Build the JP3D comp" OFF)
+mark_as_advanced(BUILD_VIEWER)
+mark_as_advanced(BUILD_JAVA)
+mark_as_advanced(BUILD_JP3D)
+
+if(BUILD_CODEC OR BUILD_MJ2)
+ # OFF: It will only build 3rd party libs if they are not found on the system
+ # ON: 3rd party libs will ALWAYS be build, and used
+ option(BUILD_THIRDPARTY "Build the thirdparty executables if it is needed" OFF)
+ add_subdirectory(thirdparty)
+ add_subdirectory(src/bin)
+endif ()
+add_subdirectory(wrapping)
+
+#-----------------------------------------------------------------------------
+# opj_config.h generation (2/2)
+configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/openjp2/opj_config.h.cmake.in
+ ${CMAKE_CURRENT_BINARY_DIR}/src/lib/openjp2/opj_config.h
+ @ONLY
+ )
+
+ configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/lib/openjp2/opj_config_private.h.cmake.in
+ ${CMAKE_CURRENT_BINARY_DIR}/src/lib/openjp2/opj_config_private.h
+ @ONLY
+ )
+
+#-----------------------------------------------------------------------------
+# build documentation in doc subdir:
+if(BUILD_DOC)
+ add_subdirectory(doc)
+endif()
+
+#-----------------------------------------------------------------------------
+# Buld Testing
+option(BUILD_TESTING "Build the tests." OFF)
+if(BUILD_TESTING)
+ 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
+ NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH
+ )
+
+ # Add repository where to find tests
+ add_subdirectory(tests)
+
+ else()
+ message(FATAL_ERROR "You need build codec to run the tests")
+ endif()
+endif()
+
+#-----------------------------------------------------------------------------
+# install all targets referenced as OPENJPEGTargets
+install(EXPORT OpenJPEGTargets DESTINATION ${OPENJPEG_INSTALL_PACKAGE_DIR})
+configure_file( ${OPENJPEG_SOURCE_DIR}/cmake/OpenJPEGConfig.cmake.in
+ ${OPENJPEG_BINARY_DIR}/OpenJPEGConfig.cmake
+ @ONLY
+)
+install( FILES ${OPENJPEG_BINARY_DIR}/OpenJPEGConfig.cmake
+ DESTINATION ${OPENJPEG_INSTALL_PACKAGE_DIR}