mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
cmake: change sub-libraries to be statically linked
This commit is contained in:
parent
a27de9542c
commit
fc6f63b192
7 changed files with 32 additions and 217 deletions
|
@ -20,6 +20,8 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
###################################################################################
|
||||
|
||||
add_compile_options(-fPIC)
|
||||
|
||||
set(INCLUDE_DIRS
|
||||
${JANSSON_INCLUDE_DIRS}
|
||||
${OPENSSL_INCLUDE_DIR}
|
||||
|
@ -67,7 +69,7 @@ set(LIB_SRC
|
|||
)
|
||||
|
||||
add_subdirectory(nodes)
|
||||
list(APPEND LIBRARIES villas-nodes)
|
||||
list(APPEND WHOLE_ARCHIVES nodes)
|
||||
|
||||
if(LIBCONFIG_FOUND)
|
||||
list(APPEND INCLUDE_DIRS ${LIBCONFIG_INCLUDE_DIRS})
|
||||
|
@ -81,7 +83,7 @@ if(WITH_IO)
|
|||
)
|
||||
|
||||
add_subdirectory(formats)
|
||||
list(APPEND LIBRARIES villas-formats)
|
||||
list(APPEND WHOLE_ARCHIVES formats)
|
||||
endif()
|
||||
|
||||
if(WITH_HOOKS)
|
||||
|
@ -91,7 +93,7 @@ if(WITH_HOOKS)
|
|||
)
|
||||
|
||||
add_subdirectory(hooks)
|
||||
list(APPEND LIBRARIES villas-hooks)
|
||||
list(APPEND WHOLE_ARCHIVES hooks)
|
||||
endif()
|
||||
|
||||
if(WITH_WEB)
|
||||
|
@ -109,7 +111,7 @@ if(WITH_API AND WITH_WEB)
|
|||
)
|
||||
|
||||
add_subdirectory(api)
|
||||
list(APPEND LIBRARIES villas-api)
|
||||
list(APPEND WHOLE_ARCHIVES api)
|
||||
endif()
|
||||
|
||||
# libnl3 is optional but required for network emulation and IRQ pinning
|
||||
|
@ -130,10 +132,17 @@ add_library(villas SHARED ${LIB_SRC})
|
|||
target_include_directories(villas PUBLIC ${INCLUDE_DIRS})
|
||||
target_link_libraries(villas PUBLIC ${LIBRARIES})
|
||||
|
||||
#set_target_properties(villas PROPERTIES
|
||||
# VERSION ${PROJECT_VERSION}
|
||||
# SOVERSION ${PROJECT_SOVERSION}
|
||||
#)
|
||||
if(APPLE)
|
||||
target_link_libraries(villas PRIVATE -Wl,-all_load ${WHOLE_ARCHIVES} -Wl,-noall_load)
|
||||
else()
|
||||
target_link_libraries(villas PRIVATE -Wl,--whole-archive ${WHOLE_ARCHIVES} -Wl,--no-whole-archive)
|
||||
endif()
|
||||
|
||||
|
||||
set_target_properties(villas PROPERTIES
|
||||
VERSION ${PROJECT_VERSION}
|
||||
SOVERSION ${PROJECT_SOVERSION}
|
||||
)
|
||||
|
||||
install(
|
||||
TARGETS villas
|
||||
|
|
|
@ -40,17 +40,6 @@ set(API_SRC
|
|||
actions/status.c
|
||||
)
|
||||
|
||||
add_library(villas-api SHARED ${API_SRC})
|
||||
target_include_directories(villas-api PUBLIC ${INCLUDE_DIRS})
|
||||
target_link_libraries(villas-api PUBLIC ${LIBRARIES})
|
||||
|
||||
#set_target_properties(villas-api PROPERTIES
|
||||
# VERSION ${PROJECT_VERSION}
|
||||
# SOVERSION ${PROJECT_SOVERSION}
|
||||
#)
|
||||
|
||||
install(
|
||||
TARGETS villas-api
|
||||
COMPONENT lib
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
)
|
||||
add_library(api STATIC ${API_SRC})
|
||||
target_include_directories(api PUBLIC ${INCLUDE_DIRS})
|
||||
target_link_libraries(api INTERFACE ${LIBRARIES})
|
||||
|
|
|
@ -50,17 +50,6 @@ if(WITH_IO)
|
|||
)
|
||||
endif()
|
||||
|
||||
add_library(villas-hooks SHARED ${HOOK_SRC})
|
||||
target_include_directories(villas-hooks PUBLIC ${INCLUDE_DIRS})
|
||||
target_link_libraries(villas-hooks PUBLIC ${LIBRARIES})
|
||||
|
||||
#set_target_properties(villas-hooks PROPERTIES
|
||||
# VERSION ${PROJECT_VERSION}
|
||||
# SOVERSION ${PROJECT_SOVERSION}
|
||||
#)
|
||||
|
||||
install(
|
||||
TARGETS villas-hooks
|
||||
COMPONENT lib
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
)
|
||||
add_library(hooks STATIC ${HOOK_SRC})
|
||||
target_include_directories(hooks PUBLIC ${INCLUDE_DIRS})
|
||||
target_link_libraries(hooks INTERFACE ${LIBRARIES})
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <syslog.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <villas/config.h>
|
||||
#include <villas/log.h>
|
||||
|
|
|
@ -57,7 +57,10 @@ endif()
|
|||
# Enable shared memory node-type
|
||||
if(HAS_SEMAPHORE AND HAS_MMAN)
|
||||
list(APPEND NODE_SRC shmem.c)
|
||||
list(APPEND LIBRARIES "rt")
|
||||
|
||||
if(CMAKE_SUSTEM_NAME STREQUAL Linux)
|
||||
list(APPEND LIBRARIES rt)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Enable IEC61850 node-types when libiec61850 is available
|
||||
|
@ -123,17 +126,6 @@ if(COMEDILIB_FOUND)
|
|||
list(APPEND LIBRARIES PkgConfig::COMEDILIB)
|
||||
endif()
|
||||
|
||||
add_library(villas-nodes SHARED ${NODE_SRC})
|
||||
target_include_directories(villas-nodes PUBLIC ${INCLUDE_DIRS})
|
||||
target_link_libraries(villas-nodes PUBLIC ${LIBRARIES})
|
||||
|
||||
#set_target_properties(villas-nodes PROPERTIES
|
||||
# VERSION ${PROJECT_VERSION}
|
||||
# SOVERSION ${PROJECT_SOVERSION}
|
||||
#)
|
||||
|
||||
install(
|
||||
TARGETS villas-nodes
|
||||
COMPONENT lib
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
)
|
||||
add_library(nodes STATIC ${NODE_SRC})
|
||||
target_include_directories(nodes PUBLIC ${INCLUDE_DIRS})
|
||||
target_link_libraries(nodes LINK_PRIVATE ${LIBRARIES})
|
||||
|
|
|
@ -1,166 +0,0 @@
|
|||
# Makefile.
|
||||
#
|
||||
# @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/>.
|
||||
###################################################################################
|
||||
|
||||
# Enabled loopback node-type
|
||||
ifeq ($(WITH_NODE_LOOPBACK),1)
|
||||
LIB_NODES += loopback
|
||||
endif
|
||||
|
||||
# Enabled Cbuilder node-type
|
||||
ifeq ($(WITH_NODE_CBUILDER),1)
|
||||
LIB_NODES += cbuilder
|
||||
endif
|
||||
|
||||
# Enable InfluxDB node-type
|
||||
ifeq ($(WITH_NODE_INFLUXDB),1)
|
||||
LIB_NODES += influxdb
|
||||
endif
|
||||
|
||||
# Enable stats node-type
|
||||
ifeq ($(WITH_NODE_STATS),1)
|
||||
LIB_NODES += stats
|
||||
endif
|
||||
|
||||
# Enable file node-type
|
||||
ifeq ($(WITH_NODE_FILE),1)
|
||||
LIB_NODES += file
|
||||
WITH_IO = 1
|
||||
endif
|
||||
|
||||
# Enable shared memory node-type
|
||||
ifeq ($(WITH_NODE_SHMEM),1)
|
||||
LIB_NODES += shmem
|
||||
endif
|
||||
|
||||
# Enable signal generator node-type
|
||||
ifeq ($(WITH_NODE_SIGNAL),1)
|
||||
LIB_NODES += signal_generator
|
||||
endif
|
||||
|
||||
# Enable RTT test node-tyoe
|
||||
ifeq ($(WITH_NODE_TEST_RTT),1)
|
||||
LIB_NODES += test_rtt
|
||||
WITH_IO = 1
|
||||
endif
|
||||
|
||||
# Enable IEC61850 node-types when libiec61850 is available
|
||||
ifeq ($(WITH_NODE_IEC61850),1)
|
||||
ifeq ($(shell $(PKGCONFIG) --atleast-version=1.2.0 libiec61850; echo $$?),0)
|
||||
LIB_SRCS += lib/nodes/iec61850_sv.c
|
||||
LIB_NODES += iec61850
|
||||
LIB_PKGS += libiec61850
|
||||
endif
|
||||
endif
|
||||
|
||||
# Enable OPAL-RT Asynchronous Process support (will result in 32bit binary!!!)
|
||||
ifeq ($(WITH_NODE_OPAL),1)
|
||||
ifneq ($(wildcard $(SRCDIR)/thirdparty/libopal/include/opal/AsyncApi.h),)
|
||||
LIB_CFLAGS += -I $(SRCDIR)/thirdparty/libopal/include/opal/
|
||||
LIB_LDFLAGS += -L/lib/i386-linux-gnu/ -L/usr/lib/i386-linux-gnu/ -L$(SRCDIR)/thirdparty/libopal/
|
||||
LIB_LDLIBS += -lOpalAsyncApiCore -lOpalCore -lOpalUtils -lirc
|
||||
LIB_NODES += opal
|
||||
|
||||
# libOpalAsyncApi is a 32bit library. So we need to build everything in 32bit
|
||||
CFLAGS += -m32
|
||||
LDFLAGS += -m32
|
||||
endif
|
||||
endif
|
||||
|
||||
# Enable Socket node type when libnl3 is available
|
||||
ifeq ($(WITH_NODE_SOCKET),1)
|
||||
LIB_NODES += socket
|
||||
WITH_IO = 1
|
||||
|
||||
# libnl3 is optional but required for network emulation and IRQ pinning
|
||||
ifeq ($(shell $(PKGCONFIG) libnl-route-3.0; echo $$?),0)
|
||||
LIB_SRCS += $(addprefix lib/kernel/, nl.c tc.c tc_netem.c if.c)
|
||||
LIB_PKGS += libnl-route-3.0
|
||||
endif
|
||||
endif
|
||||
|
||||
# Enable nanomsg node type when libnanomsg is available
|
||||
ifeq ($(WITH_NODE_NANOMSG),1)
|
||||
ifeq ($(shell $(PKGCONFIG) nanomsg; echo $$?),0)
|
||||
LIB_PKGS += nanomsg
|
||||
LIB_NODES += nanomsg
|
||||
WITH_IO = 1
|
||||
else ifeq ($(shell $(PKGCONFIG) libnanomsg; echo $$?),0)
|
||||
LIB_PKGS += libnanomsg
|
||||
LIB_NODES += nanomsg
|
||||
WITH_IO = 1
|
||||
endif
|
||||
endif
|
||||
|
||||
# Enable ZeroMQ node type when libzmq is available
|
||||
ifeq ($(WITH_NODE_ZEROMQ),1)
|
||||
ifeq ($(shell $(PKGCONFIG) libzmq; echo $$?),0)
|
||||
LIB_PKGS += libzmq
|
||||
LIB_NODES += zeromq
|
||||
WITH_IO = 1
|
||||
endif
|
||||
endif
|
||||
|
||||
# Enable NGSI support
|
||||
ifeq ($(WITH_NODE_NGSI),1)
|
||||
ifeq ($(shell $(PKGCONFIG) libcurl; echo $$?),0)
|
||||
LIB_PKGS += libcurl
|
||||
LIB_NODES += ngsi
|
||||
endif
|
||||
endif
|
||||
|
||||
# Enable WebSocket support
|
||||
ifeq ($(WITH_NODE_WEBSOCKET),1)
|
||||
ifeq ($(shell $(PKGCONFIG) libwebsockets; echo $$?),0)
|
||||
LIB_PKGS += libwebsockets
|
||||
LIB_NODES += websocket
|
||||
WITH_IO = 1
|
||||
WITH_WEB = 1
|
||||
endif
|
||||
endif
|
||||
|
||||
# Enable AMQP support
|
||||
ifeq ($(WITH_NODE_AMQP),1)
|
||||
ifeq ($(shell $(PKGCONFIG) librabbitmq; echo $$?),0)
|
||||
LIB_PKGS += librabbitmq
|
||||
LIB_NODES += amqp
|
||||
WITH_IO = 1
|
||||
endif
|
||||
endif
|
||||
|
||||
# Enable MQTT support
|
||||
ifeq ($(WITH_NODE_MQTT),1)
|
||||
ifneq ($(wildcard /usr/include/mosquitto.h),)
|
||||
LIB_SRCS += lib/nodes/mqtt.c
|
||||
LIB_NODES += mqtt
|
||||
LIB_LDLIBS += -lmosquitto
|
||||
WITH_IO = 1
|
||||
endif
|
||||
endif
|
||||
|
||||
# Enable Comedi support
|
||||
ifeq ($(WITH_NODE_COMEDI),1)
|
||||
ifeq ($(shell $(PKGCONFIG) comedilib; echo $$?),0)
|
||||
LIB_PKGS += comedilib
|
||||
LIB_SRCS += lib/nodes/comedi.c
|
||||
LIB_NODES += comedi
|
||||
endif
|
||||
endif
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include <unistd.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <netinet/ip.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <errno.h>
|
||||
|
|
Loading…
Add table
Reference in a new issue