CMakeLists.txt 2.35 KB
Newer Older
1 2
cmake_minimum_required(VERSION 3.1)
set(CMAKE_C_STANDARD 99)
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
3 4 5 6 7 8 9
include(CheckIncludeFiles)
include(TestBigEndian)
include(CheckCSourceCompiles)
include(cmake/macros.cmake)
project(libaec)
set(libaec_VERSION_MAJOR 1)
set(libaec_VERSION_MINOR 0)
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
10
set(libaec_VERSION_PATCH 1)
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
11 12
set(CMAKE_BUILD_TYPE Release)
enable_testing()
13

Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
14 15 16 17 18 19 20 21 22
check_include_files(malloc.h HAVE_MALLOC_H)
check_include_files(stdint.h HAVE_STDINT_H)
test_big_endian(WORDS_BIGENDIAN)
check_clzll(HAVE_DECL___BUILTIN_CLZLL)
if(NOT HAVE_DECL___BUILTIN_CLZLL)
  check_bsr64(HAVE_BSR64)
endif(NOT HAVE_DECL___BUILTIN_CLZLL)
find_inline_keyword()
find_restrict_keyword()
23

Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
24
configure_file(
25
  ${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.h.in
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
26 27
  ${CMAKE_CURRENT_BINARY_DIR}/config.h)
add_definitions("-DHAVE_CONFIG_H")
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
28

Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
29 30 31 32 33 34 35 36 37
option(BUILD_SHARED_LIBS "Build Shared Libraries" ON)
if(BUILD_SHARED_LIBS)
  set (LIB_TYPE SHARED)
else(BUILD_SHARED_LIBS)
  if(WIN32)
    message(WARNING "You will have to modify libaec.h for static libs.")
  endif(WIN32)
  set(LIB_TYPE STATIC)
endif(BUILD_SHARED_LIBS)
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
38

Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
39 40 41 42
set(libaec_SRCS
  ${PROJECT_SOURCE_DIR}/src/encode.c
  ${PROJECT_SOURCE_DIR}/src/encode_accessors.c
  ${PROJECT_SOURCE_DIR}/src/decode.c)
43

Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
44 45
include_directories("${PROJECT_BINARY_DIR}")
include_directories("${PROJECT_SOURCE_DIR}/src")
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
46

Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
47 48 49 50 51
add_subdirectory(src)
add_subdirectory(tests)

option(AEC_FUZZING "Enable build of fuzzing targets" OFF)
if(AEC_FUZZING)
52
  add_subdirectory(fuzzing)
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
53 54 55 56 57
endif()

set(CPACK_PACKAGE_NAME "libaec")
set(CPACK_PACKAGE_VENDOR "Deutsches Klimarechenzentrum GmbH")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
58
  "libaec - Adaptive Entropy Coding library")
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
59 60 61 62 63
set(CPACK_PACKAGE_VERSION_MAJOR "${libaec_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${libaec_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${libaec_VERSION_PATCH}")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "libaec")
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/Copyright.txt")
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
64

Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
65 66 67 68 69 70
if(WIN32)
  set(CPACK_GENERATOR "WIX")
  set(CPACK_WIX_UPGRADE_GUID "E58A21F6-BB99-46B5-8AD8-6114E4CCA0A6")
  if(CMAKE_CL_64)
    set(CPACK_INSTALL_DIRECTORY "$PROGRAMFILES64")
    set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY
71
      "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION} (Win64)")
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
72 73 74
  else(CMAKE_CL_64)
    set(CPACK_INSTALL_DIRECTORY "$PROGRAMFILES")
    set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY
75
      "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
76 77
  endif(CMAKE_CL_64)
endif(WIN32)
Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
78

Mathis Rosenhauer's avatar
Mathis Rosenhauer committed
79
include(CPack)