summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
blob: 32d3c45a03faed2302661551857e46e76ffc705d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.6)
INCLUDE(CheckIncludeFiles)
INCLUDE(TestBigEndian)
INCLUDE(CheckCSourceCompiles)
INCLUDE(cmake/macros.cmake)
PROJECT(libaec)
SET(libaec_VERSION_MAJOR 0)
SET(libaec_VERSION_MINOR 3)
SET(libaec_VERSION_PATCH 3)
SET(CMAKE_BUILD_TYPE Release)
ENABLE_TESTING()

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()

CONFIGURE_FILE(
  ${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.h.in
  ${CMAKE_CURRENT_BINARY_DIR}/config.h
  )
ADD_DEFINITIONS("-DHAVE_CONFIG_H")

# Allow the developer to select if Dynamic or Static libraries are built
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)

INCLUDE_DIRECTORIES("${PROJECT_BINARY_DIR}")
INCLUDE_DIRECTORIES("${PROJECT_BINARY_DIR}/src")
INCLUDE_DIRECTORIES("${PROJECT_SOURCE_DIR}/src")

ADD_SUBDIRECTORY(src)
# EXCLUDE_FROM_ALL doesn't seem to be working in VS
ADD_SUBDIRECTORY(tests)

SET(CPACK_PACKAGE_NAME "libaec")
SET(CPACK_PACKAGE_VENDOR "Deutsches Klimarechenzentrum GmbH")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY
  "libaec - Adaptive Entropy Coding library")
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")

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
      "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION} (Win64)")
  ELSE(CMAKE_CL_64)
    SET(CPACK_INSTALL_DIRECTORY "$PROGRAMFILES")
    SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY
      "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
  ENDIF(CMAKE_CL_64)
ENDIF(WIN32)

INCLUDE(CPack)