forked from anse1/sqlsmith
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
96 lines (74 loc) · 2.73 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
cmake_minimum_required(VERSION 3.14)
project(SQLsmith LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
include(FeatureTests)
Option(USE_UPSTREAM_LIBPQXX "Fetch and use libpqxx from Github.")
# define our executable early, so we can set the properties, based on our dependencies
add_executable(sqlsmith)
target_sources(sqlsmith PRIVATE
relmodel.cc schema.cc random.cc prod.cc expr.cc grammar.cc log.cc dump.cc impedance.cc sqlsmith.cc postgres.cc)
target_link_libraries(sqlsmith PostgreSQL::PostgreSQL)
# Workaround for outdated cmake packages on debian
set(PostgreSQL_ADDITIONAL_VERSIONS 11 12 13 14)
find_package(PostgreSQL REQUIRED)
if (NOT USE_UPSTREAM_LIBPQXX)
# If we use the system pqxx library, we have to check for libpq.
# This check is done by the CMakeLists.txt of the libpqxx project otherwise
find_package(PQXX REQUIRED)
if (PQXX_VERSION GREATER 7.0)
set(HAVE_LIBPQXX7 TRUE)
endif (PQXX_VERSION GREATER 7.0)
target_link_libraries(sqlsmith PQXX::PQXX)
else (NOT USE_UPSTREAM_LIBPQXX)
set(SKIP_BUILD_TEST TRUE)
include(FetchContent)
FetchContent_Declare(
libpqxx
GIT_REPOSITORY https://github.com/jtv/libpqxx.git
GIT_TAG 7.6.0
)
FetchContent_MakeAvailable(libpqxx)
FetchContent_GetProperties(libpqxx)
unset(SKIP_BUILD_TEST)
set(HAVE_LIBPQXX7 TRUE)
target_include_directories(sqlsmith PRIVATE ${libpqxx_SOURCE_DIR}/include)
target_link_libraries(sqlsmith pqxx)
endif (NOT USE_UPSTREAM_LIBPQXX)
if(NOT std_regex_ok)
find_package(Boost REQUIRED COMPONENTS regex)
set(REGEX_LIBRARY Boost::regex)
set(HAVE_BOOST TRUE)
set(HAVE_BOOST_REGEX TRUE)
endif(NOT std_regex_ok)
## optional dependencies
# sqlite
find_package(SQLite3)
if (SQLite3_FOUND)
set(HAVE_LIBSQLITE3 TRUE)
target_sources(sqlsmith PRIVATE sqlite.cc)
target_link_libraries(sqlsmith SQLite::SQLite3)
endif ()
# monetdb
find_package(MonetDB)
if (MonetDB_FOUND)
set(HAVE_MONETDB 1)
target_sources(sqlsmith PRIVATE monetdb.cc)
target_link_libraries(sqlsmith MonetDB::mapi)
endif ()
## target configuration
string(TOLOWER ${PROJECT_NAME} PACKAGE)
set(PACKAGE_NAME ${PROJECT_NAME})
configure_file(config_h.cmake.in config.h)
# get our git tag
set(GIT_TAG UNRELEASED)
execute_process(
COMMAND git describe --exclude=debian* --dirty --tags --always
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
OUTPUT_VARIABLE GIT_TAG
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# our gitrev.h
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/gitrev.h "#define GITREV \"${GIT_TAG}\"")
# make sure our target finds gitrev.h and config.h
target_include_directories(sqlsmith PRIVATE ${CMAKE_CURRENT_BINARY_DIR})