Skip to content

Commit

Permalink
Add support for some graphics formats
Browse files Browse the repository at this point in the history
  • Loading branch information
kfieldho committed Sep 4, 2015
1 parent 8f400bc commit 27acb32
Show file tree
Hide file tree
Showing 10 changed files with 806 additions and 5 deletions.
44 changes: 44 additions & 0 deletions CMake/External_PNG.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# PNG External project

# ZLIB
add_package_dependency(
PACKAGE PNG
PACKAGE_DEPENDENCY ZLib
PACKAGE_DEPENDENCY_ALIAS ZLIB
)
if(NOT ZLIB_FOUND)
set(ZLIB_INCLUDE_DIRS ${fletch_BUILD_INSTALL_PREFIX}/include)
get_system_library_name(zlib zlib_lib)
set(ZLIB_LIBRARIES ${fletch_BUILD_INSTALL_PREFIX}/lib/${zlib_lib})
endif()
set(png_cmake_args ${png_cmake_args}
-DZLIB_INCLUDE_DIR:PATH=${ZLIB_INCLUDE_DIRS}
-DZLIB_LIBRARY:PATH=${ZLIB_LIBRARIES}
)


ExternalProject_Add(PNG
DEPENDS ${PNG_DEPENDS}
URL ${PNG_url}
URL_MD5 ${PNG_md5}
PREFIX ${fletch_BUILD_PREFIX}
DOWNLOAD_DIR ${fletch_DOWNLOAD_DIR}
INSTALL_DIR ${fletch_BUILD_INSTALL_PREFIX}
PATCH_COMMAND ${CMAKE_COMMAND} -E copy
${fletch_SOURCE_DIR}/Patches/PNG/CMakeLists.txt
${fletch_BUILD_PREFIX}/src/PNG/CMakeLists.txt
CMAKE_GENERATOR ${gen}
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX:PATH=${fletch_BUILD_INSTALL_PREFIX}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
${png_cmake_args}
)

set(PNG_ROOT "${fletch_BUILD_INSTALL_PREFIX}" CACHE PATH "" FORCE)
file(APPEND ${fletch_CONFIG_INPUT} "
################################
# PNG
################################
set(PNG_ROOT @PNG_ROOT@)
")
42 changes: 42 additions & 0 deletions CMake/External_ZLib.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# The ZLib external project for fletch

ExternalProject_Add(ZLib
URL ${ZLib_file}
URL_MD5 ${zlib_md5}
DOWNLOAD_NAME ${zlib_dlname}
PREFIX ${fletch_BUILD_PREFIX}
DOWNLOAD_DIR ${fletch_DOWNLOAD_DIR}
INSTALL_DIR ${fletch_BUILD_INSTALL_PREFIX}
CMAKE_GENERATOR ${gen}
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX:PATH=${fletch_BUILD_INSTALL_PREFIX}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DBUILD_SHARED_LIBS:BOOL=ON
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
)

if(WIN32)
# Copy zlib to zdll for Qt
ExternalProject_Add_Step(ZLib fixup-install
COMMAND ${CMAKE_COMMAND} -E copy
${fletch_BUILD_INSTALL_PREFIX}/lib/zlib.lib
${fletch_BUILD_INSTALL_PREFIX}/lib/zdll.lib
DEPENDEES install
)
elseif(NOT APPLE)
# For Linux machines
ExternalProject_Add_Step(ZLib fixup-install
COMMAND ${CMAKE_COMMAND} -E copy
${fletch_BUILD_INSTALL_PREFIX}/lib/libzlib.so
${fletch_BUILD_INSTALL_PREFIX}/lib/libz.so
DEPENDEES install
)
endif()

set(ZLIB_ROOT ${fletch_BUILD_INSTALL_PREFIX} CACHE PATH "" FORCE)
file(APPEND ${fletch_CONFIG_INPUT} "
########################################
# ZLib
########################################
set(ZLIB_ROOT @ZLIB_ROOT@)
")
67 changes: 67 additions & 0 deletions CMake/External_libjpeg-turbo.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# libjpeg-turbo External project

include(External_yasm)
list(APPEND libjpeg-turbo_DEPENDS yasm)

if(WIN32)
ExternalProject_Add(libjpeg-turbo
URL ${libjpeg-turbo_url}
URL_MD5 ${libjpeg-turbo_md5}
DEPENDS ${libjpeg-turbo_DEPENDS}
PREFIX ${fletch_BUILD_PREFIX}
DOWNLOAD_DIR ${fletch_DOWNLOAD_DIR}
PATCH_COMMAND ${CMAKE_COMMAND}
-Dlibjpeg-turbo_patch:PATH=${fletch_SOURCE_DIR}/Patches/libjpeg-turbo
-Dlibjpeg-turbo_source:PATH=${fletch_BUILD_PREFIX}/src/libjpeg-turbo
-P ${fletch_SOURCE_DIR}/Patches/libjpeg-turbo/Patch.cmake
INSTALL_DIR ${fletch_BUILD_INSTALL_PREFIX}

CMAKE_GENERATOR ${gen}
CMAKE_ARGS
-DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}
-DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS}
-DCMAKE_INSTALL_PREFIX:PATH=${fletch_BUILD_INSTALL_PREFIX}
-DNASM:FILEPATH=${fletch_YASM} -g vc8
)

ExternalProject_Add_Step(libjpeg-turbo fixup-install
COMMAND ${CMAKE_COMMAND} -E copy
${fletch_BUILD_INSTALL_PREFIX}/lib/jpeg.lib
${fletch_BUILD_INSTALL_PREFIX}/lib/libjpeg.lib
DEPENDEES install
)
else()
# We need some special Apple treatment
if(APPLE)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(_libjpeg-turbo_ARGS_APPLE --host x86_64-apple-darwin )
endif()
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
# Need to investigate/apply the following command-line options for 32-bit when required.
# Configure commandline comes from the BUILDING.txt file in libjpeg-turbo source
# "--host i686-apple-darwin CFLAGS='-isysroot /Developer/SDKs/MacOSX10.5.sdk
# -mmacosx-version-min=10.5 -O3 -m32' LDFLAGS='-isysroot
# /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 -m32'")

endif()
endif()

Fletch_Require_Make()
ExternalProject_Add(libjpeg-turbo
URL ${libjpeg-turbo_url}
URL_MD5 ${libjpeg-turbo_md5}
DEPENDS ${libjpeg-turbo_DEPENDS}
PREFIX ${fletch_BUILD_PREFIX}
DOWNLOAD_DIR ${fletch_DOWNLOAD_DIR}
INSTALL_DIR ${fletch_BUILD_INSTALL_PREFIX}
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND ./configure
--prefix=${fletch_BUILD_INSTALL_PREFIX}
${_libjpeg-turbo_ARGS_APPLE}
NASM=${fletch_YASM}
BUILD_COMMAND ${MAKE_EXECUTABLE}
INSTALL_COMMAND ${MAKE_EXECUTABLE} install
)
endif()
118 changes: 118 additions & 0 deletions CMake/External_libtiff.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# libtiff External project

# We need -fPIC when building statically
if( UNIX AND NOT BUILD_SHARED_LIBS)
set (CMAKE_POSITION_INDEPENDENT_CODE TRUE)
endif()

# JPEG
add_package_dependency(
PACKAGE libtiff
PACKAGE_DEPENDENCY libjpeg-turbo
PACKAGE_DEPENDENCY_ALIAS JPEG
)

# ZLIB
add_package_dependency(
PACKAGE libtiff
PACKAGE_DEPENDENCY ZLib
PACKAGE_DEPENDENCY_ALIAS ZLIB
)

if(WIN32)
set(libtiff_nmake_args
JPEG_SUPPORT=1
ZIP_SUPPORT=1
)

if(NOT JPEG_FOUND)
set(JPEG_INCLUDE_DIR ${fletch_BUILD_INSTALL_PREFIX}/include)
set(JPEG_LIBRARY ${fletch_BUILD_INSTALL_PREFIX}/lib/jpeg.lib)
endif()
set(libtiff_nmake_args
JPEG_INCLUDE=-I${JPEG_INCLUDE_DIR}
JPEG_LIB=${JPEG_LIBRARY}
${libtiff_nmake_args}
)

if(NOT ZLIB_FOUND)
set(ZLIB_INCLUDE_DIRS ${fletch_BUILD_INSTALL_PREFIX}/include)
set(ZLIB_LIBRARIES ${fletch_BUILD_INSTALL_PREFIX}/lib/zlib.lib)
endif()
set(libtiff_nmake_args
ZLIB_INCLUDE=-I${ZLIB_INCLUDE_DIRS}
ZLIB_LIB=${ZLIB_LIBRARIES}
${libtiff_nmake_args}
)

ExternalProject_Add(libtiff
DEPENDS ${libtiff_DEPENDS}
URL ${libtiff_url}
URL_MD5 ${libtiff_md5}
PREFIX ${fletch_BUILD_PREFIX}
DOWNLOAD_DIR ${fletch_DOWNLOAD_DIR}
DOWNLOAD_COMMAND ${libtiff_download_command}
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND ""
# Build with nmake
BUILD_COMMAND nmake -f Makefile.vc clean
COMMAND nmake -f Makefile.vc ${libtiff_nmake_args}
# Custom install
INSTALL_COMMAND ${CMAKE_COMMAND}
-DBUILD_DIR:PATH=${fletch_BUILD_PREFIX}/src/libtiff
-DINSTALL_DIR:PATH=${fletch_BUILD_INSTALL_PREFIX}
-P ${fletch_SOURCE_DIR}/Patches/libtiff/Install.cmake
)

else()
# variables to configure libtiff
set(libtiff_configure_args)

# JPEG
if (fletch_ENABLE_libjpeg-turbo)
set(JPEG_INCLUDE_DIR ${fletch_BUILD_INSTALL_PREFIX}/include)
set(JPEG_LIBRARY_PATH ${fletch_BUILD_INSTALL_PREFIX}/lib)
else()
get_filename_component(JPEG_LIBRARY_PATH JPEG_LIBRARY PATH)
endif()
set(libtiff_configure_args ${libtiff_configure_args}
"--with-jpeg-include-dir=${JPEG_INCLUDE_DIR}"
"--with-jpeg-lib-dir=${JPEG_LIBRARY_PATH}"
)

if (fletch_ENABLE_ZLib)
set(ZLIB_INCLUDE_DIRS ${fletch_BUILD_INSTALL_PREFIX}/include)
set(ZLIB_LIBRARY_PATH ${fletch_BUILD_INSTALL_PREFIX}/lib)
else()
get_filename_component(ZLIB_LIBRARY_PATH ZLIB_LIBRARY PATH)
endif()
set(libtiff_configure_args ${libtiff_configure_args}
"--with-zlib-include-dir=${ZLIB_INCLUDE_DIRS}"
"--with-zlib-lib-dir=${ZLIB_LIBRARY_PATH}"
)

Fletch_Require_Make()
ExternalProject_Add(libtiff
DEPENDS ${libtiff_DEPENDS}
URL ${libtiff_url}
URL_MD5 ${libtiff_md5}
PREFIX ${fletch_BUILD_PREFIX}
DOWNLOAD_DIR ${fletch_DOWNLOAD_DIR}
INSTALL_DIR ${fletch_BUILD_INSTALL_PREFIX}
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND ./configure
--prefix=${fletch_BUILD_INSTALL_PREFIX}
${libtiff_configure_args}

BUILD_COMMAND ${MAKE_EXECUTABLE}
INSTALL_COMMAND ${MAKE_EXECUTABLE} install
)
endif()

set(libtiff_ROOT "${fletch_BUILD_INSTALL_PREFIX}" CACHE PATH "" FORCE)
file(APPEND ${fletch_CONFIG_INPUT} "
################################
# libtiff
################################
set(libtiff_ROOT @libtiff_ROOT@)
")
28 changes: 28 additions & 0 deletions CMake/External_yasm.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# The yasm external project for fletch.
# This external project does not follow the normal pattern for
# fletch. It is only used by the jpeg-turbo project and only when
# NASM or YASM can't be found. So, the usual enable flags and infrastructure
# for a fletch. Instead this file is directly included
# in External_libjpegturbo.cmake.

if (NOT _external_yasm_include)
set(_external_yasm_include TRUE)
ExternalProject_Add(yasm
URL ${yasm_url}
URL_MD5 ${yasm_md5}
PREFIX ${fletch_BUILD_PREFIX}
DOWNLOAD_DIR ${fletch_DOWNLOAD_DIR}
CMAKE_GENERATOR ${gen}
INSTALL_COMMAND ""
CMAKE_ARGS
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DBUILD_SHARED_LIBS=OFF
)

if (WIN32)
set(fletch_YASM ${fletch_BUILD_PREFIX}/src/yasm-build/${CMAKE_CFG_INTDIR}/yasm.exe)
else()
set(fletch_YASM ${fletch_BUILD_PREFIX}/src/yasm-build/yasm)
endif()
endif()
10 changes: 5 additions & 5 deletions CMake/Utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ function(get_system_library_name lib_name result)
endfunction()

#
# Check whether vision-tpl builds the given package or we should look for
# Check whether fletch builds the given package or we should look for
# it in the system.
# Arguments:
# PACKAGE: Name of the package you want to add a dependency to
# PACKAGE_DEPENDENCY: Name of the dependency you want to add to the PACKAGE
# PACKAGE_DEPENDENCY_ALIAS: (Optional) Name used to find the package using
# find package. Use this when the library build by vision-tpl name differs from
# find package. Use this when the library build by fletch name differs from
# the cannonical name used by cmake to find packages.
# OPTIONAL: (Optional) Used when the PACKAGE_DEPENDENCY is optional to build the
# PACKAGE. This means that not finding the PACKAGE_DEPENDENCY will not prevent
Expand All @@ -54,7 +54,7 @@ endfunction()
# appended to this variable, intended to be used to list ExternalProject
# dependencies to ensure correct build order.
# ${PACKAGE}_WITH_${PACKAGE_DEPENDENCY}: Whether the PACKAGE builds against the
# PACKAGE_DEPENDENCY independently if it's built by vision-tpl or taken from
# PACKAGE_DEPENDENCY independently if it's built by fletch or taken from
# the system.
#
macro(add_package_dependency)
Expand Down Expand Up @@ -85,7 +85,7 @@ macro(add_package_dependency)
endif()

set(${MY_PACKAGE}_WITH_${MY_PACKAGE_DEPENDENCY})
if(vision-tpl_ENABLE_${MY_PACKAGE_DEPENDENCY})
if(fletch_ENABLE_${MY_PACKAGE_DEPENDENCY})
set(${MY_PACKAGE}_DEPENDS ${${MY_PACKAGE}_DEPENDS} ${MY_PACKAGE_DEPENDENCY})
set(${MY_PACKAGE}_WITH_${MY_PACKAGE_DEPENDENCY} ON)
else()
Expand Down Expand Up @@ -115,7 +115,7 @@ macro(add_package_dependency)
message(FATAL_ERROR
" ${dependency_name} is required to build ${MY_PACKAGE}.\n "
"Either:\n "
"- Turn on vision-tpl_ENABLE_${MY_PACKAGE_DEPENDENCY}.\n "
"- Turn on fletch_ENABLE_${MY_PACKAGE_DEPENDENCY}.\n "
"- Provide the location of an external ${dependency_name}.\n"
)
endif()
Expand Down
42 changes: 42 additions & 0 deletions CMake/fletch-tarballs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,48 @@ if(WIN32)
set(jom_md5 "4e88c6378c039f4a2786a4e72129b6d7")
endif()


# ZLib
set(ZLib_version 1.2.8)
set(ZLib_tag "66a753054b356da85e1838a081aa94287226823e")
set(ZLib_url "https://github.com/commontk/zlib/archive/${ZLib_tag}.zip")
set(zlib_md5 "1d0e64ac4f7c7fe3a73ae044b70ef857")
set(zlib_dlname "zlib-${ZLib_version}.zip")
list(APPEND fletch_external_sources ZLib)

# PNG
set(PNG_version_major 1)
set(PNG_version_minor 6)
set(PNG_version_patch 17)
set(PNG_version "${PNG_version_major}.${PNG_version_minor}.${PNG_version_patch}")
set(PNG_major_minor_no_dot "${PNG_version_major}${PNG_version_minor}")
set(PNG_version_no_dot "${PNG_major_minor_no_dot}${PNG_version_patch}")
if(WIN32)
set(PNG_url "http://downloads.sourceforge.net/project/libpng/libpng${PNG_major_minor_no_dot}/${PNG_version}/lpng${PNG_version_no_dot}.zip")
set(PNG_md5 "7bcdc8ba18d6ccb6047db846fdc8feb0")
else()
set(PNG_url "http://downloads.sourceforge.net/project/libpng/libpng${PNG_major_minor_no_dot}/${PNG_version}/libpng-${PNG_version}.tar.gz")
set(PNG_md5 "134282f1752dcf4cd81a37b8ff421cef")
endif()
list(APPEND fletch_external_sources PNG)

# libjpeg-turbo
set(libjpeg-turbo_version "1.4.0")
set(libjpeg-turbo_url "http://downloads.sourceforge.net/libjpeg-turbo/libjpeg-turbo-${libjpeg-turbo_version}.tar.gz")
set(libjpeg-turbo_md5 "039153dabe61e1ac8d9323b5522b56b0")
list(APPEND fletch_external_sources libjpeg-turbo)

# YASM for building jpeg-turbo, not third party library
set(yasm_version "1.3.0")
set(yasm_url "http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz")
set(yasm_md5 "fc9e586751ff789b34b1f21d572d96af")

# libtiff
set(libtiff_version "4.0.4beta")
set(libtiff_url "http://download.osgeo.org/libtiff/tiff-${libtiff_version}.tar.gz")
set(libtiff_md5 "49c93f9c06f16c1563a7a88802671aef")
list(APPEND fletch_external_sources libtiff)

# Qt
set(Qt_release_location official_releases) # official_releases or archive
set(Qt_version_major 4)
Expand Down
Loading

0 comments on commit 27acb32

Please sign in to comment.