diff options
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 124 |
1 files changed, 73 insertions, 51 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 65fbf18..bf79f63 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,9 @@ # -# CMakeLists.txt --- a simple "cmake" file for building LZO +# CMakeLists.txt --- a simple "CMake" file for building LZO # # This file is part of the LZO data compression library. # -# Copyright (C) 1996-2014 Markus Franz Xaver Johannes Oberhumer +# Copyright (C) 1996-2015 Markus Franz Xaver Johannes Oberhumer # All Rights Reserved. # @@ -20,6 +20,8 @@ # make VERBOSE=1 # make install # +# see http://www.cmake.org/ for more info +# # # init @@ -58,6 +60,7 @@ endif() file(GLOB lzo_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.c") list(SORT lzo_SOURCES) +# LZO library if(NOT ENABLE_STATIC AND NOT ENABLE_SHARED) set(ENABLE_STATIC ON) endif() @@ -68,9 +71,10 @@ endif() if(ENABLE_SHARED) add_library(lzo_shared SHARED ${lzo_SOURCES}) set_target_properties(lzo_shared PROPERTIES OUTPUT_NAME lzo2) - # TODO: VERSION, SOVERSION + set_target_properties(lzo_shared PROPERTIES SOVERSION 2 VERSION 2.0.0) endif() +# tests & examples macro(lzo_add_executable t) add_executable(${t} ${ARGN}) if(ENABLE_STATIC) @@ -88,12 +92,18 @@ lzo_add_executable(overlap examples/overlap.c) lzo_add_executable(precomp examples/precomp.c) lzo_add_executable(precomp2 examples/precomp2.c) lzo_add_executable(simple examples/simple.c) +# some boring internal test programs if(0) -# some boring test programs -lzo_add_executable(align tests/align.c) -lzo_add_executable(chksum tests/chksum.c) -lzo_add_executable(promote tests/promote.c) -lzo_add_executable(sizes tests/sizes.c) + lzo_add_executable(align tests/align.c) + lzo_add_executable(chksum tests/chksum.c) + lzo_add_executable(promote tests/promote.c) + lzo_add_executable(sizes tests/sizes.c) +endif() + +# miniLZO +if(1) + add_executable(testmini minilzo/testmini.c minilzo/minilzo.c) + include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include/lzo) # needed for "lzoconf.h" endif() # @@ -111,76 +121,88 @@ include(CheckTypeSize) include(TestBigEndian) # Checks for header files -macro(lzo_check_include_file f var) - check_include_file("${f}" "${var}") - if(NOT ",${${var}}," STREQUAL ",,") +macro(mfx_check_include_file f var) + check_include_file("${f}" "mfx_${var}") + if(NOT ",${mfx_${var}}," STREQUAL ",,") add_definitions(-D${var}=1) + set(mfx_${var} 1) + else() + set(mfx_${var} 0) endif() endmacro() -lzo_check_include_file(stdint.h HAVE_STDINT_H) -lzo_check_include_file(sys/stat.h HAVE_SYS_STAT_H) -lzo_check_include_file(sys/types.h HAVE_SYS_TYPES_H) +# mfx_ACC_CHECK_HEADERS +set(l assert.h ctype.h dirent.h errno.h fcntl.h float.h limits.h malloc.h memory.h setjmp.h signal.h stdarg.h stddef.h stdint.h stdio.h stdlib.h string.h strings.h time.h unistd.h utime.h sys/mman.h sys/resource.h sys/stat.h sys/time.h sys/types.h sys/wait.h) +foreach(f ${l}) + string(TOUPPER "${f}" var) + string(REGEX REPLACE "[^0-9A-Z_]" "_" var "${var}") + mfx_check_include_file("${f}" "HAVE_${var}") +endforeach() # Checks for typedefs and structures -macro(lzo_check_type_size type var) - check_type_size("${type}" "${var}") - if("${${var}}" MATCHES "^[0-9]+$") - add_definitions(-D${var}=${${var}}) +macro(mfx_check_type_size type var) + check_type_size("${type}" "mfx_${var}") + if("${mfx_${var}}" MATCHES "^[1-9][0-9]*$") + add_definitions(-D${var}=${mfx_${var}}) + else() + set(mfx_${var} 0) endif() endmacro() -lzo_check_type_size("short" SIZEOF_SHORT) -lzo_check_type_size("int" SIZEOF_INT) -lzo_check_type_size("long" SIZEOF_LONG) -lzo_check_type_size("long long" SIZEOF_LONG_LONG) -lzo_check_type_size("ptrdiff_t" SIZEOF_PTRDIFF_T) -lzo_check_type_size("size_t" SIZEOF_SIZE_T) -lzo_check_type_size("void *" SIZEOF_VOID_P) -lzo_check_type_size("uintptr_t" SIZEOF_UINTPTR_T) -lzo_check_type_size("__int16" SIZEOF___INT16) -lzo_check_type_size("__int32" SIZEOF___INT32) -lzo_check_type_size("__int64" SIZEOF___INT64) -lzo_check_type_size("off_t" SIZEOF_OFF_T) -##lzo_check_type_size("off64_t" SIZEOF_OFF64_T) +# mfx_ACC_CHECK_SIZEOF + mfx_CHECK_SIZEOF +set(l short int long "long long" __int16 __int32 __int64 "void *" size_t ptrdiff_t intmax_t uintmax_t intptr_t uintptr_t float double "long double" dev_t fpos_t mode_t off_t ssize_t time_t) +foreach(f ${l}) + string(TOUPPER "${f}" var) + string(REGEX REPLACE " \\*" "_P" var "${var}") + string(REGEX REPLACE "[^0-9A-Z_]" "_" var "${var}") + mfx_check_type_size("${f}" "SIZEOF_${var}") +endforeach() # Checks for library functions -macro(lzo_check_function_exists func var) - check_function_exists("${func}" "${var}") - if(NOT ",${${var}}," STREQUAL ",,") +macro(mfx_check_function_exists func var) + check_function_exists("${func}" "mfx_${var}") + if(NOT ",${mfx_${var}}," STREQUAL ",,") add_definitions(-D${var}=1) + set(mfx_${var} 1) + else() + set(mfx_${var} 0) endif() endmacro() -lzo_check_function_exists(clock_gettime HAVE_CLOCK_GETTIME) -lzo_check_function_exists(stat HAVE_STAT) -lzo_check_function_exists(strncasecmp HAVE_STRNCASECMP) -lzo_check_function_exists(strnicmp HAVE_STRNICMP) - -set(big_endian) +# mfx_ACC_CHECK_FUNCS +set(l access alloca atexit atoi atol chmod chown clock_getcpuclockid clock_getres clock_gettime ctime difftime fstat getenv getpagesize getrusage gettimeofday gmtime isatty localtime longjmp lstat memcmp memcpy memmove memset mkdir mktime mmap mprotect munmap qsort raise rmdir setjmp signal snprintf strcasecmp strchr strdup strerror strftime stricmp strncasecmp strnicmp strrchr strstr time umask utime vsnprintf) +foreach(f ${l}) + string(TOUPPER "${f}" var) + string(REGEX REPLACE "[^0-9A-Z_]" "_" var "${var}") + mfx_check_function_exists("${f}" "HAVE_${var}") +endforeach() + +# mfx_LZO_CHECK_ENDIAN TEST_BIG_ENDIAN(big_endian) if ("${big_endian}" MATCHES "^1$") add_definitions(-DLZO_ABI_BIG_ENDIAN=1) elseif ("${big_endian}" MATCHES "^0$") add_definitions(-DLZO_ABI_LITTLE_ENDIAN=1) else() - message(FATAL_ERROR "ERROR: TEST_BIG_ENDIAN failed.") + message(FATAL_ERROR "ERROR: TEST_BIG_ENDIAN failed with result '${big_endian}'.") endif() +# LZO_HAVE_CONFIG_H +add_definitions(-DLZO_CFG_NO_CONFIG_HEADER=1) # # "make install" # -# subdirs relative to CMAKE_INSTALL_PREFIX +# these subdirs are relative to CMAKE_INSTALL_PREFIX if(NOT DEFINED install_doc_subdir) - set(install_doc_subdir doc) + set(install_doc_subdir "share/doc/lzo") endif() if(NOT DEFINED install_include_subdir) - set(install_include_subdir include) + set(install_include_subdir "include/lzo") endif() if(NOT DEFINED install_lib_subdir) - set(install_lib_subdir lib) + set(install_lib_subdir "lib") endif() if(NOT DEFINED install_examples_subdir) - set(install_examples_subdir libexec/lzo-examples) + set(install_examples_subdir "libexec/lzo/examples") endif() set(doc_DATA AUTHORS COPYING NEWS THANKS doc/LZO.FAQ doc/LZO.TXT doc/LZOAPI.TXT) @@ -192,13 +214,13 @@ set(pkginclude_HEADERS include/lzo/lzoutil.h ) -install(FILES ${doc_DATA} DESTINATION ${install_doc_subdir}) -install(FILES ${pkginclude_HEADERS} DESTINATION ${install_include_subdir}/lzo) +install(FILES ${doc_DATA} DESTINATION "${install_doc_subdir}") +install(FILES ${pkginclude_HEADERS} DESTINATION "${install_include_subdir}") if(ENABLE_STATIC) - install(TARGETS lzo_static DESTINATION ${install_lib_subdir}) + install(TARGETS lzo_static DESTINATION "${install_lib_subdir}") endif() if(ENABLE_SHARED) - install(TARGETS lzo_shared DESTINATION ${install_lib_subdir}) + install(TARGETS lzo_shared DESTINATION "${install_lib_subdir}") endif() if(0) set(lzo_EXAMPLES lzopack lzotest simple) @@ -206,7 +228,7 @@ if(0) set(d "${CMAKE_INSTALL_PREFIX}/${install_lib_subdir}") set_target_properties(${lzo_EXAMPLES} PROPERTIES INSTALL_RPATH "${d}") endif() - install(TARGETS ${lzo_EXAMPLES} DESTINATION ${install_examples_subdir}) + install(TARGETS ${lzo_EXAMPLES} DESTINATION "${install_examples_subdir}") endif() # vim:set ft=cmake ts=4 sw=4 tw=0 et: |