-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
78 lines (62 loc) · 3.21 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
cmake_minimum_required( VERSION 2.8 )
project (InDiProvCMake)
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -fPIC" )
set ( LIBODB_INCLUDE_PATH "" CACHE PATH "The odb main include path" )
set ( LIBODBDB_INCLUDE_PATH "" CACHE PATH "The odb db implementation include path" )
set ( LIBODB_LIBRARY "" CACHE FILEPATH "The odb library to link against" )
set ( LIBODBDB_LIBRARY "" CACHE FILEPATH "The odb db library to link against" )
set ( DB_USER "root" CACHE STRING "DB user name")
set ( DB_PASS "password" CACHE STRING "DB password")
set ( DB_SCHEMA "provenance" CACHE STRING "DB schema name")
set ( PISTACHE_INCLUDE_PATH "" CACHE PATH "Pistache REST Server include path" )
set ( PISTACHE_LIBRARY "" CACHE FILEPATH "Pistache libnet library" )
find_package( Threads REQUIRED )
set ( MODEL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/Model CACHE INTERNAL "model directory")
file(GLOB models
"${MODEL_DIR}/vertex.hxx"
"${MODEL_DIR}/edge.hxx"
)
message("Starting odb compiler...")
foreach(model ${models})
message(" compiling ${model}")
execute_process(COMMAND odb -d mysql --generate-query --generate-schema --fkeys-deferrable-mode not_deferrable ${model} WORKING_DIRECTORY ${MODEL_DIR} OUTPUT_VARIABLE output)
string(REPLACE .hxx -odb.hxx compilation ${model})
if(EXISTS ${compilation})
message(" Successful.")
else()
message(FATAL_ERROR "odb compilation failed. Please check whether the odb compiler is included in your path.")
endif()
endforeach()
message("odb compilation finished.")
message("")
message("Starting mysql setup...")
message(" Creating database...")
execute_process(COMMAND mysql --user=${DB_USER} --password=${DB_PASS} -e "DROP DATABASE ${DB_SCHEMA}" OUTPUT_VARIABLE output)
execute_process(COMMAND mysql --user=${DB_USER} --password=${DB_PASS} -e "CREATE DATABASE ${DB_SCHEMA}" OUTPUT_VARIABLE output)
message(" Creating elementary tables...")
message(" mysql --user=${DB_USER} --password=${DB_PASS} --database=${DB_SCHEMA} < ${MODEL_DIR}/vertex.sql")
execute_process(COMMAND "mysql" "--user=${DB_USER}" "--password=${DB_PASS}" "--database=${DB_SCHEMA}" INPUT_FILE "${MODEL_DIR}/vertex.sql" OUTPUT_VARIABLE output)
message(" Creating cross tables...")
message(" mysql --user=${DB_USER} --password=${DB_PASS} --database=${DB_SCHEMA} < ${MODEL_DIR}/edge.sql")
execute_process(COMMAND "mysql" "--user=${DB_USER}" "--password=${DB_PASS}" "--database=${DB_SCHEMA}" INPUT_FILE "${MODEL_DIR}/edge.sql" OUTPUT_VARIABLE output)
message("mysql db setup complete.")
message("")
file(GLOB source
"src/log-service.hxx"
"src/database.cxx"
"src/Model/*.hxx"
"src/Model/*.cxx"
"src/Model/*.ixx"
"src/Controller/*.hxx"
)
include_directories (${LIBODB_INCLUDE_PATH})
include_directories (${LIBODBDB_INCLUDE_PATH})
include_directories (${MODEL_DIR})
include_directories (${PISTACHE_INCLUDE_PATH})
add_executable( server "src/server.cxx" ${source} )
target_link_libraries( server ${CMAKE_THREAD_LIBS_INIT} )
target_link_libraries( server ${LIBODB_LIBRARY} )
target_link_libraries( server ${LIBODBDB_LIBRARY} )
target_link_libraries( server ${PISTACHE_LIBRARY} )
file(WRITE ${CMAKE_BINARY_DIR}/start_default_server "#!/bin/sh\n./server --user ${DB_USER} --password ${DB_PASS} --database ${DB_SCHEMA}")
exec_program("chmod 770 start_default_server")