forked from manojgudi/Theron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TheronSetup.cmake
156 lines (130 loc) · 5.47 KB
/
TheronSetup.cmake
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
########################################################################
# Include this file to get a list of include paths and definitions
# Input: THERON_SOURCE_DIR
# Output: THERON_INCLUDE_DIRS
# Output: THERON_LIBRARY_DIRS
# Output: THERON_LIBRARIES
# Output: THERON_DEFINES
# Output: THERON_SOURCES
########################################################################
list(APPEND CMAKE_MODULE_PATH ${THERON_SOURCE_DIR})
########################################################################
# Setup the list of sources
########################################################################
file(GLOB THERON_SOURCES "${THERON_SOURCE_DIR}/Theron/*.cpp")
########################################################################
# Detect the system defines
########################################################################
if(WIN32)
list(APPEND THERON_DEFINES -DTHERON_WINDOWS=1)
endif()
if(MSVC)
list(APPEND THERON_DEFINES -DTHERON_MSVC=1)
endif()
if(CMAKE_COMPILER_IS_GNUCXX)
list(APPEND THERON_DEFINES -DTHERON_GCC=1)
endif()
include(CheckTypeSize)
enable_language(C)
check_type_size("void*[8]" SIZEOF_CPU BUILTIN_TYPES_ONLY)
if(${SIZEOF_CPU} EQUAL 64)
list(APPEND THERON_DEFINES -DTHERON_64BIT=1)
endif()
if(CMAKE_COMPILER_IS_GNUCXX AND ${SIZEOF_CPU} EQUAL 64)
list(APPEND THERON_DEFINES -fPIC)
endif()
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
list(APPEND THERON_DEFINES -DTHERON_DEBUG=1)
endif()
########################################################################
# Setup the include directories
########################################################################
list(APPEND THERON_INCLUDE_DIRS ${THERON_SOURCE_DIR}/Include)
list(APPEND THERON_INCLUDE_DIRS ${THERON_SOURCE_DIR}/Include/External)
if(MSVC)
list(APPEND THERON_INCLUDE_DIRS ${THERON_SOURCE_DIR}/Include/Standard)
endif(MSVC)
########################################################################
# Find and setup Boost Threads
########################################################################
if(UNIX AND NOT BOOST_ROOT AND EXISTS "/usr/lib64" AND NOT BOOST_LIBRARYDIR)
list(APPEND BOOST_LIBRARYDIR "/usr/lib64") #fedora 64-bit fix
endif(UNIX AND NOT BOOST_ROOT AND EXISTS "/usr/lib64" AND NOT BOOST_LIBRARYDIR)
set(Boost_ADDITIONAL_VERSIONS
"1.35.0" "1.35" "1.36.0" "1.36" "1.37.0" "1.37" "1.38.0" "1.38" "1.39.0" "1.39"
"1.40.0" "1.40" "1.41.0" "1.41" "1.42.0" "1.42" "1.43.0" "1.43" "1.44.0" "1.44"
"1.45.0" "1.45" "1.46.0" "1.46" "1.47.0" "1.47" "1.48.0" "1.48" "1.49.0" "1.49"
"1.50.0" "1.50" "1.51.0" "1.51" "1.52.0" "1.52" "1.53.0" "1.53" "1.54.0" "1.54"
"1.55.0" "1.55" "1.56.0" "1.56" "1.57.0" "1.57" "1.58.0" "1.58" "1.59.0" "1.59"
"1.60.0" "1.60" "1.61.0" "1.61" "1.62.0" "1.62" "1.63.0" "1.63" "1.64.0" "1.64"
"1.65.0" "1.65" "1.66.0" "1.66" "1.67.0" "1.67" "1.68.0" "1.68" "1.69.0" "1.69"
)
find_package(Boost COMPONENTS thread system)
if(Boost_FOUND)
list(APPEND THERON_INCLUDE_DIRS ${Boost_INCLUDE_DIRS})
list(APPEND THERON_LIBRARY_DIRS ${Boost_LIBRARY_DIRS})
list(APPEND THERON_LIBRARIES ${Boost_LIBRARIES})
list(APPEND THERON_DEFINES -DTHERON_BOOST=1)
if(${Boost_VERSION} LESS 104200)
list(APPEND THERON_DEFINES "-Dmemory_order_consume=memory_order(8)")
endif()
endif()
########################################################################
# Find and setup PThreads
########################################################################
find_package(Pthreads)
if(PTHREADS_FOUND)
list(APPEND THERON_INCLUDE_DIRS ${PTHREADS_INCLUDE_DIR})
list(APPEND THERON_LIBRARIES ${PTHREADS_LIBRARY})
list(APPEND THERON_DEFINES -DTHERON_POSIX=1)
list(APPEND THERON_DEFINES -DHAVE_PTHREAD_H)
endif()
########################################################################
# Find and setup c++11
########################################################################
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG(-std=c++11 HAS_STD_CPP11)
if(HAS_STD_CPP11)
list(APPEND THERON_DEFINES -DTHERON_CPP11=1)
list(APPEND THERON_DEFINES -std=c++11)
endif()
########################################################################
# Extra linux specific libraries
########################################################################
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
find_library(
NUMA_LIBRARIES
NAMES numa
PATHS /usr/lib /usr/lib64
)
if(NUMA_LIBRARIES)
list(APPEND THERON_LIBRARIES ${NUMA_LIBRARIES})
list(APPEND THERON_DEFINES -DTHERON_NUMA=1)
endif()
find_library(
RT_LIBRARIES
NAMES rt
PATHS /usr/lib /usr/lib64
)
if(RT_LIBRARIES)
list(APPEND THERON_LIBRARIES ${RT_LIBRARIES})
else()
message(FATAL_ERROR "librt required to build Theron")
endif()
endif()
########################################################################
# Setup Crossroads IO (optional)
########################################################################
find_package(XS)
if(XS_FOUND)
list(APPEND THERON_LIBRARY_DIRS ${XS_INCLUDE_DIR})
list(APPEND THERON_LIBRARIES ${XS_LIBRARIES})
list(APPEND THERON_DEFINES -DTHERON_XS=1)
endif()
########################################################################
# Print results
########################################################################
message(STATUS "THERON_INCLUDE_DIRS: ${THERON_INCLUDE_DIRS}")
message(STATUS "THERON_LIBRARY_DIRS: ${THERON_LIBRARY_DIRS}")
message(STATUS "THERON_LIBRARIES: ${THERON_LIBRARIES}")
message(STATUS "THERON_DEFINES: ${THERON_DEFINES}")