forked from openv/vcontrold
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
92 lines (78 loc) · 2.81 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
cmake_minimum_required(VERSION 3.2.0)
project(vcontrold C)
IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
# CMAKE_INSTALL_PREFIX defaults to /usr/local, but it should go to /usr
set(CMAKE_INSTALL_PREFIX /usr)
ENDIF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
option(MANPAGES "Build man pages via rst2man" ON)
option(VCLIENT "Build the vclient helper program (for communication with vcontrold)" ON)
option(VSIM "Build the vsim helper program (for development and testing purposes)" OFF)
find_package(LibXml2 REQUIRED)
if(MANPAGES)
find_program(RST2MAN NAMES rst2man rst2man.py)
if(RST2MAN)
message("-- Found rst2man: ${RST2MAN}")
else(RST2MAN)
message(FATAL_ERROR
"Could not find a rst2man executable. Either set the \"MANPAGES\" option to \"OFF\" \
(via cmake -DMANPAGES=OFF) or install Python's Docutils \
(cf. http://docutils.sourceforge.net/)."
)
endif(RST2MAN)
endif(MANPAGES)
add_custom_target(
UpdateVersion ALL
COMMAND ${CMAKE_COMMAND}
-DBASE_DIR=${CMAKE_CURRENT_SOURCE_DIR}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/UpdateVersion.cmake
COMMENT "Updating version header."
BYPRODUCTS ${CMAKE_CURRENT_SOURCE_DIR}/src/version.h
)
include_directories(
${LIBXML2_INCLUDE_DIR}
)
set(vcontrold_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/src/io.c
${CMAKE_CURRENT_SOURCE_DIR}/src/common.c
${CMAKE_CURRENT_SOURCE_DIR}/src/xmlconfig.c
${CMAKE_CURRENT_SOURCE_DIR}/src/parser.c
${CMAKE_CURRENT_SOURCE_DIR}/src/socket.c
${CMAKE_CURRENT_SOURCE_DIR}/src/semaphore.c
${CMAKE_CURRENT_SOURCE_DIR}/src/framer.c
${CMAKE_CURRENT_SOURCE_DIR}/src/unit.c
${CMAKE_CURRENT_SOURCE_DIR}/src/arithmetic.c
${CMAKE_CURRENT_SOURCE_DIR}/src/vcontrold.c
)
set(vclient_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/src/common.c
${CMAKE_CURRENT_SOURCE_DIR}/src/socket.c
${CMAKE_CURRENT_SOURCE_DIR}/src/io.c
${CMAKE_CURRENT_SOURCE_DIR}/src/client.c
${CMAKE_CURRENT_SOURCE_DIR}/src/vclient.c
)
set(vsim_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/src/socket.c
${CMAKE_CURRENT_SOURCE_DIR}/src/vsim.c
)
add_executable(vcontrold ${vcontrold_SRCS})
target_link_libraries(vcontrold ${LIBXML2_LIBRARIES})
add_dependencies(vcontrold UpdateVersion)
if(VCLIENT)
add_executable(vclient ${vclient_SRCS})
add_dependencies(vclient UpdateVersion)
endif(VCLIENT)
if(VSIM)
add_executable(vsim ${vsim_SRCS})
add_dependencies(vsim UpdateVersion)
endif(VSIM)
if(MANPAGES)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/doc/man)
endif(MANPAGES)
install(TARGETS vcontrold DESTINATION ${CMAKE_INSTALL_PREFIX}/sbin)
if(VCLIENT)
install(TARGETS vclient DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
endif(VCLIENT)
if(VSIM)
install(TARGETS vsim DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
endif(VSIM)