Start using cmake API for easy packaging
authorMathieu Malaterre <mathieu.malaterre@gmail.com>
Mon, 21 Jun 2010 13:54:49 +0000 (13:54 +0000)
committerMathieu Malaterre <mathieu.malaterre@gmail.com>
Mon, 21 Jun 2010 13:54:49 +0000 (13:54 +0000)
CMake/OpenJPEGConfig.cmake.in [new file with mode: 0644]
CMakeLists.txt
ChangeLog
codec/CMakeLists.txt
libopenjpeg/CMakeLists.txt

diff --git a/CMake/OpenJPEGConfig.cmake.in b/CMake/OpenJPEGConfig.cmake.in
new file mode 100644 (file)
index 0000000..d2e6341
--- /dev/null
@@ -0,0 +1,48 @@
+#-----------------------------------------------------------------------------
+#
+# OPENJPEGConfig.cmake - CMake configuration file for external projects.
+#
+# This file is configured by OPENJPEG and used by the UseOPENJPEG.cmake
+# module to load OPENJPEG's settings for an external project.
+@OPENJPEG_CONFIG_INSTALL_ONLY@
+# The OPENJPEG version number.
+SET(OPENJPEG_MAJOR_VERSION "@OPENJPEG_VERSION_MAJOR@")
+SET(OPENJPEG_MINOR_VERSION "@OPENJPEG_VERSION_MINOR@")
+SET(OPENJPEG_BUILD_VERSION "@OPENJPEG_VERSION_BUILD@")
+
+# The libraries.
+SET(OPENJPEG_LIBRARIES "@OPENJPEG_LIBRARIES@")
+
+# The CMake macros dir.
+SET(OPENJPEG_CMAKE_DIR "@OPENJPEG_CMAKE_DIR_CONFIG@")
+
+# The configuration options.
+SET(OPENJPEG_BUILD_SHARED_LIBS "@OPENJPEG_BUILD_SHARED_LIBS@")
+
+# The "use" file.
+SET(OPENJPEG_USE_FILE "@OPENJPEG_USE_FILE_CONFIG@")
+
+get_filename_component(SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
+if(EXISTS ${SELF_DIR}/OPENJPEGTargets.cmake)
+  # This is an install tree
+  include(${SELF_DIR}/OPENJPEGTargets.cmake)
+  get_filename_component(OPENJPEG_INCLUDE_ROOT "${SELF_DIR}/../../@OPENJPEG_INSTALL_INCLUDE_DIR@" ABSOLUTE)
+  set(OPENJPEG_INCLUDE_DIRS ${OPENJPEG_INCLUDE_ROOT})
+
+else(EXISTS ${SELF_DIR}/OPENJPEGTargets.cmake)
+  if(EXISTS ${SELF_DIR}/OPENJPEGExports.cmake)
+    # This is a build tree
+    SET( OPENJPEG_INCLUDE_DIRS @OPENJPEG_INCLUDE_PATH@)
+
+    include(${SELF_DIR}/OPENJPEGExports.cmake)
+
+  else(EXISTS ${SELF_DIR}/OPENJPEGExports.cmake)
+    message(FATAL_ERROR "ooops")
+  endif(EXISTS ${SELF_DIR}/OPENJPEGExports.cmake)
+endif(EXISTS ${SELF_DIR}/OPENJPEGTargets.cmake)
+
+set(OPENJPEG_USE_FILE ${SELF_DIR}/UseOPENJPEG.cmake)
+
+# Backward compatible part:
+SET(OPENJPEG_FOUND       TRUE)
+
index 27203d9cef6364395e840cc6afdbf0ffa16e2f24..8603275be6e09feed6c814a29727f155e372137c 100644 (file)
@@ -71,6 +71,11 @@ IF(NOT OPENJPEG_INSTALL_DOC_DIR)
   SET(OPENJPEG_INSTALL_DOC_DIR "share/doc/${subdir}")
 ENDIF(NOT OPENJPEG_INSTALL_DOC_DIR)
 
+IF(NOT OPENJPEG_INSTALL_PACKAGE_DIR)
+  SET(OPENJPEG_INSTALL_PACKAGE_DIR ${OPENJPEG_INSTALL_LIB_DIR}/${subdir}
+    CACHE INTERNAL "")
+ENDIF(NOT OPENJPEG_INSTALL_PACKAGE_DIR)
+
 #-----------------------------------------------------------------------------
 # Test for some required system information.
 INCLUDE (${CMAKE_ROOT}/Modules/CMakeBackwardCompatibilityC.cmake)
@@ -176,3 +181,13 @@ IF(CMAKE_COMPILER_IS_GNUCC)
   SET(CMAKE_C_FLAGS_RELEASE "-ffast-math ${CMAKE_C_FLAGS_RELEASE}")
 ENDIF(CMAKE_COMPILER_IS_GNUCC)
 
+# 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}
+)
+
index 70edb2c19c6726ff34670d35172822c8f8b00477..92e0470f4e0c2586c39ced2846b48810fcca3816 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,6 +11,7 @@ Jun 21, 2010
 * [MM] j2k_to_image properly return error code
 * [MM] increase coverage by testing all codecs
 * [MM] fix installation. Place in subfolder to handle both API
+* [MM] Start using cmake API for easy packaging
 
 April 8, 2010
 * [FOD] Fixed problem with Borland C++ Builder (Borland C do not have lrintf). Thanks Marek Mauder for this fix.
index bbdaee190d9be5d07f9f71862b62a89ab9975959..e55d19da9df79ea864c1dfa05f9addd889bc95f7 100644 (file)
@@ -51,7 +51,10 @@ FOREACH(exe j2k_to_image image_to_j2k)
     TARGET_LINK_LIBRARIES(${exe} m)
   ENDIF(UNIX)
   # Install exe
-  INSTALL_TARGETS(/bin/ ${exe})
+  INSTALL(TARGETS ${exe}
+    EXPORT OpenJPEGTargets
+    DESTINATION ${OPENJPEG_INSTALL_BIN_DIR} COMPONENT Applications
+  )
 ENDFOREACH(exe)
 
 if(BUILD_TESTING)
index 10e9ee213106ef2d16e913a88a7e6e2542c24db0..2e5746deaabcf24ff9d4e2a6f1c9bb38cf8024ce 100644 (file)
@@ -70,10 +70,11 @@ ENDIF(UNIX)
 
 # Install library
 INSTALL(TARGETS ${OPENJPEG_LIBRARY_NAME}
-       DESTINATION ${OPENJPEG_INSTALL_LIB_DIR}
+  EXPORT OpenJPEGTargets
+       DESTINATION ${OPENJPEG_INSTALL_LIB_DIR} COMPONENT Libraries
 )
 
 # Install includes files
 INSTALL(FILES openjpeg.h
-       DESTINATION ${OPENJPEG_INSTALL_INCLUDE_DIR}
+       DESTINATION ${OPENJPEG_INSTALL_INCLUDE_DIR} COMPONENT Headers
 )