forked from ElektraInitiative/libelektra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
66 lines (55 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
find_program (GO_EXECUTABLE "go")
list (FIND REMOVED_PLUGINS "yajl" yajl_index)
if (NOT yajl_index EQUAL -1)
remove_tool (elektrad "yajl plugin not available")
elseif (NOT GO_EXECUTABLE)
remove_tool (elektrad "`go` executable was not found")
else ()
# find installation path
set (install_directory ${TARGET_TOOL_DATA_FOLDER}/elektrad)
# configure and copy files
configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/README.md" "${CMAKE_CURRENT_BINARY_DIR}/README.md")
configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/run.sh" "${CMAKE_CURRENT_BINARY_DIR}/run-elektrad")
configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/build.sh" "${CMAKE_CURRENT_BINARY_DIR}/build-elektrad")
# create temporary elektra.pc file
configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/temp-elektra.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/elektra.pc" @ONLY)
# install files to destination
install (PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/run-elektrad ${CMAKE_CURRENT_BINARY_DIR}/run-elektrad
${CMAKE_CURRENT_BINARY_DIR}/build-elektrad DESTINATION ${TARGET_TOOL_EXEC_FOLDER})
if (BUILD_SHARED)
set (ELEKTRA_LIBS_ELEKTRAD elektra-core elektra-kdb elektra-plugin elektra-ease elektra-meta)
elseif (BUILD_FULL)
set (ELEKTRA_LIBS_ELEKTRAD elektra-full)
elseif (BUILD_STATIC)
set (ELEKTRA_LIBS_ELEKTRAD elektra-static)
endif (BUILD_SHARED)
add_custom_command (
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/elektrad/elektrad"
COMMAND ${CMAKE_COMMAND} ARGS -E env GO111MODULE=on PKG_CONFIG_PATH=${CMAKE_CURRENT_BINARY_DIR} ${GO_EXECUTABLE} build -o
"${CMAKE_CURRENT_BINARY_DIR}/elektrad/elektrad"
COMMAND ${CMAKE_COMMAND} -E create_symlink "${CMAKE_CURRENT_BINARY_DIR}/elektrad/elektrad"
"${CMAKE_BINARY_DIR}/bin/elektrad"
VERBATIM
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/main.go" ${ELEKTRA_LIBS_ELEKTRAD})
add_custom_target (elektrad ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/elektrad/elektrad")
# build elektra-web
install (CODE "message (\"-- Installing: elektra-web > elektrad\")")
install (PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/elektrad/elektrad" DESTINATION "${install_directory}")
# generate man pages
generate_man_page (kdb-run-elektrad FILENAME "${CMAKE_CURRENT_BINARY_DIR}/README.md" GENERATED_FROM
"${CMAKE_CURRENT_SOURCE_DIR}/README.md")
# test apis
find_program (DREDD_EXECUTABLE "dredd")
if (DREDD_EXECUTABLE)
# testing is possible
add_test (
NAME test_elektra_web
COMMAND test.sh
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
set_property (TEST test_elektra_web PROPERTY ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/lib"
"PKG_CONFIG_PATH=${CMAKE_CURRENT_BINARY_DIR}")
else (DREDD_EXECUTABLE)
message (WARNING "Exclude tests for `elektrad`, since `dredd` was not found.")
endif (DREDD_EXECUTABLE)
endif ()