1 cmake_minimum_required(VERSION 2.8.12)
3 set(PROJECT_DESC "Network Topology Simulator using sysrepo and netopeer2")
4 include(GNUInstallDirs)
7 set(NTSIMULATOR_MAJOR_VERSION 1)
8 set(NTSIMULATOR_MINOR_VERSION 1)
9 set(NTSIMULATOR_PATCH_VERSION 1)
10 set(NTSIMULATOR_VERSION ${NTSIMULATOR_MAJOR_VERSION}.${NTSIMULATOR_MINOR_VERSION}.${NTSIMULATOR_PATCH_VERSION})
11 set(NTSIMULATOR_SOVERSION ${NTSIMULATOR_MAJOR_VERSION}.${NTSIMULATOR_MINOR_VERSION})
14 set(CMAKE_MACOSX_RPATH TRUE)
16 # set default build type if not specified by user
17 if(NOT CMAKE_BUILD_TYPE)
18 set(CMAKE_BUILD_TYPE debug)
20 string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER)
22 set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
24 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wpedantic -std=gnu11 -Wno-language-extension-token")
25 if(CMAKE_COMPILER_IS_GNUCC)
26 # disable strict aliasing in GCC, since it produces false alarams in libev
27 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-strict-aliasing")
29 set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG -O2")
30 set(CMAKE_C_FLAGS_DEBUG "-g -O0")
33 message(FATAL_ERROR "Only Unix-like systems are supported.")
36 if(NOT DEFINED IS_DEVELOPER_CONFIGURATION)
37 if(CMAKE_BUILD_TYPE_LOWER MATCHES "debug" AND NOT CMAKE_BUILD_TYPE_LOWER MATCHES "^rel")
38 set(IS_DEVELOPER_CONFIGURATION true)
40 set(IS_DEVELOPER_CONFIGURATION false)
44 # location of system repository
45 if(${IS_DEVELOPER_CONFIGURATION})
46 set(REPOSITORY_LOC "${CMAKE_BINARY_DIR}/repository" CACHE PATH "System repository location, contains configuration schema and data files.")
48 set(REPOSITORY_LOC "/etc/sysrepo" CACHE PATH "System repository location, contains configuration schema and data files.")
51 # include custom Modules
52 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMakeModules/")
53 include_directories(${CMAKE_CURRENT_BINARY_DIR})
54 include_directories("${CMAKE_CURRENT_SOURCE_DIR}/inc")
56 # find required libraries
57 find_package(SYSREPO REQUIRED)
58 include_directories(${SYSREPO_INCLUDE_DIR})
63 # Configure install file
64 configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scripts/model-install.sh.in" "${PROJECT_BINARY_DIR}/model-install.sh" ESCAPE_QUOTES @ONLY)
67 if (NOT SYSREPOCTL_EXECUTABLE)
68 find_program(SYSREPOCTL_EXECUTABLE sysrepoctl)
70 if (NOT SYSREPOCTL_EXECUTABLE)
71 message(FATAL_ERROR "Unable to find sysrepoctl, set SYSREPOCTL_EXECUTABLE manually.")
75 if (NOT SYSREPOCFG_EXECUTABLE)
76 find_program(SYSREPOCFG_EXECUTABLE sysrepocfg)
78 if (NOT SYSREPOCFG_EXECUTABLE)
79 message(FATAL_ERROR "Unable to find sysrepocfg, set SYSREPOCFG_EXECUTABLE manually.")
82 # Command line options to be passed to `sysrepoctl` when working with modules
83 # which should only be accessible by an administrator
84 if (NOT SYSREPOCTL_ROOT_PERMS)
85 set(SYSREPOCTL_ROOT_PERMS "-o root:root -p 600")
89 set(ENV{SYSREPOCTL} ${SYSREPOCTL_EXECUTABLE})
90 set(ENV{SYSREPOCFG} ${SYSREPOCFG_EXECUTABLE})
91 set(ENV{SYSREPOCTL_ROOT_PERMS} SYSREPOCTL_ROOT_PERMS)
92 execute_process(COMMAND ${PROJECT_BINARY_DIR}/model-install.sh)")