mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
cmake: add new CMakeLists.txt
This commit is contained in:
parent
832c2857d8
commit
179aa2d553
8 changed files with 519 additions and 0 deletions
104
CMakeLists.txt
Normal file
104
CMakeLists.txt
Normal file
|
@ -0,0 +1,104 @@
|
|||
# Main CMakeLists.
|
||||
#
|
||||
# @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC
|
||||
# @license GNU General Public License (version 3)
|
||||
#
|
||||
# VILLASnode
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
###################################################################################
|
||||
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
|
||||
project(VILLASnode)
|
||||
|
||||
set(CMAKE_C_STANDARD 11)
|
||||
|
||||
set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH ON)
|
||||
|
||||
find_package(PkgConfig)
|
||||
include(CheckIncludeFile)
|
||||
|
||||
# Check OS
|
||||
check_include_file("sys/eventfd.h" HAS_EVENTFD)
|
||||
|
||||
# Build options
|
||||
option(WITH_HOOKS "Build with support for processing hook plugins" ON)
|
||||
option(WITH_IO "Build with support format plugins" ON)
|
||||
option(WITH_WEB "Build with internal webserver" ON)
|
||||
option(WITH_API "Build with remote control API" ON)
|
||||
option(WITH_CONFIG "Build with support for libconfig configuration syntax" ON)
|
||||
|
||||
set(V 2)
|
||||
set(PREFIX ${CMAKE_INSTALL_PREFIX})
|
||||
|
||||
set(VARIANT "${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
|
||||
|
||||
# Add git revision and build variant defines
|
||||
execute_process(
|
||||
COMMAND git describe --tags --abbrev=0 --match "v*"
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE VERSION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
string(SUBSTRING ${VERSION} 2 -1 VERSION_NUM)
|
||||
|
||||
string(TIMESTAMP BUILD_DATE "%Y%m%d")
|
||||
|
||||
if(DEFINED ENV{CI})
|
||||
string(APPEND VARIANT "-ci")
|
||||
string(SUBSTRING $ENV{CI_COMMIT_SHA} 0 7 GIT_REV)
|
||||
set(GIT_BRANCH ${CI_COMMIT_REF_NAME})
|
||||
else()
|
||||
execute_process(
|
||||
COMMAND git rev-parse --short=7 HEAD
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_REV
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
execute_process(
|
||||
COMMAND git rev-parse --abbrev-ref HEAD
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_BRANCH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
endif()
|
||||
|
||||
if(DEFINED ENV{CI_COMMIT_TAG})
|
||||
set(RELEASE 1)
|
||||
else()
|
||||
string(REPLACE "-" "_" GIT_BRANCH_NORM ${GIT_BRANCH})
|
||||
string(REPLACE "-" "_" VARIANT_NORM ${VARIANT})
|
||||
|
||||
set(RELEASE "1.${GIT_BRANCH_NORM}_${VARIANT_NORM}.${BUILD_DATE}git${GIT_REV}")
|
||||
endif()
|
||||
|
||||
set(BUILDID "${VERSION}-${GIT_REV}-${VARIANT}")
|
||||
|
||||
configure_file(
|
||||
${CMAKE_SOURCE_DIR}/include/villas/config.h.in
|
||||
${CMAKE_BINARY_DIR}/include/villas/config.h
|
||||
)
|
||||
|
||||
include_directories(
|
||||
${CMAKE_SOURCE_DIR}/include
|
||||
${CMAKE_BINARY_DIR}/include
|
||||
)
|
||||
|
||||
add_subdirectory(lib)
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(tools)
|
128
lib/CMakeLists.txt
Normal file
128
lib/CMakeLists.txt
Normal file
|
@ -0,0 +1,128 @@
|
|||
# CMakeLists.
|
||||
#
|
||||
# @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC
|
||||
# @license GNU General Public License (version 3)
|
||||
#
|
||||
# VILLASnode
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
###################################################################################
|
||||
|
||||
find_package(OpenSSL REQUIRED)
|
||||
find_package(curl REQUIRED)
|
||||
|
||||
pkg_check_modules(JANSSON IMPORTED_TARGET REQUIRED jansson)
|
||||
|
||||
set(INCLUDE_DIRS
|
||||
${JANSSON_INCLUDE_DIRS}
|
||||
${OPENSSL_INCLUDE_DIR}
|
||||
${CURL_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
set(LIBRARIES
|
||||
PkgConfig::JANSSON
|
||||
${OPENSSL_LIBRARIES}
|
||||
${CURL_LIBRARIES}
|
||||
)
|
||||
|
||||
set(LIB_SRC
|
||||
kernel/kernel.c
|
||||
kernel/rt.c
|
||||
sample.c
|
||||
path.c
|
||||
node.c
|
||||
log.c
|
||||
log_config.c
|
||||
utils.c
|
||||
super_node.c
|
||||
hist.c
|
||||
timing.c
|
||||
pool.c
|
||||
list.c
|
||||
queue.c
|
||||
queue_signalled.c
|
||||
memory.c
|
||||
advio.c
|
||||
plugin.c
|
||||
node_type.c
|
||||
stats.c
|
||||
mapping.c
|
||||
shmem.c
|
||||
config_helper.c
|
||||
crypt.c
|
||||
compat.c
|
||||
log_helper.c
|
||||
task.c
|
||||
buffer.c
|
||||
table.c
|
||||
bitset.c
|
||||
signal.c
|
||||
)
|
||||
|
||||
add_subdirectory(nodes)
|
||||
|
||||
if(WITH_CONFIG)
|
||||
pkg_check_modules(CONFIG IMPORTED_TARGET REQUIRED libconfig)
|
||||
|
||||
list(APPEND INCLUDE_DIRS ${CONFIG_INCLUDE_DIRS})
|
||||
list(APPEND LIBRARIES PkgConfig::CONFIG)
|
||||
endif()
|
||||
|
||||
if(WITH_IO)
|
||||
list(APPEND LIB_SRC
|
||||
io.c
|
||||
format_type.c
|
||||
)
|
||||
|
||||
add_subdirectory(formats)
|
||||
list(APPEND LIBRARIES villas-formats)
|
||||
endif()
|
||||
|
||||
if(WITH_HOOKS)
|
||||
list(APPEND LIB_SRC
|
||||
hook.c
|
||||
hook_type.c
|
||||
)
|
||||
|
||||
add_subdirectory(hooks)
|
||||
list(APPEND LIBRARIES villas-hooks)
|
||||
endif()
|
||||
|
||||
if(WITH_WEB)
|
||||
list(APPEND LIB_SRC
|
||||
web.c
|
||||
)
|
||||
|
||||
find_package(libwebsockets REQUIRED)
|
||||
|
||||
message("LWS: ${LIBWEBSOCKETS_LIBRARIES}")
|
||||
|
||||
list(APPEND INCLUDE_DIRS ${LIBWEBSOCKETS_INCLUDE_DIRS})
|
||||
list(APPEND LIBRARIES websockets_shared)
|
||||
endif()
|
||||
|
||||
if(WITH_API AND WITH_WEB)
|
||||
list(APPEND LIB_SRC
|
||||
api.c
|
||||
)
|
||||
|
||||
add_subdirectory(api)
|
||||
list(APPEND LIBRARIES villas-api)
|
||||
endif()
|
||||
|
||||
add_library(villas SHARED ${LIB_SRC})
|
||||
|
||||
target_include_directories(villas PUBLIC ${INCLUDE_DIRS})
|
||||
target_link_libraries(villas PUBLIC ${LIBRARIES})
|
42
lib/api/CMakeLists.txt
Normal file
42
lib/api/CMakeLists.txt
Normal file
|
@ -0,0 +1,42 @@
|
|||
|
||||
# CMakeLists.
|
||||
#
|
||||
# @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC
|
||||
# @license GNU General Public License (version 3)
|
||||
#
|
||||
# VILLASnode
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
###################################################################################
|
||||
|
||||
find_package(openssl REQUIRED)
|
||||
|
||||
set(INCLUDE_DIRS
|
||||
${OPENSSL_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
set(LIBRARIES
|
||||
${OPENSSL_LIBRARIES}
|
||||
)
|
||||
|
||||
file(GLOB ACTION_SRC actions/*.c)
|
||||
|
||||
add_library(villas-api STATIC
|
||||
${ACTION_SRC}
|
||||
session.c
|
||||
)
|
||||
|
||||
target_include_directories(villas-api PUBLIC ${INCLUDE_DIRS})
|
||||
target_link_libraries(villas-api PUBLIC ${LIBRARIES})
|
82
lib/formats/CMakeLists.txt
Normal file
82
lib/formats/CMakeLists.txt
Normal file
|
@ -0,0 +1,82 @@
|
|||
# CMakeLists.
|
||||
#
|
||||
# @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC
|
||||
# @license GNU General Public License (version 3)
|
||||
#
|
||||
# VILLASnode
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
###################################################################################
|
||||
|
||||
set(FORMAT_SRC
|
||||
json.c
|
||||
json_reserve.c
|
||||
villas_binary.c
|
||||
villas_human.c
|
||||
csv.c
|
||||
raw.c
|
||||
)
|
||||
|
||||
find_package(openssl REQUIRED)
|
||||
|
||||
set(INCLUDE_DIRS
|
||||
${OPENSSL_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
set(LIBRARIES
|
||||
${OPENSSL_LIBRARIES}
|
||||
)
|
||||
|
||||
# Enable Google Protobuf format
|
||||
find_package(Protobuf)
|
||||
if(Protobuf_FOUND)
|
||||
list(APPEND FORMAT_SRC
|
||||
protobuf.c
|
||||
${CMAKE_CURRENT_BINARY_DIR}/villas.pb-c.c
|
||||
)
|
||||
|
||||
list(APPEND INCLUDE_DIRS
|
||||
${Protobuf_INCLUDE_DIRS}
|
||||
${Protobuf_PROTOC_INCLUDE_DIRS}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
|
||||
list(APPEND LIBRARIES
|
||||
${Protobuf_LIBRARY}
|
||||
${Protobuf_PROTOC_LIBRARIES}
|
||||
)
|
||||
|
||||
set_source_files_properties(villas.pb-c.h villas.pb-c.c
|
||||
PROPERTIES
|
||||
GENERATED TRUE
|
||||
)
|
||||
|
||||
add_custom_command(
|
||||
COMMAND ${Protobuf_PROTOC_EXECUTABLE} --c_out=${CMAKE_CURRENT_BINARY_DIR} villas.proto
|
||||
OUTPUT
|
||||
villas.pb-c.c
|
||||
villas.pb-c.h
|
||||
MAIN_DEPENDENCY villas.proto
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
endif()
|
||||
|
||||
add_library(villas-formats STATIC ${FORMAT_SRC})
|
||||
target_include_directories(villas-formats PUBLIC ${INCLUDE_DIRS})
|
||||
target_link_libraries(villas-formats PUBLIC ${LIBRARIES})
|
||||
|
||||
if(Protobuf_FOUND)
|
||||
# add_dependencies(villas-formats villas.pb-c.c villas.pb-c.h)
|
||||
endif()
|
57
lib/hooks/CMakeLists.txt
Normal file
57
lib/hooks/CMakeLists.txt
Normal file
|
@ -0,0 +1,57 @@
|
|||
# CMakeLists.
|
||||
#
|
||||
# @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC
|
||||
# @license GNU General Public License (version 3)
|
||||
#
|
||||
# VILLASnode
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
###################################################################################
|
||||
|
||||
pkg_check_modules(JANSSON IMPORTED_TARGET REQUIRED jansson)
|
||||
|
||||
set(INCLUDE_DIRS
|
||||
${JANSSON_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
set(LIBRARIES
|
||||
PkgConfig::JANSSON
|
||||
)
|
||||
|
||||
set(HOOK_SRC
|
||||
convert.c
|
||||
decimate.c
|
||||
drop.c
|
||||
jitter_calc.c
|
||||
map.c
|
||||
restart.c
|
||||
shift_seq.c
|
||||
shift_ts.c
|
||||
skip_first.c
|
||||
stats.c
|
||||
ts.c
|
||||
limit_rate.c
|
||||
scale.c
|
||||
)
|
||||
|
||||
if(WITH_IO)
|
||||
list(APPEND HOOK_SRC
|
||||
print.c
|
||||
)
|
||||
endif()
|
||||
|
||||
add_library(villas-hooks STATIC ${HOOK_SRC})
|
||||
target_include_directories(villas-hooks PUBLIC ${INCLUDE_DIRS})
|
||||
target_link_libraries(villas-hooks PUBLIC ${LIBRARIES})
|
48
lib/nodes/CMakeLists.txt
Normal file
48
lib/nodes/CMakeLists.txt
Normal file
|
@ -0,0 +1,48 @@
|
|||
# CMakeLists.
|
||||
#
|
||||
# @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC
|
||||
# @license GNU General Public License (version 3)
|
||||
#
|
||||
# VILLASnode
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
###################################################################################
|
||||
|
||||
pkg_check_modules(JANSSON IMPORTED_TARGET REQUIRED jansson)
|
||||
|
||||
set(INCLUDE_DIRS
|
||||
${JANSSON_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
set(LIBRARIES
|
||||
PkgConfig::JANSSON
|
||||
)
|
||||
|
||||
set(NODE_SRC
|
||||
influxdb.c
|
||||
stats.c
|
||||
file.c
|
||||
)
|
||||
|
||||
if(HAS_EVENTFD)
|
||||
list(APPEND NODE_SRC
|
||||
loopback.c
|
||||
cbuilder.c
|
||||
)
|
||||
endif()
|
||||
|
||||
add_library(villas-nodes STATIC ${NODE_SRC})
|
||||
target_include_directories(villas-nodes PUBLIC ${INCLUDE_DIRS})
|
||||
target_link_libraries(villas-nodes PUBLIC ${LIBRARIES})
|
16
src/CMakeLists.txt
Normal file
16
src/CMakeLists.txt
Normal file
|
@ -0,0 +1,16 @@
|
|||
link_libraries(villas)
|
||||
|
||||
add_executable(villas-node node.c)
|
||||
add_executable(villas-test-rtt test-rtt.c)
|
||||
add_executable(villas-test-shmem test-shmem.c)
|
||||
|
||||
if(WITH_IO)
|
||||
add_executable(villas-test-cmp test-cmp.c)
|
||||
add_executable(villas-convert convert.c)
|
||||
add_executable(villas-pipe pipe.c)
|
||||
add_executable(villas-signal signal.c)
|
||||
endif()
|
||||
|
||||
if(WITH_IO AND WITH_HOOKS)
|
||||
add_executable(villas-hook hook.c)
|
||||
endif()
|
42
tools/CMakeLists.txt
Normal file
42
tools/CMakeLists.txt
Normal file
|
@ -0,0 +1,42 @@
|
|||
# CMakeLists.
|
||||
#
|
||||
# @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
|
||||
# @copyright 2017, Institute for Automation of Complex Power Systems, EONERC
|
||||
# @license GNU General Public License (version 3)
|
||||
#
|
||||
# VILLASnode
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
###################################################################################
|
||||
|
||||
if(WITH_CONFIG)
|
||||
add_executable(conf2json conf2json.c)
|
||||
|
||||
target_link_libraries(conf2json PUBLIC villas)
|
||||
endif()
|
||||
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
add_executable(rmshm rmshm.c)
|
||||
target_link_libraries(rmshm PUBLIC pthread rt)
|
||||
|
||||
add_executable(rmsem rmsem.c)
|
||||
target_link_libraries(rmsem PUBLIC pthread rt)
|
||||
endif()
|
||||
|
||||
pkg_check_modules(ZMQ IMPORTED_TARGET REQUIRED libzmq)
|
||||
if(ZMQ_FOUND)
|
||||
add_executable(zmq-keygen zmq-keygen.c)
|
||||
target_include_directories(zmq-keygen PUBLIC ${ZMQ_INCLUDE_DIRS})
|
||||
target_link_libraries(zmq-keygen PUBLIC PkgConfig::ZMQ)
|
||||
endif()
|
Loading…
Add table
Reference in a new issue