summaryrefslogtreecommitdiffstats
path: root/ctrl/sysrepo-plugins/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'ctrl/sysrepo-plugins/CMakeLists.txt')
-rw-r--r--ctrl/sysrepo-plugins/CMakeLists.txt42
1 files changed, 25 insertions, 17 deletions
diff --git a/ctrl/sysrepo-plugins/CMakeLists.txt b/ctrl/sysrepo-plugins/CMakeLists.txt
index 93434b9c6..13a601bf0 100644
--- a/ctrl/sysrepo-plugins/CMakeLists.txt
+++ b/ctrl/sysrepo-plugins/CMakeLists.txt
@@ -16,29 +16,37 @@
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
project(hicn_sysrepo_plugin)
-include(GNUInstallDirs)
-
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules"
"${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/Modules"
)
-# set default build type if not specified by user
-if(NOT CMAKE_BUILD_TYPE)
- set(CMAKE_BUILD_TYPE debug)
+include(GNUInstallDirs)
+include(BuildMacros)
+
+find_package(PkgConfig)
+find_package(Sysrepo)
+
+if (NOT SRPD_PLUGINS_PATH)
+ if (PKG_CONFIG_FOUND)
+ execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} "--variable=SRPD_PLUGINS_PATH" "libsysrepo" OUTPUT_VARIABLE SRPD_PLUGINS_PATH)
+ string(STRIP ${SRPD_PLUGINS_PATH} SRPD_PLUGINS_PATH)
+ endif()
+endif()
+if (NOT SRPD_PLUGINS_PATH)
+ message(FATAL_ERROR "Cannot get sysrepo plugins directory due to missing pkg-config, set SRPD_PLUGINS_PATH manually.")
endif()
-string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER)
-# set compiler options
-set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -std=gnu99")
-set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG -O2")
-set(CMAKE_C_FLAGS_DEBUG "-g -O0")
+if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
+ find_package_wrapper(VPP REQUIRED)
+ find_package_wrapper(HicnPlugin REQUIRED)
+ add_subdirectory(hicn-plugin)
+else()
+ if (BUILD_HICNPLUGIN AND "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
+ list(APPEND DEPENDENCIES
+ hicn_plugin)
+ add_subdirectory(hicn-plugin)
+ endif ()
+endif()
# add subdirectories
-if (BUILD_HICNPLUGIN AND "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
- add_subdirectory(hicn-plugin)
-endif ()
-if (BUILD_HICNLIGHT AND "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
- add_subdirectory(hicn-light)
-endif ()
include(Packaging)