forked from karmaresearch/vlog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
275 lines (244 loc) · 11.3 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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
cmake_minimum_required (VERSION 2.8)
set(CMAKE_C_COMPILER "gcc")
set(CMAKE_CXX_COMPILER "g++")
if (NOT "$ENV{CC}" STREQUAL "")
set(CMAKE_C_COMPILER "$ENV{CC}")
endif()
if (NOT "$ENV{CXX}" STREQUAL "")
set(CMAKE_CXX_COMPILER "$ENV{CXX}")
endif()
project (vlog)
include(ExternalProject)
set(CMAKE_MACOSX_RPATH 1)
if (DIST)
set(CMAKE_OSX_ARCHITECTURES arm64 x86_64)
set(ONLY_ACIVE_ARCH NO)
endif()
#Set to release mode if nothing is specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Release' as none was specified.")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release")
endif()
#Add macPorts
# Detect if the "port" command is valid on this system; if so, return full path
EXECUTE_PROCESS(COMMAND which port RESULT_VARIABLE DETECT_MACPORTS OUTPUT_VARIABLE MACPORTS_PREFIX ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
IF (${DETECT_MACPORTS} EQUAL 0)
# "/opt/local/bin/port" doesn't have libs, so we get the parent directory
GET_FILENAME_COMPONENT(MACPORTS_PREFIX ${MACPORTS_PREFIX} DIRECTORY)
# "/opt/local/bin" doesn't have libs, so we get the parent directory
GET_FILENAME_COMPONENT(MACPORTS_PREFIX ${MACPORTS_PREFIX} DIRECTORY)
# "/opt/local" is where MacPorts lives, add `/lib` suffix and link
LINK_DIRECTORIES(${MACPORTS_PREFIX}/lib)
INCLUDE_DIRECTORIES(${MACPORTS_PREFIX}/include)
ENDIF()
#Add homebrew
EXECUTE_PROCESS(COMMAND brew --prefix RESULT_VARIABLE exitstatus OUTPUT_VARIABLE BREW_PREFIX ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
IF (${exitstatus} EQUAL 0)
LINK_DIRECTORIES(${BREW_PREFIX}/lib)
INCLUDE_DIRECTORIES(${BREW_PREFIX}/include)
ENDIF()
#add files to compile
file(GLOB vlog_SRC
"src/vlog/*.cpp"
"src/vlog/common/*.cpp"
"src/vlog/backward/*.cpp"
"src/vlog/forward/*.cpp"
"src/vlog/magic/*.cpp"
"src/vlog/incremental/*.cpp"
"src/vlog/embeddings/*.cpp"
"src/vlog/inmemory/*.cpp"
"src/vlog/trident/*.cpp"
"src/vlog/cycles/*.cpp"
"src/vlog/ml/*.cpp"
"src/vlog/trigger/*.cpp"
"src/launcher/vloglayer.cpp"
"src/launcher/vlogscan.cpp"
"src/vlog/prediction/*.cpp"
"src/vlog/util/*.cpp"
)
#ZLIB
find_package(ZLIB REQUIRED)
#Trident
IF(TRIDENT_LIB)
message("Using KOGNAC provided installation: ${KOGNAC_LIB} ${KOGNAC_INC}")
include_directories(${KOGNAC_INC})
LINK_DIRECTORIES("${KOGNAC_LIB}")
add_library(kognac-core SHARED IMPORTED)
set_property(TARGET kognac-core PROPERTY IMPORTED_LOCATION ${KOGNAC_LIB}/${CMAKE_SHARED_LIBRARY_PREFIX}kognac-core${CMAKE_SHARED_LIBRARY_SUFFIX})
message("Using Trident provided installation: ${TRIDENT_LIB} ${TRIDENT_INC}")
include_directories(${TRIDENT_INC})
include_directories(${TRIDENT_INC}/layers)
include_directories(${TRIDENT_INC}/../rdf3x/include)
add_library(trident SHARED IMPORTED)
set_property(TARGET trident PROPERTY IMPORTED_LOCATION ${TRIDENT_LIB}/libtrident-core${CMAKE_SHARED_LIBRARY_SUFFIX})
add_library(trident-sparql SHARED IMPORTED)
set_property(TARGET trident-sparql PROPERTY IMPORTED_LOCATION ${TRIDENT_LIB}/libtrident-sparql${CMAKE_SHARED_LIBRARY_SUFFIX})
LINK_DIRECTORIES("${TRIDENT_LIB}/")
ELSE()
ExternalProject_Add(git-trident
DOWNLOAD_COMMAND git clone https://github.com/karmaresearch/trident.git
DOWNLOAD_DIR .
SOURCE_DIR trident
BUILD_IN_SOURCE 1
IF (DIST)
CMAKE_ARGS "-DDIST=1" "-DSPARQL=1" "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
ELSE()
CMAKE_ARGS "-DSPARQL=1" "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}"
ENDIF()
INSTALL_COMMAND ""
)
ExternalProject_Get_Property(git-trident SOURCE_DIR)
include_directories(${SOURCE_DIR}/include)
include_directories(${SOURCE_DIR}/include/layers)
include_directories(${SOURCE_DIR}/rdf3x/include)
# TRIDENT
add_library(trident SHARED IMPORTED)
add_dependencies(trident git-trident)
set_property(TARGET trident PROPERTY IMPORTED_LOCATION "${CMAKE_BINARY_DIR}/trident/libtrident-core${CMAKE_SHARED_LIBRARY_SUFFIX}")
LINK_DIRECTORIES("${CMAKE_BINARY_DIR}/trident/")
# TRIDENT SPARQL
add_library(trident-sparql SHARED IMPORTED)
add_dependencies(trident-sparql git-trident)
set_property(TARGET trident-sparql PROPERTY IMPORTED_LOCATION "${CMAKE_BINARY_DIR}/trident/libtrident-sparql${CMAKE_SHARED_LIBRARY_SUFFIX}")
# KOGNAC
set(KOGNAC_LIB ${CMAKE_BINARY_DIR}/trident/kognac)
add_library(kognac-core SHARED IMPORTED)
add_dependencies(kognac-core git-trident)
include_directories(${SOURCE_DIR}/kognac/include)
LINK_DIRECTORIES("${KOGNAC_LIB}")
set_property(TARGET kognac-core PROPERTY IMPORTED_LOCATION ${KOGNAC_LIB}/${CMAKE_SHARED_LIBRARY_PREFIX}kognac-core${CMAKE_SHARED_LIBRARY_SUFFIX})
ENDIF()
#SPARSEHASH
find_path(sparsehash sparsehash/sparse_hash_map)
IF (${sparsehash} STREQUAL "sparsehash-NOTFOUND")
message("Could not find sparsehash. I'm going to use the version from kognac ...")
include_directories(${KOGNAC_LIB}/external/sparsehash/src/)
ENDIF()
#LZ4
# find_library(lz4 lz4)
# find_path(lz4h lz4.h)
# IF (${lz4h} STREQUAL "lz4h-NOTFOUND")
# message("Could not find LZ4. I'm going to use the version from kognac")
message("I'm going to use LZ4 the version from kognac")
include_directories(${KOGNAC_LIB}/external/lz4/lib/)
LINK_DIRECTORIES(${KOGNAC_LIB}/external/lz4/lib)
add_library(lz4 STATIC IMPORTED)
set_property(TARGET lz4 PROPERTY IMPORTED_LOCATION ${KOGNAC_LIB}/external/lz4/lib/${CMAKE_STATIC_LIBRARY_PREFIX}lz4${CMAKE_STATIC_LIBRARY_SUFFIX})
# ELSE()
# include_directories(lz4h)
# message("-- Found LZ4")
# ENDIF()
IF (JAVA)
find_package(Java REQUIRED)
include(UseJava)
find_package(JNI REQUIRED)
include_directories(${JNI_INCLUDE_DIRS})
ENDIF()
#Webserver support
IF(WEBINTERFACE)
file(GLOB vlog_webSRC "src/vlog/web/*.cpp")
set(vlog_SRC ${vlog_webSRC} ${vlog_SRC})
set(COMPILE_FLAGS "${COMPILE_FLAGS} -DWEBINTERFACE=1")
ENDIF()
IF(MYSQL)
file(GLOB vlog_mysqlSRC "src/vlog/mysql/*.cpp")
set(vlog_SRC ${vlog_mysqlSRC} ${vlog_SRC})
set(COMPILE_FLAGS "${COMPILE_FLAGS} -DMYSQL=1")
link_libraries("-lmysqlcppconn")
ENDIF()
IF(ODBC)
file(GLOB vlog_odbcSRC "src/vlog/odbc/*.cpp")
set(vlog_SRC ${vlog_odbcSRC} ${vlog_SRC})
set(COMPILE_FLAGS "${COMPILE_FLAGS} -DODBC=1")
link_libraries("-lodbc")
ENDIF()
IF(MAPI)
file(GLOB vlog_mapiSRC "src/vlog/mapi/*.cpp")
set(vlog_SRC ${vlog_mapiSRC} ${vlog_SRC})
set(COMPILE_FLAGS "${COMPILE_FLAGS} -DMAPI=1")
link_libraries("-lmapi")
ENDIF()
IF(SPARQL)
find_package(CURL REQUIRED)
include_directories(${CURL_INCLUDE_DIR})
file(GLOB vlog_sparqlSRC "src/vlog/sparql/*.cpp")
set(vlog_SRC ${vlog_sparqlSRC} ${vlog_SRC})
set(COMPILE_FLAGS "${COMPILE_FLAGS} -DSPARQL=1")
ENDIF()
IF(MDLITE)
file(GLOB vlog_mdliteSRC "src/vlog/mdlite/*.cpp")
set(vlog_SRC ${vlog_mdliteSRC} ${vlog_SRC})
set(COMPILE_FLAGS "${COMPILE_FLAGS} -DMDLITE=1")
link_libraries("-lmonetdb5")
ENDIF()
IF(ELASTIC)
file(GLOB vlog_elasticSRC "src/vlog/text/elastictable.cpp")
set(vlog_SRC ${vlog_elasticSRC} ${vlog_SRC})
set(COMPILE_FLAGS "${COMPILE_FLAGS} -DELASTIC=1")
ENDIF()
IF(JAVA)
file(GLOB vlog_javaSRC "src/vlog/java/native/*.cpp")
add_library(vlog-java SHARED ${vlog_javaSRC})
ENDIF()
#Create both a library and the executable program
add_library(vlog-core SHARED ${vlog_SRC})
add_executable(vlog src/launcher/main.cpp)
IF(SPARQL)
target_link_libraries(vlog-core ${CURL_LIBRARIES})
ENDIF()
#PTHREADS
find_package(Threads REQUIRED)
if (THREADS_HAVE_PTHREAD_ARG)
target_compile_options(PUBLIC vlog-core "-pthread")
endif()
if (CMAKE_THREAD_LIBS_INIT)
target_link_libraries(vlog-core "${CMAKE_THREAD_LIBS_INIT}")
endif()
#Set compiler options
# set(CLANG_ONLY_COMPILE_FLAGS "-Wimplicit-int-conversion")
# set(GNUCXX_ONLY_COMPILE_FLAGS "-Wconversion")
if((${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang") OR (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU"))
set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -O3")
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -DDEBUG")
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
set(COMPILE_FLAGS "${COMPILE_FLAGS} -c -fPIC -MD -std=c++11 -DUSE_COMPRESSED_COLUMNS -DPRUNING_QSQR=1 ${CLANG_ONLY_COMPILE_FLAGS}")
if(LINUX)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lstdc++")
endif()
else()
set(COMPILE_FLAGS "${COMPILE_FLAGS} -c -fPIC -MD -std=c++11 -DUSE_COMPRESSED_COLUMNS -DPRUNING_QSQR=1 ${GNUCXX_ONLY_COMPILE_FLAGS}")
endif()
endif()
IF (JAVA)
set(COMPILE_FLAGS "${COMPILE_FLAGS} -fPIC")
ENDIF()
set_target_properties(vlog-core PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS}")
IF(JAVA)
set_target_properties(vlog-java PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS}")
ENDIF()
set_target_properties(vlog PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS}" OUTPUT_NAME "vlog")
#standard include
include_directories(include/)
TARGET_LINK_LIBRARIES(vlog-core trident trident-sparql ${ZLIB_LIBRARIES} kognac-core lz4)
if(JAVA)
file(GLOB javaSRC "src/vlog/java/karmaresearch/vlog/*.java")
Create_javadoc(vlog PACKAGES karmaresearch.vlog SOURCEPATH ${CMAKE_CURRENT_SOURCE_DIR}/src/vlog/java WINDOWTITLE "VLog JNI Interface")
# add_dependencies(vlog-java headers)
TARGET_LINK_LIBRARIES(vlog-java vlog-core trident trident-sparql kognac-core)
#Terrible hack to make cmake actually find the shared library when adding it to the jar.
#It won't find it in the binary directory ... so we copy it to the source directory, add it to the jar, and then remove it from the source directory
add_custom_command(TARGET vlog-java COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_SOURCE_DIR}/resources)
add_custom_command(TARGET vlog-java COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:vlog-java> ${CMAKE_SOURCE_DIR}/resources)
add_custom_command(TARGET vlog-java COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:vlog-core> ${CMAKE_SOURCE_DIR}/resources)
add_custom_command(TARGET vlog-java COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:trident> ${CMAKE_SOURCE_DIR}/resources)
add_custom_command(TARGET vlog-java COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:trident-sparql> ${CMAKE_SOURCE_DIR}/resources)
add_custom_command(TARGET vlog-java COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:kognac-core> ${CMAKE_SOURCE_DIR}/resources)
set(CMAKE_JAVA_COMPILE_FLAGS -target 8 -source 8)
add_jar(jvlog ${javaSRC} resources/${CMAKE_SHARED_LIBRARY_PREFIX}vlog-java${CMAKE_SHARED_LIBRARY_SUFFIX} resources/${CMAKE_SHARED_LIBRARY_PREFIX}vlog-core${CMAKE_SHARED_LIBRARY_SUFFIX} resources/${CMAKE_SHARED_LIBRARY_PREFIX}trident-core${CMAKE_SHARED_LIBRARY_SUFFIX} resources/${CMAKE_SHARED_LIBRARY_PREFIX}trident-sparql${CMAKE_SHARED_LIBRARY_SUFFIX} resources/${CMAKE_SHARED_LIBRARY_PREFIX}kognac-core${CMAKE_SHARED_LIBRARY_SUFFIX} GENERATE_NATIVE_HEADERS headers DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/src/vlog/java/native/)
add_custom_command(TARGET jvlog POST_BUILD COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_SOURCE_DIR}/resources)
add_custom_command(TARGET jvlog POST_BUILD COMMAND ${CMAKE_COMMAND} -E remove $<TARGET_FILE:vlog-java>)
add_dependencies(jvlog vlog-java)
ENDIF()
TARGET_LINK_LIBRARIES(vlog vlog-core)