Browse Source

- added support for cmake

tags/v0.1
andreas.romeyke@slub-dresden.de 3 years ago
parent
commit
13a5fa044d
5 changed files with 120 additions and 17 deletions
  1. +1
    -1
      README.1st
  2. +23
    -0
      README.compile
  3. +0
    -16
      README.windows
  4. +87
    -0
      src/CMakeLists.txt
  5. +9
    -0
      src/toolchain-mingw32.cmake

+ 1
- 1
README.1st View File

@@ -17,7 +17,7 @@ fixit_tiff:
- fixes a TIFF file with wrong metadata
- needs a Linux or an AIX system with installed libtiff4
(crosscompiling to Windows should work, too)
- compile it with: make clean; make all; make strip
- see README.compile, alternatively: compile it with "make clean; make all; make strip"
- help comes with option "fixit_tiff -h"



+ 23
- 0
README.compile View File

@@ -0,0 +1,23 @@
# You need an installed cmake
########################################################
# compiling under linux
########################################################
mkdir build
cd build
cmake ../src/
make
########################################################
# alternatively for windows crosscompiling using mingw
########################################################
#mkdir build
#cd build
#cmake -DCMAKE_TOOLCHAIN_FILE=../src/toolchain-mingw32.cmake -DTIFF_LIBRARY=~/Downloads/tiff-4.0.6/libtiff/.libs/libtiff.a -DTIFF_INCLUDE_DIR=~/Downloads/tiff-4.0.6/libtiff/ ../src/
#make
#
########################################################
# examples/options to set specific C-compiler or Flags
########################################################
# cmake ../src/ -DCMAKE_C_COMPILER=$(which gcc)
# cmake ../src/ -DCMAKE_C_FLAGS="-O0 -p -g"
# cmake ../src/ -DCMAKE_C_COMPILER=$(which clang-3.5) -DCMAKE_C_FLAGS="-Oz -pedantic"
#

+ 0
- 16
README.windows View File

@@ -16,24 +16,8 @@ Crosscompiling to Windows
under windows)
** make -j 2

== libpcre ==
* needed to compile checkit_tiff
* download the libpcre Source package
** http://www.pcre.org/ (pcre-8.3.7.tar.gz)
* crosscompile libpcre for windows
** cd to unzipped source package
** autoconf
** ./configure --host=i686-w64-mingw32 --disable-shared --enable-static
** make



== fixit_tiff ==
* now compile fixit-tool
** cd to fixit-tool directory
** CC="i686-w64-mingw32-gcc" INC="-I ../tiff-4.0.6/libtiff/ -L ../tiff-4.0.6/libtiff/.libs/ -static" make

== checkit_tiff ==
* now compile fixit-tool
** cd to checkit-tool directory
** SANITIZE="" CC="i686-w64-mingw32-gcc" INC="-DPCRE_STATIC -I../tiff-4.0.6/libtiff/ -I../pcre-8.37/" LIB="-fPIC -static -L../tiff-4.0.6/libtiff/.libs/ -L../pcre-8.37/.libs/" make checkit_tiff

+ 87
- 0
src/CMakeLists.txt View File

@@ -0,0 +1,87 @@
cmake_minimum_required (VERSION 2.6)
project (fixit_tiff)
include_directories("${PROJECT_SOURCE_DIR}")
include (CheckSymbolExists)

file( GLOB fixit_tiff_SOURCES
"${PROJECT_SOURCE_DIR}/*.c"
)
#
# Make a version file containing the current version from git.
#
execute_process( COMMAND git rev-list HEAD --count OUTPUT_VARIABLE REPO_REVISION OUTPUT_STRIP_TRAILING_WHITESPACE )
execute_process( COMMAND git rev-parse --abbrev-ref HEAD OUTPUT_VARIABLE BUILD_BRANCH OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process( COMMAND git rev-parse HEAD OUTPUT_VARIABLE BUILD_REV_ID OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process( COMMAND git describe --long --tags --dirty --always OUTPUT_VARIABLE BUILD_REV_ID_SHORT OUTPUT_STRIP_TRAILING_WHITESPACE)
add_definitions(-DVERSION="${BUILD_BRANCH}")
add_definitions(-DREPO_REVISION="${REPO_REVISION}")

if(WIN32)
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
SET(BUILD_SHARED_LIBRARIES OFF)
SET(CMAKE_EXE_LINKER_FLAGS "-static")
add_definitions(-DPCRE_STATIC)
add_definitions(-D_POSIX_C_SOURCE=200809L)
# FIXME: needed for MingW only
add_definitions(-D_GNU_SOURCE=1)
endif(WIN32)

add_executable(fixit_tiff fixit_tiff.c ${fixit_tiff_SOURCES})
set(CMAKE_EXTRA_INCLUDE_FILES tiff.h)


## libtiff5
find_package(TIFF REQUIRED)
if(TIFF_FOUND)
# Confirm required API is available
#INCLUDE(CheckFunctionExists)
SET(CMAKE_REQUIRED_LIBRARIES ${TIFF_LIBRARIES})
#CHECK_FUNCTION_EXISTS(TIFFOpen HAVE_TIFFOPEN)
#IF(NOT HAVE_TIFFOPEN)
# SET(TIFF_FOUND) # ReSET to NOT found for TIFF library
# MESSAGE(FATAL_ERROR "Failed to link with libtiff - TIFFOpen function not found")
#ENDIF()

# CHECK_FUNCTION_EXISTS(TIFFMergeFieldInfo HAVE_TIFFMERGEFIELDINFO)
#IF(NOT HAVE_TIFFMERGEFIELDINFO)
# SET(TIFF_FOUND) # ReSET to NOT found for TIFF library
# MESSAGE(FATAL_ERROR "Failed to link with libtiff - TIFFMergeFieldInfo function not found. libtiff 3.6.0 Beta or later required. Please upgrade or use an older version of libgeotiff")
#ENDIF()
INCLUDE_DIRECTORIES(${TIFF_INCLUDE_DIR})
ADD_DEFINITIONS(-DHAVE_TIFF=1)

CHECK_SYMBOL_EXISTS(TIFFTAG_IMAGELAYER "tiff.h" HAVE_TIFFTAG_IMAGE_LAYER)
IF(NOT HAVE_TIFFTAG_IMAGE_LAYER)
MESSAGE(STATUS "old tiff library detected, -DTIFFTAG_IMAGELAYER=34732 added")
ADD_DEFINITIONS(-DTIFFTAG_IMAGELAYER=34732)
ENDIF()

CHECK_SYMBOL_EXISTS(TIFF_UINT64_T "tiff.h" HAVE_TIFF_UINT64_T)
IF(NOT HAVE_TIFF_UINT64_T)
MESSAGE(STATUS "old tiff library detected, -Duint64='unsigned long long' added")
ADD_DEFINITIONS(-Duint64=unsigned\ long\ long)
ENDIF()

CHECK_SYMBOL_EXISTS(TIFF_INT64_T "tiff.h" HAVE_TIFF_INT64_T)
IF(NOT HAVE_TIFF_INT64_T)
MESSAGE(STATUS "old tiff library detected, -Dint64='long long' added")
ADD_DEFINITIONS(-Dint64=long\ long)
ENDIF()

else(TIFF_FOUND)
MESSAGE(FATAL_ERROR "No TIFF library found, add $TIFF_INCLUDE_DIR manually")
endif(TIFF_FOUND)

TARGET_LINK_LIBRARIES(fixit_tiff ${TIFF_LIBRARIES})

install( TARGETS fixit_tiff
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
)
install(DIRECTORY
../examples
DESTINATION share/fixit_tiff/
)

file( GLOB README_FILES "../README*" "../FAQ" "../LICENSE" "../TODO" "../BUGS")
install(FILES ${README_FILES} DESTINATION share/fixit_tiff/)

+ 9
- 0
src/toolchain-mingw32.cmake View File

@@ -0,0 +1,9 @@
set (CMAKE_SYSTEM_NAME Windows)
set (CMAKE_C_COMPILER i686-w64-mingw32-gcc)
set (CMAKE_CXX_COMPILER i686-w64-mingw32-g++)
set (CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32)
set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
# call cmake:
# cmake -DCMAKE_TOOLCHAIN_FILE=toolchain-mingw32.cmake SRCPATH

Loading…
Cancel
Save