Skip to content

Commit 9bb2ce7

Browse files
mauriciovasquezbernalfrisso
authored andcommitted
libpolycube: provide pkg-config (#115)
Services that are not shipped with polycube (standalone services) need to know which libraries and headers files should use in the building process. This commit adds a pkg-config file for libpolycube, so services can use it for compiling. This commit also fixes some include errors to allow such standalone services to compile. Signed-off-by: Mauricio Vasquez B <mauriciovasquezbernal@gmail.com>
1 parent f2d20a7 commit 9bb2ce7

8 files changed

Lines changed: 32 additions & 16 deletions

File tree

src/libs/polycube/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
add_subdirectory(src)
22

3-
install(DIRECTORY include/ DESTINATION include)
3+
configure_file(libpolycube.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libpolycube.pc @ONLY)
4+
5+
install(DIRECTORY include/ DESTINATION /usr/include)
6+
7+
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpolycube.pc
8+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)

src/libs/polycube/include/polycube/common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
#pragma once
1818

19-
#include <spdlog/spdlog.h>
19+
#include "spdlog/spdlog.h"
2020
#include <string>
2121

2222
namespace polycube {

src/libs/polycube/include/polycube/services/base_cube.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
#include <map>
2020
#include <string>
2121

22-
#include <spdlog/sinks/rotating_file_sink.h>
23-
#include <spdlog/sinks/stdout_sinks.h>
24-
#include <spdlog/spdlog.h>
22+
#include "spdlog/sinks/rotating_file_sink.h"
23+
#include "spdlog/sinks/stdout_sinks.h"
24+
#include "spdlog/spdlog.h"
2525

2626
#include "polycube/common.h"
2727

src/libs/polycube/include/polycube/services/cube.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,6 @@
1919
#include <map>
2020
#include <string>
2121

22-
#include <spdlog/sinks/rotating_file_sink.h>
23-
#include <spdlog/sinks/stdout_sinks.h>
24-
#include <spdlog/spdlog.h>
25-
26-
#include "polycube/common.h"
27-
28-
#include "polycube/services/cube_factory.h"
2922
#include "polycube/services/port.h"
3023
#include "polycube/services/utils.h"
3124

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
prefix=@CMAKE_INSTALL_PREFIX@
2+
libdir=${prefix}/lib
3+
includedir=/usr/include
4+
5+
Name: libpolycube
6+
Version: @REVISION@
7+
Description: Polycube library
8+
Requires:
9+
Requires.private: libtins
10+
Libs: -L${libdir} -lpolycube -luuid -ltins
11+
Cflags: -I${includedir} -I${includedir}/polycube

src/libs/spdlog/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
install(DIRECTORY spdlog DESTINATION include/polycube)
1+
install(DIRECTORY spdlog DESTINATION /usr/include/polycube)

src/services/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
include_directories(${CMAKE_SOURCE_DIR}/src/libs/polycube/include)
22
include_directories(${CMAKE_SOURCE_DIR}/src/libs/spdlog)
33

4+
set(POLYCUBE_STANDALONE_SERVICE false)
5+
set(POLYCUBE_LIBRARIES polycube uuid tins)
6+
47
set(LOAD_SERVICES "" PARENT_SCOPE)
58

69
macro(add_service servicename servicefolder)

src/services/pcn-helloworld/src/CMakeLists.txt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ include_directories(serializer)
88
include_directories(interface)
99
include_directories(default-src)
1010

11+
if (POLYCUBE_STANDALONE_SERVICE)
12+
find_package(PkgConfig REQUIRED)
13+
pkg_check_modules(POLYCUBE libpolycube)
14+
include_directories(${POLYCUBE_INCLUDE_DIRS})
15+
endif(POLYCUBE_STANDALONE_SERVICE)
16+
1117
# Needed to load files as variables
1218
include_directories(${CMAKE_CURRENT_BINARY_DIR})
1319

@@ -26,9 +32,7 @@ load_file_as_variable(pcn-helloworld Helloworld_dp_egress.c helloworld_code_egre
2632
# load datamodel in a variable
2733
load_file_as_variable(pcn-helloworld ../datamodel/helloworld.yang helloworld_datamodel)
2834

29-
target_link_libraries(pcn-helloworld
30-
polycube
31-
uuid)
35+
target_link_libraries(pcn-helloworld ${POLYCUBE_LIBRARIES})
3236

3337
# Specify shared library install directory
3438

0 commit comments

Comments
 (0)