Home | History | Annotate | Download | only in cmake_unofficial
      1 PROJECT(LZ4 C)
      2 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "LZ4 compression library")
      3 set(CPACK_PACKAGE_VERSION_MAJOR 1)
      4 set(CPACK_PACKAGE_VERSION_MINOR 5)
      5 set(CPACK_PACKAGE_VERSION_PATCH r126)
      6 set(VERSION_STRING	" \"${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}\" ")
      7 include(CPack)
      8 
      9 cmake_minimum_required (VERSION 2.6)
     10 INCLUDE (CheckTypeSize)
     11 check_type_size("void *" SIZEOF_VOID_P)
     12 IF( ${SIZEOF_VOID_P} STREQUAL  "8" )
     13     set (CMAKE_SYSTEM_PROCESSOR "64bit")
     14     MESSAGE( STATUS "64 bit architecture detected size of void * is " ${SIZEOF_VOID_P})
     15 ENDIF()
     16 
     17 option(BUILD_TOOLS "Build the command line tools" ON)
     18 option(BUILD_LIBS  "Build the libraries in addition to the tools" OFF)
     19 
     20 if(UNIX AND BUILD_LIBS)
     21     if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
     22         add_definitions(-fPIC)
     23     endif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
     24 endif()
     25 
     26 set(LZ4_DIR ../lib/)
     27 set(PRG_DIR ../programs/)
     28 set(LZ4_SRCS_LIB ${LZ4_DIR}lz4.c ${LZ4_DIR}lz4hc.c ${LZ4_DIR}lz4.h ${LZ4_DIR}lz4hc.h)
     29 set(LZ4_SRCS ${LZ4_DIR}lz4frame.c ${LZ4_DIR}xxhash.c ${PRG_DIR}bench.c ${PRG_DIR}lz4cli.c ${PRG_DIR}lz4io.c)
     30 
     31 if(BUILD_TOOLS AND NOT BUILD_LIBS)
     32     set(LZ4_SRCS ${LZ4_SRCS} ${LZ4_SRCS_LIB})
     33 endif()
     34 
     35 if(BUILD_TOOLS)
     36     add_executable(lz4 ${LZ4_SRCS})
     37     set_target_properties(lz4 PROPERTIES COMPILE_DEFINITIONS DISABLE_LZ4C_LEGACY_OPTIONS)
     38     install(TARGETS lz4 RUNTIME DESTINATION "bin/")
     39     add_executable(lz4c ${LZ4_SRCS})
     40     install(TARGETS lz4c RUNTIME DESTINATION "bin/")
     41 endif()
     42 
     43 if(BUILD_LIBS)    
     44     add_library(liblz4 ${LZ4_SRCS_LIB})
     45     
     46     set_target_properties(liblz4 PROPERTIES
     47     OUTPUT_NAME lz4
     48     SOVERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}"
     49     )
     50         
     51     install(TARGETS liblz4
     52     LIBRARY DESTINATION lib
     53     ARCHIVE DESTINATION lib
     54     )
     55 
     56     install(FILES
     57     ${LZ4_DIR}/lz4.h
     58     ${LZ4_DIR}/lz4hc.h
     59     DESTINATION include
     60     )
     61     
     62     if(BUILD_TOOLS)
     63         target_link_libraries(lz4 liblz4)
     64         target_link_libraries(lz4c liblz4)
     65     endif()
     66 endif()
     67 
     68 
     69 #warnings
     70 
     71 ADD_DEFINITIONS("-Wall")
     72 ADD_DEFINITIONS("-Wextra")
     73 ADD_DEFINITIONS("-Wundef")
     74 ADD_DEFINITIONS("-Wshadow")
     75 ADD_DEFINITIONS("-Wcast-align")
     76 ADD_DEFINITIONS("-Wstrict-prototypes")
     77 ADD_DEFINITIONS("-std=c99")
     78 ADD_DEFINITIONS("-DLZ4_VERSION=\"${CPACK_PACKAGE_VERSION_PATCH}\"")
     79 INCLUDE_DIRECTORIES (${LZ4_DIR})
     80 
     81 
     82 
     83