aboutsummaryrefslogtreecommitdiff
path: root/tools/rasm/apultra-master/src/libdivsufsort/include/CMakeLists.txt
blob: 37781ccb33e0442dbae6b2f0af89564a9087af0f (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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
include(CheckIncludeFiles)
include(CheckIncludeFile)
include(CheckSymbolExists)
include(CheckTypeSize)
include(CheckFunctionKeywords)
include(CheckLFS)

## Checks for header files ##
check_include_file("inttypes.h" HAVE_INTTYPES_H)
check_include_file("memory.h" HAVE_MEMORY_H)
check_include_file("stddef.h" HAVE_STDDEF_H)
check_include_file("stdint.h" HAVE_STDINT_H)
check_include_file("stdlib.h" HAVE_STDLIB_H)
check_include_file("string.h" HAVE_STRING_H)
check_include_file("strings.h" HAVE_STRINGS_H)
check_include_file("sys/types.h" HAVE_SYS_TYPES_H)
if(HAVE_INTTYPES_H)
  set(INCFILE "#include <inttypes.h>")
elseif(HAVE_STDINT_H)
  set(INCFILE "#include <stdint.h>")
else(HAVE_INTTYPES_H)
  set(INCFILE "")
endif(HAVE_INTTYPES_H)

## create configuration files from .cmake file ##
if(BUILD_EXAMPLES)
  ## Checks for WinIO ##
  if(WIN32)
    check_include_file("io.h" HAVE_IO_H)
    check_include_file("fcntl.h" HAVE_FCNTL_H)
    check_symbol_exists("_setmode" "io.h;fcntl.h" HAVE__SETMODE)
    if(NOT HAVE__SETMODE)
      check_symbol_exists("setmode" "io.h;fcntl.h" HAVE_SETMODE)
    endif(NOT HAVE__SETMODE)
    check_symbol_exists("_fileno" "stdio.h" HAVE__FILENO)
    check_symbol_exists("fopen_s" "stdio.h" HAVE_FOPEN_S)
    check_symbol_exists("_O_BINARY" "fcntl.h" HAVE__O_BINARY)
  endif(WIN32)

  ## Checks for large file support ##
  check_lfs(WITH_LFS)
  configure_file("${CMAKE_CURRENT_SOURCE_DIR}/lfs.h.cmake" "${CMAKE_CURRENT_BINARY_DIR}/lfs.h" @ONLY)
endif(BUILD_EXAMPLES)

## generate config.h ##
check_function_keywords("inline;__inline;__inline__;__declspec(dllexport);__declspec(dllimport)")
if(HAVE_INLINE)
  set(INLINE "inline")
elseif(HAVE___INLINE)
  set(INLINE "__inline")
elseif(HAVE___INLINE__)
  set(INLINE "__inline__")
else(HAVE_INLINE)
  set(INLINE "")
endif(HAVE_INLINE)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake" "${CMAKE_CURRENT_BINARY_DIR}/config.h")

## Checks for types ##
# sauchar_t (8bit)
check_type_size("uint8_t" UINT8_T)
if(HAVE_UINT8_T)
  set(SAUCHAR_TYPE "uint8_t")
else(HAVE_UINT8_T)
  check_type_size("unsigned char" SIZEOF_UNSIGNED_CHAR)
  if("${SIZEOF_UNSIGNED_CHAR}" STREQUAL "1")
    set(SAUCHAR_TYPE "unsigned char")
  else("${SIZEOF_UNSIGNED_CHAR}" STREQUAL "1")
    message(FATAL_ERROR "Cannot find unsigned 8-bit integer type")
  endif("${SIZEOF_UNSIGNED_CHAR}" STREQUAL "1")
endif(HAVE_UINT8_T)
# saint_t (32bit)
check_type_size("int32_t" INT32_T)
if(HAVE_INT32_T)
  set(SAINT32_TYPE "int32_t")
  check_symbol_exists("PRId32" "inttypes.h" HAVE_PRID32)
  if(HAVE_PRID32)
    set(SAINT32_PRId "PRId32")
  else(HAVE_PRID32)
    set(SAINT32_PRId "\"d\"")
  endif(HAVE_PRID32)
else(HAVE_INT32_T)
  check_type_size("int" SIZEOF_INT)
  check_type_size("long" SIZEOF_LONG)
  check_type_size("short" SIZEOF_SHORT)
  check_type_size("__int32" SIZEOF___INT32)
  if("${SIZEOF_INT}" STREQUAL "4")
    set(SAINT32_TYPE "int")
    set(SAINT32_PRId "\"d\"")
  elseif("${SIZEOF_LONG}" STREQUAL "4")
    set(SAINT32_TYPE "long")
    set(SAINT32_PRId "\"ld\"")
  elseif("${SIZEOF_SHORT}" STREQUAL "4")
    set(SAINT32_TYPE "short")
    set(SAINT32_PRId "\"d\"")
  elseif("${SIZEOF___INT32}" STREQUAL "4")
    set(SAINT32_TYPE "__int32")
    set(SAINT32_PRId "\"d\"")
  else("${SIZEOF_INT}" STREQUAL "4")
    message(FATAL_ERROR "Cannot find 32-bit integer type")
  endif("${SIZEOF_INT}" STREQUAL "4")
endif(HAVE_INT32_T)
# saint64_t (64bit)
if(BUILD_DIVSUFSORT64)
  check_type_size("int64_t" INT64_T)
  if(HAVE_INT64_T)
    set(SAINT64_TYPE "int64_t")
    check_symbol_exists("PRId64" "inttypes.h" HAVE_PRID64)
    if(HAVE_PRID64)
      set(SAINT64_PRId "PRId64")
    else(HAVE_PRID64)
      set(SAINT64_PRId "\"lld\"")
    endif(HAVE_PRID64)
  else(HAVE_INT64_T)
    check_type_size("int" SIZEOF_INT)
    check_type_size("long" SIZEOF_LONG)
    check_type_size("long long" SIZEOF_LONG_LONG)
    check_type_size("__int64" SIZEOF___INT64)
    if("${SIZEOF_INT}" STREQUAL "8")
      set(SAINT64_TYPE "int")
      set(SAINT64_PRId "\"d\"")
    elseif("${SIZEOF_LONG}" STREQUAL "8")
      set(SAINT64_TYPE "long")
      set(SAINT64_PRId "\"ld\"")
    elseif("${SIZEOF_LONG_LONG}" STREQUAL "8")
      set(SAINT64_TYPE "long long")
      set(SAINT64_PRId "\"lld\"")
    elseif("${SIZEOF___INT64}" STREQUAL "8")
      set(SAINT64_TYPE "__int64")
      set(SAINT64_PRId "\"I64d\"")
    else("${SIZEOF_INT}" STREQUAL "8")
      message(SEND_ERROR "Cannot find 64-bit integer type")
      set(BUILD_DIVSUFSORT64 OFF)
    endif("${SIZEOF_INT}" STREQUAL "8")
  endif(HAVE_INT64_T)
endif(BUILD_DIVSUFSORT64)

## generate divsufsort.h ##
set(DIVSUFSORT_IMPORT "")
set(DIVSUFSORT_EXPORT "")
if(BUILD_SHARED_LIBS)
  if(HAVE___DECLSPEC_DLLIMPORT_)
    set(DIVSUFSORT_IMPORT "__declspec(dllimport)")
  endif(HAVE___DECLSPEC_DLLIMPORT_)
  if(HAVE___DECLSPEC_DLLEXPORT_)
    set(DIVSUFSORT_EXPORT "__declspec(dllexport)")
  endif(HAVE___DECLSPEC_DLLEXPORT_)
endif(BUILD_SHARED_LIBS)
set(W64BIT "")
set(SAINDEX_TYPE "${SAINT32_TYPE}")
set(SAINDEX_PRId "${SAINT32_PRId}")
set(SAINT_PRId "${SAINT32_PRId}")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/divsufsort.h.cmake"
               "${CMAKE_CURRENT_BINARY_DIR}/divsufsort.h" @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/divsufsort.h" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
if(BUILD_DIVSUFSORT64)
  set(W64BIT "64")
  set(SAINDEX_TYPE "${SAINT64_TYPE}")
  set(SAINDEX_PRId "${SAINT64_PRId}")
  configure_file("${CMAKE_CURRENT_SOURCE_DIR}/divsufsort.h.cmake"
                 "${CMAKE_CURRENT_BINARY_DIR}/divsufsort64.h" @ONLY)
  install(FILES "${CMAKE_CURRENT_BINARY_DIR}/divsufsort64.h" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
endif(BUILD_DIVSUFSORT64)