Skip to content

Commit

Permalink
libpolycube: provide pkg-config (#115)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
mauriciovasquezbernal authored and frisso committed Apr 26, 2019
1 parent f2d20a7 commit 9bb2ce7
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 16 deletions.
7 changes: 6 additions & 1 deletion src/libs/polycube/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
add_subdirectory(src)

install(DIRECTORY include/ DESTINATION include)
configure_file(libpolycube.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libpolycube.pc @ONLY)

install(DIRECTORY include/ DESTINATION /usr/include)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpolycube.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
2 changes: 1 addition & 1 deletion src/libs/polycube/include/polycube/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#pragma once

#include <spdlog/spdlog.h>
#include "spdlog/spdlog.h"
#include <string>

namespace polycube {
Expand Down
6 changes: 3 additions & 3 deletions src/libs/polycube/include/polycube/services/base_cube.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
#include <map>
#include <string>

#include <spdlog/sinks/rotating_file_sink.h>
#include <spdlog/sinks/stdout_sinks.h>
#include <spdlog/spdlog.h>
#include "spdlog/sinks/rotating_file_sink.h"
#include "spdlog/sinks/stdout_sinks.h"
#include "spdlog/spdlog.h"

#include "polycube/common.h"

Expand Down
7 changes: 0 additions & 7 deletions src/libs/polycube/include/polycube/services/cube.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@
#include <map>
#include <string>

#include <spdlog/sinks/rotating_file_sink.h>
#include <spdlog/sinks/stdout_sinks.h>
#include <spdlog/spdlog.h>

#include "polycube/common.h"

#include "polycube/services/cube_factory.h"
#include "polycube/services/port.h"
#include "polycube/services/utils.h"

Expand Down
11 changes: 11 additions & 0 deletions src/libs/polycube/libpolycube.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
prefix=@CMAKE_INSTALL_PREFIX@
libdir=${prefix}/lib
includedir=/usr/include

Name: libpolycube
Version: @REVISION@
Description: Polycube library
Requires:
Requires.private: libtins
Libs: -L${libdir} -lpolycube -luuid -ltins
Cflags: -I${includedir} -I${includedir}/polycube
2 changes: 1 addition & 1 deletion src/libs/spdlog/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
install(DIRECTORY spdlog DESTINATION include/polycube)
install(DIRECTORY spdlog DESTINATION /usr/include/polycube)
3 changes: 3 additions & 0 deletions src/services/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
include_directories(${CMAKE_SOURCE_DIR}/src/libs/polycube/include)
include_directories(${CMAKE_SOURCE_DIR}/src/libs/spdlog)

set(POLYCUBE_STANDALONE_SERVICE false)
set(POLYCUBE_LIBRARIES polycube uuid tins)

set(LOAD_SERVICES "" PARENT_SCOPE)

macro(add_service servicename servicefolder)
Expand Down
10 changes: 7 additions & 3 deletions src/services/pcn-helloworld/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ include_directories(serializer)
include_directories(interface)
include_directories(default-src)

if (POLYCUBE_STANDALONE_SERVICE)
find_package(PkgConfig REQUIRED)
pkg_check_modules(POLYCUBE libpolycube)
include_directories(${POLYCUBE_INCLUDE_DIRS})
endif(POLYCUBE_STANDALONE_SERVICE)

# Needed to load files as variables
include_directories(${CMAKE_CURRENT_BINARY_DIR})

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

target_link_libraries(pcn-helloworld
polycube
uuid)
target_link_libraries(pcn-helloworld ${POLYCUBE_LIBRARIES})

# Specify shared library install directory

Expand Down

0 comments on commit 9bb2ce7

Please sign in to comment.