summaryrefslogtreecommitdiff
path: root/cmake/config/eina.cmake
blob: 40913614d90a4304a35c8f48bef6233740995ca6 (plain) (blame)
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
pkg_check_modules(VALGRIND valgrind)

# set default option values based on BUILD_PROFILE
set(EINA_DEBUG_THREADS OFF)
set(ENABLE_VALGRIND OFF)
if("${BUILD_PROFILE}" STREQUAL "dev")
  set(ENABLE_VALGRIND ${VALGRIND_FOUND})
elseif("${BUILD_PROFILE}" STREQUAL "debug")
  set(EINA_DEBUG_THREADS ON)
  set(ENABLE_VALGRIND ${VALGRIND_FOUND})
elseif("${BUILD_PROFILE}" STREQUAL "release")
endif()

EFL_OPTION(EINA_MAGIC_DEBUG "magic debug of eina structure" ON)
EFL_OPTION(EINA_DEBUG_THREADS "debugging of eina threads" ${EINA_DEBUG_THREADS})
EFL_OPTION(ENABLE_VALGRIND "valgrind support" ${ENABLE_VALGRIND})

set(EINA_MODULE_TYPE_MP_CHAINED_POOL_DEFAULT "STATIC")
set(EINA_MODULE_TYPE_MP_ONE_BIG_DEFAULT "STATIC")
set(EINA_MODULE_TYPE_MP_PASS_THROUGH_DEFAULT "STATIC")

# no CHECK_INIT() yet, all CHECK_APPEND_DEFINE(), FUNC_CHECK(),
# HEADER_CHECK() and TYPE_CHECK() goes to src/lib/efl/config_gen.h

if(ENABLE_VALGRIND)
  if(NOT VALGRIND_FOUND)
    message(FATAL_ERROR "Valgrind was required but not found!")
  endif()
  CHECK_APPEND_DEFINE(NVALGRIND "")
else()
  CHECK_APPEND_DEFINE(NVALGRIND 1)
endif()


# we want the following checks inside src/lib/eina/eina_config.h to be
# generated from cmake/post/eina.cmake.
#
# By default all symbols are prefixed with EINA_
CHECK_INIT(eina)

if("${BUILD_PROFILE}" STREQUAL "dev")
elseif("${BUILD_PROFILE}" STREQUAL "debug")
  set(EINA_STRINGSHARE_USAGE ON)
  set(EINA_DEBUG_MALLOC ON)
  set(EINA_COW_MAGIC_ON ON)
  set(EINA_DEFAULT_MEMPOOL ON)
  set(EINA_DEBUG_MALLOC ON)
elseif("${BUILD_PROFILE}" STREQUAL "release")
  set(EINA_LOG_LEVEL_MAXIMUM 3)
endif()

CHECK_APPEND_DEFINE(EINA_MAGIC_DEBUG ${EINA_MAGIC_DEBUG})
CHECK_APPEND_DEFINE(EINA_SAFETY_CHECKS 1)
CHECK_APPEND_DEFINE(EINA_DEBUG_THREADS "${EINA_DEBUG_THREADS}")
CHECK_APPEND_DEFINE(EINA_STRINGSHARE_USAGE "${EINA_STRINGSHARE_USAGE}")
CHECK_APPEND_DEFINE(EINA_DEBUG_MALLOC "${EINA_DEBUG_MALLOC}")
CHECK_APPEND_DEFINE(EINA_COW_MAGIC_ON "${EINA_COW_MAGIC_ON}")
CHECK_APPEND_DEFINE(EINA_DEFAULT_MEMPOOL "${EINA_DEFAULT_MEMPOOL}")
CHECK_APPEND_DEFINE(EINA_DEBUG_MALLOC "${EINA_DEBUG_MALLOC}")
CHECK_APPEND_DEFINE(EINA_LOG_LEVEL_MAXIMUM "${EINA_LOG_LEVEL_MAXIMUM}")
CHECK_APPEND_DEFINE(EINA_HAVE_THREADS "${EFL_HAVE_THREADS}")

#check for symbols in pthread
#TODO Make the definitions depending on the platform
FUNC_CHECK(pthread_barrier_init NAME EINA_HAVE_PTHREAD_BARRIER INCLUDE_FILES pthread.h FLAGS ${CMAKE_THREAD_LIBS_INIT} DEFINITIONS "-D_GNU_SOURCE=1")
FUNC_CHECK(pthread_attr_setaffinity_np NAME EINA_HAVE_PTHREAD_AFFINITY INCLUDE_FILES pthread.h FLAGS ${CMAKE_THREAD_LIBS_INIT} DEFINITIONS "-D_GNU_SOURCE=1")
FUNC_CHECK(pthread_setname_np NAME EINA_HAVE_PTHREAD_SETNAME INCLUDE_FILES pthread.h FLAGS ${CMAKE_THREAD_LIBS_INIT} DEFINITIONS "-D_GNU_SOURCE=1")
FUNC_CHECK(pthread_spin_init NAME EINA_HAVE_POSIX_SPINLOCK INCLUDE_FILES pthread.h FLAGS ${CMAKE_THREAD_LIBS_INIT} DEFINITIONS "-D_GNU_SOURCE=1")

#check for eina header files that are required
HEADER_CHECK(alloca.h)
HEADER_CHECK(byteswap.h)
HEADER_CHECK(fnmatch.h)
#only enable log when fnmatch is there
CHECK_APPEND_DEFINE(EINA_ENABLE_LOG ${EINA_HAVE_FNMATCH_H})
HEADER_CHECK(dirent.h)

TYPE_CHECK(wchar_t)
TYPE_CHECK(uintptr_t)
TYPE_CHECK(wchar_t)

# TODO: fix define name to not need a name!
#check for swap16/32/64
FUNC_CHECK(bswap_16 NAME EINA_HAVE_BSWAP16 INCLUDE_FILES byteswap.h)
FUNC_CHECK(bswap_32 NAME EINA_HAVE_BSWAP32 INCLUDE_FILES byteswap.h)
FUNC_CHECK(bswap_64 NAME EINA_HAVE_BSWAP64 INCLUDE_FILES byteswap.h)

#Check if there is the alloca header