"checkit_tiff" is an incredibly fast conformance checker for baseline TIFFs (with various extensions), see http://andreas-romeyke.de
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

180 lines
7.0 KiB

cmake_minimum_required (VERSION 3.9.4)
project (checkit_tiff)
include_directories("${PROJECT_SOURCE_DIR}/headers")
include_directories("${PROJECT_SOURCE_DIR}/validate_icc")
include (CheckSymbolExists)
include (CheckFunctionExists)
include(CheckIPOSupported)
file( GLOB checkit_tiff_SOURCES
"${PROJECT_SOURCE_DIR}/tagrules/*.c"
"${PROJECT_SOURCE_DIR}/ifdrules/*.c"
"${PROJECT_SOURCE_DIR}/messages/*.c"
"${PROJECT_SOURCE_DIR}/helper/*.c"
"${PROJECT_SOURCE_DIR}/helper/renderer/*.c"
"${PROJECT_SOURCE_DIR}/parser/*parser.c"
"${PROJECT_SOURCE_DIR}/validate_icc/*.c"
"${PROJECT_SOURCE_DIR}/risk_analyzer/*.c"
)
file( GLOB checkit_tiff_risk_SOURCES
"${PROJECT_SOURCE_DIR}/helper/check_helper.c"
"${PROJECT_SOURCE_DIR}/helper/check_print.c"
"${PROJECT_SOURCE_DIR}/helper/check_tiffparse.c"
"${PROJECT_SOURCE_DIR}/messages/*.c"
"${PROJECT_SOURCE_DIR}/risk_analyzer/*.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 describe --tags OUTPUT_VARIABLE BUILD_TAG 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}_${BUILD_TAG}")
add_definitions(-DREPO_REVISION="${REPO_REVISION}")
check_ipo_supported(RESULT LTO_IS_SUPPORTED OUTPUT LTO_CHECK_ERROR)
if (LTO_IS_SUPPORTED)
message(STATUS "IPO / LTO enabled")
set(INTERPROCEDURAL_OPTIMIZATIONS TRUE)
else()
message(STATUS "IPO / LTO unsupported: <${LTO_CHECK_ERROR}>")
endif()
# add default CFLAGS
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector-strong -Wformat -Werror=format-security")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,relro -fPIE")
# Check for compatibility with gnu11
# Compile with gnu11 support.
include(CheckCCompilerFlag)
CHECK_C_COMPILER_FLAG("-std=gnu11" COMPILER_SUPPORTS_GNU11)
if(COMPILER_SUPPORTS_GNU11)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu11")
else()
message(STATUS "Your compiler (${CMAKE_C_COMPILER}) has no gnu11 support.")
message(STATUS "If you are using clang on Apple OS X, please switch to gcc (version > 4.7) which is compliant with the C11 standard.")
message(STATUS "If you are using MinGW or compile under MS Windows, the code could compile, but without any warranty and without any support!")
endif()
if(WIN32)
add_definitions(-D__WIN32__=1)
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
set(BUILD_SHARED_LIBRARIES OFF)
# needed to increase default stack, because Win7 has only 1MB
set(CMAKE_EXE_LINKER_FLAGS "-static -Wl,--stack,20000000")
add_definitions(-DPCRE_STATIC)
add_definitions(-D_POSIX_C_SOURCE=200809L)
# FIXME: needed for MingW only
add_definitions(-D_GNU_SOURCE=1)
endif()
if(STATIC)
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
set(BUILD_SHARED_LIBRARIES OFF)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
add_definitions(-DPCRE_STATIC)
endif()
add_executable(checkit_tiff checkit_tiff.c ${checkit_tiff_SOURCES})
add_executable(checkit_check_config checkit_check_config.c ${checkit_tiff_SOURCES})
add_executable(checkit_tiff_risk checkit_tiff_risk.c ${checkit_tiff_risk_SOURCES})
set(CMAKE_EXTRA_INCLUDE_FILES tiff.h)
#libpcre
#find_package(LIBPCRE REQUIRED)
find_path(PCRE_INCLUDE_DIR NAMES pcre.h)
find_library(PCRE_LIBRARY NAMES pcre)
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCRE DEFAULT_MSG PCRE_LIBRARY PCRE_INCLUDE_DIR)
if (PCRE_FOUND)
set(PCRE_LIBRARIES ${PCRE_LIBRARY})
if (STATIC)
set(PCRE_LIBRARIES ${PCRE_LIBRARIES} -lpthread)
endif()
set(PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIR})
include_directories(${PCRE_INCLUDE_DIR})
else()
message(FATAL_ERROR "No PCRE library found, add $PCRE_INCLUDE_DIR manually")
endif()
#find mmap
CHECK_FUNCTION_EXISTS(mmap _HAVE_MMAP)
CHECK_FUNCTION_EXISTS(munmap _HAVE_MUNMAP)
if(_HAVE_MMAP AND _HAVE_MUNMAP)
message(INFO "mmap found")
set(_HAVE__MMAP 1)
endif()
target_link_libraries(checkit_tiff ${PCRE_LIBRARIES})
target_link_libraries(checkit_check_config ${PCRE_LIBRARIES})
target_link_libraries(checkit_tiff_risk)
install( TARGETS checkit_tiff
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
)
install(DIRECTORY
../example_configs
../tiffs_should_fail
../tiffs_should_pass
DESTINATION share/checkit_tiff/
)
file( GLOB README_FILES "../README*" "../FAQ" "../LICENSE" "../TODO" "../BUGS")
install(FILES ${README_FILES} DESTINATION share/checkit_tiff/)
include(FindPerl)
if (PERL_FOUND)
enable_testing()
set(T_DIR ${PROJECT_SOURCE_DIR}/../t )
add_test(NAME grammar COMMAND ${PERL_EXECUTABLE} -I ${T_DIR} test_grammar.t WORKING_DIRECTORY ${T_DIR} )
add_test(NAME config COMMAND ${PERL_EXECUTABLE} -I ${T_DIR} test_config_examples.t WORKING_DIRECTORY ${T_DIR} )
add_test(NAME validfiles COMMAND ${PERL_EXECUTABLE} -I ${T_DIR} test_should_pass.t WORKING_DIRECTORY ${T_DIR} )
add_test(NAME invalidfiles COMMAND ${PERL_EXECUTABLE} -I ${T_DIR} test_should_fail.t WORKING_DIRECTORY ${T_DIR} )
else()
message(WARN "for testsuite an installed Perl is needed")
endif()
# CPACK definitions
include(InstallRequiredSystemLibraries)
set (CPACK_PACKAGE_VENDOR "Andreas Romeyke")
string(REGEX REPLACE "^v([0-9]+).*" "\\1" MAJOR_VERSION ${BUILD_TAG})
string(REGEX REPLACE "^v[0-9]+\\.([0-9]+)\\.[0-9]+[^0-9].*" "\\1" MINOR_VERSION ${BUILD_TAG})
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+)[^0-9].*" "\\1" PATCH_VERSION ${BUILD_TAG})
message( "BUILDTAG (after) : '${BUILD_TAG}'")
message( "MAJOR VERSION: ${MAJOR_VERSION}")
message( "MINOR VERSION: ${MINOR_VERSION}")
message( "PATCH VERSION: ${PATCH_VERSION}")
set (CPACK_PACKAGE_VERSION_MAJOR ${MAJOR_VERSION})
set (CPACK_PACKAGE_VERSION_MINOR ${MINOR_VERSION})
set (CPACK_PACKAGE_VERSION_PATCH ${PATCH_VERSION})
set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/../LICENSE")
set (CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/../README.1st_checkit")
set (CPACK_GENERATOR "TGZ;STGZ;TZ;DEB;RPM")
#set (CPACK_GENERATOR "DEB")
set (CPACK_PACKAGE_CONTACT "Andreas Romeyke checkit_tiff@andreas-romeyke.de")
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
#set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc (>= 6.0)")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "checkit_tiff is a policy-oriented conformance checker for baseline TIFFs")
set(CPACK_PACKAGE_DESCRIPTION "checkit_tiff is a conformance checker for baseline TIFFs (with various
extensions). It works in different way than other tools. Instead to use a
hardcoded rule set with predefined values, you are able to define tags and
corresponding values more fine granulary. The rulesets are human readable and
could be adapted to own needs.")
set(CPACK_DEBIAN_PACKAGE_SECTION "misc")
set(CPACK_DEBIAN_COMPRESSION_TYPE "xz")
include(CPack)