Echo Kakadu copyright notice
[openjpeg.git] / CMakeLists.txt
index 7d6b0b5575bf19afc48333e227bced3002f29ea6..7898d15ca76f115acd7be6a5c896227d00073f23 100644 (file)
@@ -11,6 +11,9 @@ cmake_minimum_required(VERSION 2.8.2)
 
 if(COMMAND CMAKE_POLICY)
   cmake_policy(SET CMP0003 NEW)
+  if (NOT (${CMAKE_VERSION} VERSION_LESS 3.0))
+    cmake_policy(SET CMP0042 NEW)
+  endif()
 endif()
 
 if(NOT OPENJPEG_NAMESPACE)
@@ -47,6 +50,7 @@ set(PACKAGE_VERSION
 #   1.5   |  5
 #   1.5.1 |  5
 #   2.0   |  6
+#   2.0.1 |  6
 #   2.1   |  7
 # above is the recommendation by the OPJ team. If you really need to override this default,
 # you can specify your own OPENJPEG_SOVERSION at cmake configuration time:
@@ -94,6 +98,8 @@ endif()
 
 # --------------------------------------------------------------------------
 # Install directories
+# Build DOCUMENTATION (not in ALL target and only if Doxygen is found)
+option(BUILD_DOC "Build the HTML documentation (with doxygen if available)." OFF)
 
 string(TOLOWER ${PROJECT_NAME} projectname)
 set(OPENJPEG_INSTALL_SUBDIR "${projectname}-${OPENJPEG_VERSION_MAJOR}.${OPENJPEG_VERSION_MINOR}")
@@ -118,6 +124,7 @@ if(NOT OPENJPEG_INSTALL_INCLUDE_DIR)
   set(OPENJPEG_INSTALL_INCLUDE_DIR "include/${OPENJPEG_INSTALL_SUBDIR}")
 endif()
 
+if(BUILD_DOC)
 if(NOT OPENJPEG_INSTALL_MAN_DIR)
   set(OPENJPEG_INSTALL_MAN_DIR "share/man/")
 endif()
@@ -125,6 +132,7 @@ endif()
 if(NOT OPENJPEG_INSTALL_DOC_DIR)
   set(OPENJPEG_INSTALL_DOC_DIR "share/doc/${OPENJPEG_INSTALL_SUBDIR}")
 endif()
+endif()
 
 if(NOT OPENJPEG_INSTALL_JNI_DIR)
   if(WIN32)
@@ -141,6 +149,11 @@ if(NOT OPENJPEG_INSTALL_PACKAGE_DIR)
   set(OPENJPEG_INSTALL_PACKAGE_DIR "${OPENJPEG_INSTALL_LIB_DIR}/${OPENJPEG_INSTALL_SUBDIR}")
 endif()
 
+if (APPLE)
+       list(APPEND OPENJPEG_LIBRARY_PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/${OPENJPEG_INSTALL_LIB_DIR}")
+       option(OPJ_USE_DSYMUTIL "Call dsymutil on binaries after build." OFF)
+endif()
+
 #-----------------------------------------------------------------------------
 # Big endian test:
 include (${CMAKE_ROOT}/Modules/TestBigEndian.cmake)
@@ -177,7 +190,7 @@ if(CMAKE_COMPILER_IS_GNUCC)
   # For all builds, make sure openjpeg is std99 compliant:
   # set(CMAKE_C_FLAGS "-Wall -std=c99 ${CMAKE_C_FLAGS}") # FIXME: this setting prevented us from setting a coverage build.
   # Do not use ffast-math for all build, it would produce incorrect results, only set for release:
-  set(CMAKE_C_FLAGS_RELEASE "-ffast-math ${CMAKE_C_FLAGS_RELEASE}")
+  SET(OPENJPEG_LIBRARY_COMPILE_OPTIONS ${OPENJPEG_LIBRARY_COMPILE_OPTIONS} "$<$<CONFIG:Release>:-ffast-math>")
 endif()
 
 #-----------------------------------------------------------------------------
@@ -264,8 +277,7 @@ configure_file(
  )
 
 #-----------------------------------------------------------------------------
-# Build DOCUMENTATION (not in ALL target and only if Doxygen is found)
-option(BUILD_DOC "Build the HTML documentation (with doxygen if available)." OFF)
+# build documentation in doc subdir:
 if(BUILD_DOC)
   add_subdirectory(doc)
 endif()
@@ -307,16 +319,25 @@ install( FILES ${OPENJPEG_BINARY_DIR}/OpenJPEGConfig.cmake
 
 #-----------------------------------------------------------------------------
 # install CHANGES and LICENSE
+if(BUILD_DOC)
 if(EXISTS ${OPENJPEG_SOURCE_DIR}/CHANGES)
   install(FILES CHANGES DESTINATION ${OPENJPEG_INSTALL_DOC_DIR})
 endif()
+
 install(FILES LICENSE DESTINATION ${OPENJPEG_INSTALL_DOC_DIR})
+endif()
 
 include (cmake/OpenJPEGCPack.cmake)
 
 #-----------------------------------------------------------------------------
 # pkgconfig support
+# enabled by default on Unix, disabled by default on other platforms
 if(UNIX)
+  option(BUILD_PKGCONFIG_FILES "Build and install pkg-config files" ON)
+else()
+  option(BUILD_PKGCONFIG_FILES "Build and install pkg-config files" OFF)
+endif()
+if(BUILD_PKGCONFIG_FILES)
   # install in lib and not share (see multi-arch note above)
   configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/lib/openjp2/libopenjp2.pc.cmake.in
     ${CMAKE_CURRENT_BINARY_DIR}/libopenjp2.pc @ONLY)