forked from eyalroz/ssb-dbgen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
179 lines (147 loc) · 5.86 KB
/
CMakeLists.txt
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
cmake_minimum_required(VERSION 3.0)
cmake_policy(SET CMP0054 NEW) # Don't try to interpret "FOO" as a variable
include(CheckIncludeFiles)
include(CheckTypeSize)
include(CheckSymbolExists)
include(CheckFunctionExists)
project(ssb-dbgen # SSB benchmark data (and query) generator utilities
LANGUAGES C)
if (NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
endif()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
set(DATABASE "DB2" CACHE STRING "Command language dialect to target with the qgen query generator (\"DATABASE\"")
set_property(CACHE DATABASE PROPERTY STRINGS INFORMIX DB2 TDAT SQLSERVER SYBASE)
set(WORKLOAD SSB CACHE STRING "Choice of benchmark / query workload (\"WORKLOAD\")")
set_property(CACHE WORKLOAD PROPERTY STRINGS TPCH SSB)
set(CSV_OUTPUT_FORMAT OFF CACHE BOOL "Use CSV output format")
set(EOL_HANDLING OFF CACHE BOOL "Skip separator after the last field in generated lines?")
set(YMD_DASH_DATE OFF CACHE BOOL "Generate date values in YYYY-MM-DD format (with dashes) rather than YYYYMMDD")
if (CSV_OUTPUT_FORMAT AND NOT EOL_HANDLING)
message(WARNING "When CSV is used for the output format, EOL_HANDLING is ignored and a separator is _never_ printed after the last field on the line (the equivalent of EOL_HANDLING being ON).")
endif()
check_type_size("long long" SIZEOF_LONG_LONG)
check_type_size("long" SIZEOF_LONG)
check_type_size("int" SIZEOF_INT)
check_type_size("short" SIZEOF_SHORT)
# Header checks...
# ... for POSIX systems
check_include_file(unistd.h HAVE_UNISTD_H)
check_include_file(fcntl.h HAVE_FCNTL_H)
check_include_file(sys/wait.h HAVE_SYS_WAIT_H)
check_include_file(sys/types.h HAVE_SYS_TYPES_H)
check_include_file(sys/stat.h HAVE_SYS_STAT_H)
check_include_file(strings.h HAVE_STRINGS_H)
check_include_file(inttypes.h HAVE_INTTYPES_H)
# ... for Windows
check_include_file(getopt.h HAVE_GETOPT_H)
check_include_file(process.h HAVE_PROCESS_H)
check_include_file(windows.h HAVE_WINDOWS_H)
# ... non-platform-specific
check_include_file(stdint.h HAVE_STDINT_H) # standard since C99
check_include_file(sys/bittypes.h HAVE_SYS_BITTYPES_H)
check_symbol_exists(malloc stdlib.h HAVE_MALLOC_IN_STDLIB)
if (NOT HAVE_MALLOC_IN_STDLIB)
check_include_file(malloc.h HAVE_MALLOC_H)
if (NOT HAVE_MALLOC_H)
message(FATAL_ERROR "Could not locate a definition of the malloc() function")
endif()
endif()
if (NOT HAVE_UNISTD_H AND HAVE_SYS_TYPES_H)
check_symbol_exists(pid_t sys/types.h HAVE_PID_T_IN_SYS_TYPES_H)
endif()
check_symbol_exists(getopt stdlib.h STDLIB_HAS_GETOPT)
check_symbol_exists(getenv stdlib.h STDLIB_HAS_GETENV)
if (NOT STDLIB_HAS_GETENV)
message(FATAL_ERROR "getenv is required but not found")
endif()
#check_function_exists(getpid HAVE_GETPID)
#if (NOT HAVE_GETPID)
# check_function_exists(_getpid HAVE__GETPID)
#endif()
# Functions necessary for parallel data generation...
# ... with POSIX
check_function_exists(kill HAVE_KILL)
check_function_exists(fork HAVE_FORK)
check_function_exists(wait HAVE_WAIT)
# ... on Windows (currently disabled, see the code)
#check_function_exists(TerminateProcess HAVE_TERMINATE_PROCESS)
#check_function_exists(spawnv HAVE_SPAWNV)
#if (NOT HAVE_SPAWNV)
# check_function_exists(_spawnv HAVE__SPAWNV)
#endif()
#check_function_exists(cwait HAVE_CWAIT)
#if (NOT HAVE_CWAIT)
# check_function_exists(_cwait HAVE__CWAIT)
#endif()
configure_file(src/config.h.in src/config.h @ONLY)
# The following is necessary since the generated config.h will be placed
# in the build directory ("binary" directory), not in the source directory
include_directories("${CMAKE_CURRENT_BINARY_DIR}/src")
add_executable(dbgen
src/bcd2.c
src/bm_utils.c
src/build.c
src/driver.c
src/load_stub.c
src/permute.c
src/print.c
src/rnd.c
src/speed_seed.c
src/text.c
)
add_executable(qgen
src/bcd2.c
src/bm_utils.c
src/build.c
src/permute.c
src/qgen.c
src/rnd.c
src/speed_seed.c
src/text.c
src/varsub.c
)
if (NOT LOG_FUNCTION_EXISTS AND NOT NEED_LINKING_AGAINST_LIBM)
# Decide whether or not to link against the C math library (libm);
# See: https://stackoverflow.com/q/32816646/1593077
CHECK_FUNCTION_EXISTS(log LOG_FUNCTION_EXISTS)
if(NOT LOG_FUNCTION_EXISTS)
unset(LOG_FUNCTION_EXISTS CACHE)
list(APPEND CMAKE_REQUIRED_LIBRARIES m)
CHECK_FUNCTION_EXISTS(log LOG_FUNCTION_EXISTS)
if(LOG_FUNCTION_EXISTS)
unset(LOG_FUNCTION_EXISTS CACHE)
set(NEED_LINKING_AGAINST_LIBM True CACHE BOOL "" FORCE)
message(STATUS "Need linking against the C math library")
else()
message(FATAL_ERROR "Cannot determine how to make the C standard library math functions available")
endif()
else()
endif()
endif()
if (NEED_LINKING_AGAINST_LIBM)
target_link_libraries(dbgen m)
target_link_libraries(qgen m)
endif()
set_property(
TARGET dbgen qgen
APPEND PROPERTY COMPILE_DEFINITIONS
DBNAME="dss"
${DATABASE}
${WORKLOAD}
_FILE_OFFSET_BITS=64
)
set_property(TARGET dbgen qgen PROPERTY C_STANDARD 99)
set_property(TARGET dbgen qgen PROPERTY C_EXTENSIONS OFF)
# Note: Defining _POSIX_C_SOURCE=200809L allows the code access to functions defined in the POSIX standard,
# but not in the C language standard - and such functions _are_ in use in the code.
if ("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
set_property(TARGET dbgen qgen APPEND PROPERTY COMPILE_OPTIONS -Wall -Wextra -Wno-missing-field-initializers)
set_property(TARGET dbgen qgen APPEND PROPERTY COMPILE_DEFINITIONS _POSIX_C_SOURCE=200809L)
elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
set_property(TARGET dbgen qgen APPEND PROPERTY COMPILE_OPTIONS -Wall -Wextra -Wno-missing-field-initializers)
set_property(TARGET dbgen qgen APPEND PROPERTY COMPILE_DEFINITIONS _POSIX_C_SOURCE=200809L)
elseif ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
set_property(TARGET dbgen qgen APPEND PROPERTY COMPILE_OPTIONS "/W3")
set_property(TARGET dbgen qgen APPEND PROPERTY COMPILE_DEFINITIONS _CRT_NONSTDC_NO_DEPRECATE _CRT_SECURE_NO_WARNINGS)
endif()