improved some CMakeLists files linked to the build of applications which used thirdparty

This commit is contained in:
Mickael Savinaud 2011-07-13 16:49:53 +00:00
parent 36c8d85f43
commit 65f7f8dc50
8 changed files with 213 additions and 177 deletions

View File

@ -5,6 +5,9 @@ What's New for OpenJPEG
! : changed
+ : added
July 10, 2011
! [mickael] improved some CMakeLists files linked to the build of applications which used thirdparty
_______ R812 : 'openjpeg-1.5' branch created ______________________________
July 10, 2011

View File

@ -1,24 +1,31 @@
# - Find LCMS library
# Find the native LCMS includes and library
# This module defines
# LCMS_INCLUDE_DIR, where to find tiff.h, etc.
# LCMS_LIBRARIES, libraries to link against to use LCMS.
# LCMS_FOUND, If false, do not try to use LCMS.
# Once done this will define
#
# LCMS_INCLUDE_DIR - Where to find lcms.h, etc.
# LCMS_LIBRARIES - Libraries to link against to use LCMS.
# LCMS_FOUND - If false, do not try to use LCMS.
#
# also defined, but not for general use are
# LCMS_LIBRARY, where to find the LCMS library.
#
#=============================================================================
#=============================================================================
FIND_PATH(LCMS_INCLUDE_DIR lcms.h PATHS /usr/include /usr/local/include /opt/include /opt/local/include)
#
SET(LCMS_NAMES ${LCMS_NAMES} lcms liblcms liblcms_static)
FIND_LIBRARY(LCMS_LIBRARY NAMES ${LCMS_NAMES} )
#
MARK_AS_ADVANCED(LCMS_INCLUDE_DIR LCMS_LIBRARY)
# handle the QUIETLY and REQUIRED arguments and set LCMS_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LCMS DEFAULT_MSG LCMS_LIBRARY LCMS_INCLUDE_DIR)
#
IF(LCMS_FOUND)
SET( LCMS_INCLUDE_DIRS ${LCMS_INCLUDE_DIR})
SET( LCMS_LIBRARIES ${LCMS_LIBRARY} )
ENDIF(LCMS_FOUND)
MARK_AS_ADVANCED(LCMS_INCLUDE_DIR LCMS_LIBRARY)

View File

@ -1,23 +1,31 @@
# - Find LCMS2 library
# Find the native LCMS2 includes and library
# This module defines
# LCMS2_INCLUDE_DIR, where to find tiff.h, etc.
# LCMS2_LIBRARIES, libraries to link against to use LCMS2.
# LCMS2_FOUND, If false, do not try to use LCMS2.
# also defined, but not for general use are
# LCMS2_LIBRARY, where to find the LCMS2 library.
# Once done this will define
#
# LCMS2_INCLUDE_DIR - Where to find lcms2.h, etc.
# LCMS2_LIBRARIES - Libraries to link against to use LCMS2.
# LCMS2_FOUND - If false, do not try to use LCMS2.
#
# also defined, but not for general use are
# LCMS2_LIBRARY - Where to find the LCMS2 library.
#=============================================================================
#=============================================================================
FIND_PATH(LCMS2_INCLUDE_DIR lcms2.h PATHS /usr/include /usr/local/include /opt/include /opt/local/include)
SET(LCMS2_NAMES ${LCMS2_NAMES} lcms2 liblcms2 liblcms2_static)
FIND_LIBRARY(LCMS2_LIBRARY NAMES ${LCMS2_NAMES} )
MARK_AS_ADVANCED(LCMS2_INCLUDE_DIR LCMS2_LIBRARY)
# handle the QUIETLY and REQUIRED arguments and set LCMS2_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LCMS2 DEFAULT_MSG LCMS2_LIBRARY LCMS2_INCLUDE_DIR)
#
IF(LCMS2_FOUND)
SET( LCMS2_INCLUDE_DIRS ${LCMS2_INCLUDE_DIR})
SET( LCMS2_LIBRARIES ${LCMS2_LIBRARY} )
ENDIF(LCMS2_FOUND)
#
MARK_AS_ADVANCED(LCMS2_INCLUDE_DIR LCMS2_LIBRARY)

View File

@ -39,6 +39,12 @@ 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)
@ -150,7 +156,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 +202,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
)
#-----------------------------------------------------------------------------
# CDash+CMake : to be updated
@ -218,7 +220,19 @@ ADD_SUBDIRECTORY(libopenjpeg)
# Build Applications
OPTION(BUILD_CODEC "Build the CODEC executables" ON)
OPTION(BUILD_MJ2 "Build the MJ2 executables." OFF)
ADD_SUBDIRECTORY(applications)
IF(BUILD_CODEC OR BUILD_MJ2)
OPTION(BUILD_THIRDPARTY "Build the thirdparty executables if it is needed" OFF)
ADD_SUBDIRECTORY(thirdparty)
ADD_SUBDIRECTORY(applications)
ENDIF (BUILD_CODEC OR BUILD_MJ2)
#-----------------------------------------------------------------------------
# opj_config.h generation (2/2)
CONFIGURE_FILE("${OPENJPEG_SOURCE_DIR}/opj_configh.cmake.in"
"${OPENJPEG_BINARY_DIR}/opj_config.h"
@ONLY
)
#-----------------------------------------------------------------------------
# Build JPWL-flavoured library and executables

View File

@ -1,130 +1,9 @@
IF(BUILD_CODEC OR BUILD_MJ2)
#
#
IF(UNIX OR CYGWIN)
SET(CMAKE_INCLUDE_PATH /usr/include /usr/local/include /opt/include
/opt/local/include /usr/include/libpng /usr/include/libpng14
/usr/include/libpng12 /usr/local/include/libpng
/usr/local/include/libpng14 /usr/local/include/libpng12
/opt/include/libpng /opt/include/libpng14 /opt/include/libpng12
/opt/local/include/libpng /opt/local/include/libpng14)
SET(CMAKE_LIBRARY_PATH /usr/lib /usr/local/lib /opt/lib /opt/local/lib)
ENDIF()
#
FIND_PACKAGE(ZLIB)
#
IF(ZLIB_LIBRARY STREQUAL "ZLIB_LIBRARY-NOTFOUND")
SET(ZLIB_FOUND 0)
ENDIF(ZLIB_LIBRARY STREQUAL "ZLIB_LIBRARY-NOTFOUND")
#
IF(ZLIB_FOUND)
SET(HAVE_ZLIB_H 1)
SET(HABE_LIBZ 1)
SET(Z_LIBNAME ${ZLIB_LIBRARIES})
SET(Z_INCLUDE_DIRNAME ${ZLIB_INCLUDE_DIR})
ENDIF(ZLIB_FOUND)
#
FIND_PACKAGE(PNG)
#
IF(PNG_LIBRARY STREQUAL "PNG_LIBRARY-NOTFOUND")
SET(PNG_FOUND 0)
ENDIF(PNG_LIBRARY STREQUAL "PNG_LIBRARY-NOTFOUND")
#
IF(PNG_FOUND)
SET(HAVE_PNG_H 1)
SET(HAVE_LIBPNG 1)
SET(PNG_LIBNAME ${PNG_LIBRARIES})
SET(PNG_INCLUDE_DIRNAME ${PNG_INCLUDE_DIR})
ENDIF(PNG_FOUND)
#
FIND_PACKAGE(TIFF)
#
IF(TIFF_LIBRARY STREQUAL "TIFF_LIBRARY-NOTFOUND")
SET(TIFF_FOUND 0)
ENDIF(TIFF_LIBRARY STREQUAL "TIFF_LIBRARY-NOTFOUND")
#
IF(TIFF_FOUND)
SET(HAVE_TIFF_H 1)
SET(HAVE_LIBTIFF 1)
SET(TIFF_LIBNAME ${TIFF_LIBRARIES})
SET(TIFF_INCLUDE_DIRNAME ${TIFF_INCLUDE_DIR})
ENDIF(TIFF_FOUND)
#
SET(LCMS12_MISSING 1)
INCLUDE(${OPENJPEG_SOURCE_DIR}/thirdparty/FindLCMS2.cmake OPTIONAL)
#
IF(LCMS2_FOUND)
SET(LCMS12_MISSING 0)
SET(HAVE_LCMS2_H 1)
SET(HAVE_LIBLCMS2 1)
SET(LCMS_LIBNAME ${LCMS2_LIBRARY})
SET(LCMS_INCLUDE_DIRNAME ${LCMS2_INCLUDE_DIR})
ENDIF(LCMS2_FOUND)
#
IF(NOT LCMS2_FOUND)
INCLUDE(${OPENJPEG_SOURCE_DIR}/thirdparty/FindLCMS.cmake OPTIONAL)
#
IF(LCMS_FOUND)
SET(LCMS12_MISSING 0)
SET(HAVE_LCMS1_H 1)
SET(HAVE_LIBLCMS1 1)
SET(LCMS_LIBNAME ${LCMS_LIBRARY} )
SET(LCMS_INCLUDE_DIRNAME ${LCMS_INCLUDE_DIR})
ENDIF(LCMS_FOUND)
ENDIF(NOT LCMS2_FOUND)
#-------------------------------------------------------------
OPTION(BUILD_THIRDPARTY "Build the thirdparty executables" ON)
#
IF(NOT ZLIB_FOUND OR NOT PNG_FOUND OR NOT TIFF_FOUND OR LCMS12_MISSING)
IF(BUILD_THIRDPARTY)
SET(HAVE_ZLIB_H 1)
SET(HAVE_LIBZ 1)
SET(HAVE_PNG_H 1)
SET(HAVE_LIBPNG 1)
SET(HAVE_TIFF_H 1)
SET(HAVE_LIBTIFF 1)
SET(HAVE_LCMS2_H 1)
SET(HAVE_LIBLCMS2 1)
#
#ADD_SUBDIRECTORY(${OPENJPEG_SOURCE_DIR}/thirdparty)
#
LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/thirdparty/lib)
#
IF(NOT ZLIB_FOUND)
INCLUDE_DIRECTORIES(${OPENJPEG_SOURCE_DIR}/thirdparty/include)
SET(ZLIB_INCLUDE_DIRNAME ${OPENJPEG_SOURCE_DIR}/thirdparty/include)
SET(Z_LIBNAME z)
SET(ZLIB_FOUND 1)
ENDIF(NOT ZLIB_FOUND)
#
IF(NOT PNG_FOUND)
SET(PNG_INCLUDE_DIRNAME ${OPENJPEG_SOURCE_DIR}/thirdparty/libpng)
SET(PNG_LIBNAME png)
SET(PNG_FOUND 1)
ENDIF(NOT PNG_FOUND)
#
IF(NOT LCMS_FOUND AND NOT LCMS2_FOUND)
SET(LCMS_INCLUDE_DIRNAME ${OPENJPEG_SOURCE_DIR}/thirdparty/liblcms2/include)
SET(LCMS_LIBNAME lcms2)
SET(LCMS2_FOUND 1)
ENDIF(NOT LCMS_FOUND AND NOT LCMS2_FOUND)
#
IF(NOT TIFF_FOUND)
SET(TIFF_INCLUDE_DIRNAME ${OPENJPEG_SOURCE_DIR}/thirdparty/libtiff)
SET(TIFF_LIBNAME tiff)
SET(TIFF_FOUND 1)
ENDIF(NOT TIFF_FOUND)
#
ENDIF(BUILD_THIRDPARTY)
ENDIF(NOT ZLIB_FOUND OR NOT PNG_FOUND OR NOT TIFF_FOUND OR LCMS12_MISSING)
#
ENDIF(BUILD_CODEC OR BUILD_MJ2)
#
# Build the each application if it needed
IF(BUILD_CODEC)
ADD_SUBDIRECTORY(codec)
ENDIF(BUILD_CODEC)
#
IF(BUILD_MJ2)
ADD_SUBDIRECTORY(mj2)
ENDIF(BUILD_MJ2)
#

View File

@ -1,4 +1,4 @@
# Build the demo app, small examples
# Build the demo app, small examples
# First thing define the common source:
SET(common_SRCS
@ -37,11 +37,7 @@ ENDIF(WIN32)
FOREACH(exe j2k_to_image image_to_j2k j2k_dump)
ADD_EXECUTABLE(${exe} ${exe}.c ${common_SRCS})
TARGET_LINK_LIBRARIES(${exe} ${OPENJPEG_LIBRARY_NAME}
${Z_LIBNAME} ${PNG_LIBNAME} ${TIFF_LIBNAME})
IF(LCMS_FOUND OR LCMS2_FOUND)
TARGET_LINK_LIBRARIES(${exe} ${LCMS_LIBNAME})
ENDIF(LCMS_FOUND OR LCMS2_FOUND)
${Z_LIBNAME} ${PNG_LIBNAME} ${TIFF_LIBNAME} ${LCMS_LIBNAME} )
ADD_TEST(${exe} ${EXECUTABLE_OUTPUT_PATH}/${exe})
# calling those exe without option will make them fail always:

View File

@ -1,6 +1,6 @@
/* create config.h for CMake */
#define PACKAGE_VERSION "@PACKAGE_VERSION@"
#
#cmakedefine HAVE_INTTYPES_H @HAS_INTTYPES_H@
#cmakedefine HAVE_MEMORY_H @HAS_MEMORY_H@
#cmakedefine HAVE_STDINT_H @HAS_STDINT_H@
@ -14,9 +14,9 @@
#cmakedefine HAVE_PNG_H @HAVE_PNG_H@
#cmakedefine HAVE_LIBTIFF @HAVE_LIBTIFF@
#cmakedefine HAVE_TIFF_H @HAVE_TIFF_H@
#
#cmakedefine HAVE_LIBLCMS1 @HAVE_LIBLCMS1@
#cmakedefine HAVE_LIBLCMS2 @HAVE_LIBLCMS2@
#cmakedefine HAVE_LCMS1_H @HAVE_LCMS1_H@
#cmakedefine HAVE_LCMS2_H @HAVE_LCMS2_H@
#

View File

@ -1,20 +1,149 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
IF(BUILD_THIRDPARTY)
#
IF(NOT ZLIB_FOUND)
ADD_SUBDIRECTORY(libz)
ENDIF(NOT ZLIB_FOUND)
#
IF(NOT PNG_FOUND)
ADD_SUBDIRECTORY(libpng)
ENDIF(NOT PNG_FOUND)
#
IF(NOT LCMS2_FOUND)
ADD_SUBDIRECTORY(liblcms2)
ENDIF(NOT LCMS2_FOUND)
#
IF(NOT TIFF_FOUND)
ADD_SUBDIRECTORY(libtiff)
ENDIF(NOT TIFF_FOUND)
#
ENDIF(BUILD_THIRDPARTY)
IF(UNIX OR CYGWIN)
SET(CMAKE_INCLUDE_PATH /usr/include /usr/local/include /opt/include
/opt/local/include /usr/include/libpng /usr/include/libpng14
/usr/include/libpng12 /usr/local/include/libpng
/usr/local/include/libpng14 /usr/local/include/libpng12
/opt/include/libpng /opt/include/libpng14 /opt/include/libpng12
/opt/local/include/libpng /opt/local/include/libpng14)
SET(CMAKE_LIBRARY_PATH /usr/lib /usr/local/lib /opt/lib /opt/local/lib)
ENDIF(UNIX OR CYGWIN)
#------------
# Try to find lib Z
FIND_PACKAGE(ZLIB)
IF(ZLIB_FOUND)
SET(Z_LIBNAME ${ZLIB_LIBRARIES} PARENT_SCOPE)
SET(Z_INCLUDE_DIRNAME ${ZLIB_INCLUDE_DIRS} PARENT_SCOPE)
message("Your system seems to have a Z lib available, we will used it to generate PNG lib")
ELSE (ZLIB_FOUND) # not found
IF(BUILD_THIRDPARTY)
# Try to build it
message("We will build Z lib from thirdparty")
ADD_SUBDIRECTORY(libz)
SET(Z_LIBNAME ${ZLIB_LIBRARIES} PARENT_SCOPE)
SET(Z_INCLUDE_DIRNAME ${ZLIB_INCLUDE_DIRS} PARENT_SCOPE)
SET(ZLIB_FOUND 1)
ELSE (BUILD_THIRDPARTY)
message("Z lib not found, activate BUILD_THIRDPARTY if you want build it (necessary to build libPNG)")
ENDIF(BUILD_THIRDPARTY)
ENDIF(ZLIB_FOUND)
#------------
# Try to find lib PNG (which depends to zlib)
IF (ZLIB_FOUND)
FIND_PACKAGE(PNG)
IF(PNG_FOUND)
message("Your system seems to have a PNG lib available, we will used it")
SET(HAVE_PNG_H 1 PARENT_SCOPE)
SET(HAVE_LIBPNG 1 PARENT_SCOPE)
SET(PNG_LIBNAME ${PNG_LIBRARIES} PARENT_SCOPE)
SET(PNG_INCLUDE_DIRNAME ${PNG_INCLUDE_DIR} PARENT_SCOPE)
ELSE(PNG_FOUND) # not found
IF(BUILD_THIRDPARTY)
# Try to build it
message("We will build PNG lib from thirdparty")
ADD_SUBDIRECTORY(libpng)
SET(HAVE_PNG_H 1 PARENT_SCOPE)
SET(HAVE_LIBPNG 1 PARENT_SCOPE)
SET(PNG_LIBNAME ${PNG_LIBRARIES} PARENT_SCOPE)
SET(PNG_INCLUDE_DIRNAME ${PNG_INCLUDE_DIR} PARENT_SCOPE)
ELSE (BUILD_THIRDPARTY)
SET(HAVE_PNG_H 0 PARENT_SCOPE)
SET(HAVE_LIBPNG 0 PARENT_SCOPE)
message("PNG lib not found, activate BUILD_THIRDPARTY if you want build it")
ENDIF(BUILD_THIRDPARTY)
ENDIF(PNG_FOUND)
ELSE (ZLIB_FOUND)
message(WARNING "To add lib PNG we need that ZLIB was previously found")
ENDIF (ZLIB_FOUND)
#------------
# Try to find lib TIFF
FIND_PACKAGE(TIFF)
IF(TIFF_FOUND)
message("Your system seems to have a TIFF lib available, we will used it")
SET(HAVE_TIFF_H 1 PARENT_SCOPE)
SET(HAVE_LIBTIFF 1 PARENT_SCOPE)
SET(TIFF_LIBNAME ${TIFF_LIBRARIES} PARENT_SCOPE)
SET(TIFF_INCLUDE_DIRNAME ${TIFF_INCLUDE_DIR} PARENT_SCOPE)
ELSE (TIFF_FOUND) # not found
IF(BUILD_THIRDPARTY)
# Try to build it
message("We will build TIFF lib from thirdparty")
ADD_SUBDIRECTORY(libtiff)
SET(TIFF_LIBNAME ${TIFF_LIBRARIES} PARENT_SCOPE)
SET(TIFF_INCLUDE_DIRNAME ${TIFF_INCLUDE_DIR} PARENT_SCOPE)
SET(HAVE_TIFF_H 1 PARENT_SCOPE)
SET(HAVE_LIBTIFF 1 PARENT_SCOPE)
ELSE (BUILD_THIRDPARTY)
SET(HAVE_TIFF_H 0 PARENT_SCOPE)
SET(HAVE_LIBTIFF 0 PARENT_SCOPE)
message("TIFF lib not found, activate BUILD_THIRDPARTY if you want build it")
ENDIF(BUILD_THIRDPARTY)
ENDIF(TIFF_FOUND)
#------------
# Try to find lib LCMS2 (or by default LCMS)
FIND_PACKAGE(LCMS2)
IF(LCMS2_FOUND)
message("Your system seems to have a LCMS2 lib available, we will used it")
SET(HAVE_LCMS2_H 1 PARENT_SCOPE)
SET(HAVE_LIBLCMS2 1 PARENT_SCOPE)
SET(LCMS_LIBNAME ${LCMS2_LIBRARIES} PARENT_SCOPE)
SET(LCMS_INCLUDE_DIRNAME ${LCMS2_INCLUDE_DIRS} PARENT_SCOPE)
ELSE (LCMS2_FOUND) # not found lcms2
# try to find LCMS
FIND_PACKAGE(LCMS)
IF(LCMS_FOUND)
message("Your system seems to have a LCMS lib available, we will used it")
SET(HAVE_LCMS_H 1 PARENT_SCOPE)
SET(HAVE_LIBLCMS 1 PARENT_SCOPE)
SET(LCMS_LIBNAME ${LCMS_LIBRARIES} PARENT_SCOPE)
SET(LCMS_INCLUDE_DIRNAME ${LCMS_INCLUDE_DIRS} PARENT_SCOPE)
ELSE (LCMS_FOUND) # not found lcms
SET(HAVE_LCMS_H 0 PARENT_SCOPE)
SET(HAVE_LIBLCMS 0 PARENT_SCOPE)
IF( BUILD_THIRDPARTY)
# Try to build lcms2
message("We will build LCMS2 lib from thirdparty")
ADD_SUBDIRECTORY(liblcms2)
SET(LCMS_LIBNAME "lcms2" PARENT_SCOPE)
SET(LCMS_INCLUDE_DIRNAME ${OPENJPEG_SOURCE_DIR}/thirdparty/liblcms2/include PARENT_SCOPE) #
SET(HAVE_LCMS2_H 1 PARENT_SCOPE)
SET(HAVE_LIBLCMS2 1 PARENT_SCOPE)
ELSE (BUILD_THIRDPARTY)
SET(HAVE_LCMS2_H 0 PARENT_SCOPE)
SET(HAVE_LIBLCMS2 0 PARENT_SCOPE)
message("LCMS2 or LCMS lib not found, activate BUILD_THIRDPARTY if you want build it")
ENDIF(BUILD_THIRDPARTY)
ENDIF (LCMS_FOUND)
ENDIF(LCMS2_FOUND)