Radek Krejci | b0cd394 | 2017-04-07 13:31:30 +0200 | [diff] [blame] | 1 | cmake_minimum_required(VERSION 2.8.12) |
Radek Krejci | e74ea8c | 2015-04-09 18:06:20 +0200 | [diff] [blame] | 2 | project(libyang C) |
| 3 | |
Jan Kundrát | 37df09e | 2016-11-04 15:42:08 +0100 | [diff] [blame] | 4 | include(GNUInstallDirs) |
| 5 | |
Michal Vasko | e5cf992 | 2015-11-11 11:06:40 +0100 | [diff] [blame] | 6 | set(LIBYANG_DESCRIPTION "libyang is YANG data modelling language parser and toolkit written (and providing API) in C.") |
| 7 | |
Radek Krejci | b0cd394 | 2017-04-07 13:31:30 +0200 | [diff] [blame] | 8 | # Correct RPATH usage on OS X |
| 9 | set(CMAKE_MACOSX_RPATH TRUE) |
| 10 | |
Radek Krejci | 8f7cf40 | 2015-08-13 08:05:48 +0200 | [diff] [blame] | 11 | # set version |
| 12 | set(LIBYANG_MAJOR_VERSION 0) |
Michal Vasko | 27b91d0 | 2017-05-23 14:40:00 +0200 | [diff] [blame] | 13 | set(LIBYANG_MINOR_VERSION 13) |
Michal Vasko | 37159fd | 2017-07-11 14:27:01 +0200 | [diff] [blame^] | 14 | set(LIBYANG_MICRO_VERSION 26) |
Radek Krejci | 8f7cf40 | 2015-08-13 08:05:48 +0200 | [diff] [blame] | 15 | set(LIBYANG_VERSION ${LIBYANG_MAJOR_VERSION}.${LIBYANG_MINOR_VERSION}.${LIBYANG_MICRO_VERSION}) |
| 16 | set(LIBYANG_SOVERSION ${LIBYANG_MAJOR_VERSION}.${LIBYANG_MINOR_VERSION}) |
Radek Krejci | 60cdf28 | 2016-10-10 16:22:22 +0200 | [diff] [blame] | 17 | configure_file(${PROJECT_SOURCE_DIR}/src/libyang.h.in ${PROJECT_SOURCE_DIR}/src/libyang.h) |
Radek Krejci | 8f7cf40 | 2015-08-13 08:05:48 +0200 | [diff] [blame] | 18 | |
Radek Krejci | c43058d | 2017-01-04 16:29:58 +0100 | [diff] [blame] | 19 | if(PLUGINS_DIR) |
| 20 | set(LIBYANG_EXT_PLUGINS_DIR ${PLUGINS_DIR}) |
| 21 | else() |
| 22 | set(LIBYANG_EXT_PLUGINS_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libyang) |
| 23 | endif() |
Radek Krejci | 858ad95 | 2017-01-04 11:16:32 +0100 | [diff] [blame] | 24 | configure_file(${PROJECT_SOURCE_DIR}/src/extensions_config.h.in ${PROJECT_SOURCE_DIR}/src/extensions_config.h) |
| 25 | |
Michal Vasko | e4e8fbd | 2015-08-24 14:54:49 +0200 | [diff] [blame] | 26 | # include custom Modules |
Radek Krejci | 977c1c8 | 2015-09-01 15:18:03 +0200 | [diff] [blame] | 27 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMakeModules/") |
Michal Vasko | e4e8fbd | 2015-08-24 14:54:49 +0200 | [diff] [blame] | 28 | |
Pavol Vican | f7cc285 | 2016-03-22 23:27:35 +0100 | [diff] [blame] | 29 | find_package(FLEX) |
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 30 | find_package(BISON) |
PavolVican | cf74925 | 2017-06-08 09:31:49 +0200 | [diff] [blame] | 31 | find_program (DEB_BUILDER NAMES debuild) |
| 32 | find_program (RPM_BUILDER NAMES rpmbuild) |
Pavol Vican | 0a9716f | 2016-05-22 17:04:06 +0200 | [diff] [blame] | 33 | find_program (SED_TOOL NAMES sed) |
Pavol Vican | f7cc285 | 2016-03-22 23:27:35 +0100 | [diff] [blame] | 34 | |
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 35 | if(NOT BISON_FOUND) |
Radek Krejci | f19243b | 2017-02-02 09:23:40 +0100 | [diff] [blame] | 36 | message(WARNING "Missing Bison.\nYou won't be able to generate source codes from changed flex/bison files.\nCompiling libyang should still works fine.") |
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 37 | elseif (NOT FLEX_FOUND) |
Radek Krejci | f19243b | 2017-02-02 09:23:40 +0100 | [diff] [blame] | 38 | message(WARNING "Missing Flex.\nYou won't be able to generate source codes from changed flex/bison files.\nCompiling libyang should still works fine.") |
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 39 | else() |
| 40 | if (BISON_VERSION VERSION_LESS 3) |
| 41 | set(EMPTYDIR "") |
| 42 | else () |
| 43 | set(EMPTYDIR "%empty") |
| 44 | endif() |
| 45 | configure_file(${PROJECT_SOURCE_DIR}/src/yang.y.in ${PROJECT_SOURCE_DIR}/src/yang.y) |
| 46 | add_custom_target(bison |
Pavol Vican | 15bf384 | 2016-04-05 22:25:00 +0200 | [diff] [blame] | 47 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/src |
PavolVican | 22e8868 | 2017-02-14 22:38:18 +0100 | [diff] [blame] | 48 | COMMAND bison -l -o parser_yang_bis.c --defines=parser_yang_bis.h yang.y |
Pavol Vican | 6ab09d8 | 2016-10-24 11:30:02 +0200 | [diff] [blame] | 49 | COMMAND flex -8 -L -o parser_yang_lex.c --header-file=parser_yang_lex.h yang.l |
PavolVican | 1985713 | 2017-03-01 09:47:47 +0100 | [diff] [blame] | 50 | COMMAND ${SED_TOOL} -i 's/int yychar\;/int yychar\;\\nchar *s = NULL, *tmp_s = NULL, *ext_name = NULL\;\\nstruct lys_module *trg = NULL\;\\nstruct lys_node *tpdf_parent = NULL, *data_node = NULL\;\\nstruct lys_ext_instance_complex *ext_instance = NULL\;\\nint is_ext_instance\;\\nvoid *actual = NULL\;\\nenum yytokentype backup_type, actual_type = MODULE_KEYWORD\;\\nint64_t cnt_val = 0\;\\nint is_value = 0\;\\nvoid *yang_type = NULL\;/' parser_yang_bis.c |
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 51 | ) |
| 52 | endif() |
Pavol Vican | f7cc285 | 2016-03-22 23:27:35 +0100 | [diff] [blame] | 53 | |
PavolVican | 5d37752 | 2017-06-07 15:08:14 +0200 | [diff] [blame] | 54 | if (NOT DEFINED ENV{TRAVIS_BRANCH}) |
| 55 | execute_process(COMMAND "git" "rev-parse" "--abbrev-ref" "HEAD" |
| 56 | OUTPUT_VARIABLE GIT_BRANCH |
| 57 | OUTPUT_STRIP_TRAILING_WHITESPACE |
| 58 | ERROR_QUIET |
| 59 | ) |
| 60 | if (NOT GIT_BRANCH) |
| 61 | set(ENV{TRAVIS_BRANCH} "master") |
| 62 | else() |
| 63 | if (GIT_BRANCH MATCHES "master|devel") |
| 64 | set(ENV{TRAVIS_BRANCH} ${GIT_BRANCH}) |
| 65 | else() |
| 66 | set(ENV{TRAVIS_BRANCH} "master") |
| 67 | endif() |
PavolVican | 3739627 | 2017-03-25 00:57:20 +0100 | [diff] [blame] | 68 | endif() |
PavolVican | 5d37752 | 2017-06-07 15:08:14 +0200 | [diff] [blame] | 69 | set(GIT_BRANCH $ENV{TRAVIS_BRANCH}) |
PavolVican | 3739627 | 2017-03-25 00:57:20 +0100 | [diff] [blame] | 70 | endif() |
| 71 | |
PavolVican | 5d37752 | 2017-06-07 15:08:14 +0200 | [diff] [blame] | 72 | if ($ENV{TRAVIS_BRANCH} STREQUAL "master") |
| 73 | set(PACKAGE_NAME "libyang") |
| 74 | set(BRANCH "master") |
| 75 | set(BUILD_TYPE "Package") |
| 76 | set(CONFLICT_PACKAGE_NAME "libyang-experimental") |
| 77 | else () |
| 78 | set(PACKAGE_NAME "libyang-experimental") |
| 79 | set(BRANCH "devel") |
| 80 | set(BUILD_TYPE "debug") |
| 81 | set(CONFLICT_PACKAGE_NAME "libyang") |
| 82 | endif() |
| 83 | # change version in config files |
| 84 | configure_file(${PROJECT_SOURCE_DIR}/packages/libyang.spec.in ${PROJECT_BINARY_DIR}/build-packages/libyang.spec) |
| 85 | configure_file(${PROJECT_SOURCE_DIR}/packages/libyang.dsc.in ${PROJECT_BINARY_DIR}/build-packages/libyang.dsc) |
| 86 | configure_file(${PROJECT_SOURCE_DIR}/packages/debian.control.in ${PROJECT_BINARY_DIR}/build-packages/debian.control @ONLY) |
| 87 | configure_file(${PROJECT_SOURCE_DIR}/packages/debian.rules.in ${PROJECT_BINARY_DIR}/build-packages/debian.rules) |
| 88 | |
PavolVican | cf74925 | 2017-06-08 09:31:49 +0200 | [diff] [blame] | 89 | if (NOT DEB_BUILDER) |
| 90 | message(WARNING "Missing tools (devscripts, debhelper package) for building deb package.\nYou won't be able to generate deb package from source code.\nCompiling libyang should still works fine.") |
| 91 | else () |
| 92 | # target for local build deb package |
| 93 | add_custom_target(build-deb |
| 94 | WORKING_DIRECTORY ${PROJECT_BINARY_DIR} |
| 95 | COMMAND build-packages/local-deb.sh |
| 96 | ) |
| 97 | configure_file(${PROJECT_SOURCE_DIR}/packages/local-deb.sh.in ${PROJECT_BINARY_DIR}/build-packages/local-deb.sh @ONLY) |
| 98 | endif() |
PavolVican | 5d37752 | 2017-06-07 15:08:14 +0200 | [diff] [blame] | 99 | |
PavolVican | cf74925 | 2017-06-08 09:31:49 +0200 | [diff] [blame] | 100 | if (NOT RPM_BUILDER) |
| 101 | message(WARNING "Missing tools (rpm package) for building rpm package. \nYou won't be able to generate rpm package from source code.\nCompiling libyang should still works fine.") |
| 102 | else () |
| 103 | # target for local build rpm package |
| 104 | string(REPLACE ${PROJECT_SOURCE_DIR} "." EXCLUDE_BUILD_DIR ${PROJECT_BINARY_DIR}) |
| 105 | add_custom_target(build-rpm |
| 106 | WORKING_DIRECTORY ${PROJECT_BINARY_DIR} |
| 107 | COMMAND build-packages/local-rpm.sh |
| 108 | ) |
| 109 | configure_file(${PROJECT_SOURCE_DIR}/packages/local-rpm.sh.in ${PROJECT_BINARY_DIR}/build-packages/local-rpm.sh @ONLY) |
| 110 | endif() |
PavolVican | 5d37752 | 2017-06-07 15:08:14 +0200 | [diff] [blame] | 111 | |
Radek Krejci | e74ea8c | 2015-04-09 18:06:20 +0200 | [diff] [blame] | 112 | # check the supported platform |
| 113 | if(NOT UNIX) |
| 114 | message(FATAL_ERROR "Only *nix like systems are supported.") |
| 115 | endif() |
| 116 | |
Radek Krejci | e74ea8c | 2015-04-09 18:06:20 +0200 | [diff] [blame] | 117 | # set default build type if not specified by user |
| 118 | if(NOT CMAKE_BUILD_TYPE) |
| 119 | set(CMAKE_BUILD_TYPE debug) |
| 120 | endif() |
| 121 | |
Radek Krejci | c43058d | 2017-01-04 16:29:58 +0100 | [diff] [blame] | 122 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra") |
Radek Krejci | 3045cf3 | 2015-05-28 10:58:52 +0200 | [diff] [blame] | 123 | set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG") |
PavolVican | 3739627 | 2017-03-25 00:57:20 +0100 | [diff] [blame] | 124 | set(CMAKE_C_FLAGS_PACKAGE "-g -O2 -DNDEBUG") |
Radek Krejci | f19ac67 | 2016-02-05 16:16:36 +0100 | [diff] [blame] | 125 | set(CMAKE_C_FLAGS_DEBUG "-g -O0") |
Radek Krejci | e74ea8c | 2015-04-09 18:06:20 +0200 | [diff] [blame] | 126 | |
PavolVican | 3739627 | 2017-03-25 00:57:20 +0100 | [diff] [blame] | 127 | if((CMAKE_BUILD_TYPE STREQUAL debug) OR (CMAKE_BUILD_TYPE STREQUAL Package)) |
Radek Krejci | 61cd556 | 2015-10-05 14:06:34 +0200 | [diff] [blame] | 128 | option(ENABLE_BUILD_TESTS "Build tests" ON) |
| 129 | option(ENABLE_VALGRIND_TESTS "Build tests with valgrind" ON) |
| 130 | else() |
| 131 | option(ENABLE_BUILD_TESTS "Build tests" OFF) |
| 132 | option(ENABLE_VALGRIND_TESTS "Build tests with valgrind" OFF) |
| 133 | endif() |
Mislav Novakovic | 021b9a1 | 2015-10-01 20:50:21 +0200 | [diff] [blame] | 134 | |
Radek Krejci | 5a06554 | 2015-05-22 15:02:07 +0200 | [diff] [blame] | 135 | set(libsrc |
Radek Krejci | 9b4ca39 | 2015-04-10 08:31:27 +0200 | [diff] [blame] | 136 | src/common.c |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 137 | src/context.c |
Radek Krejci | 9b4ca39 | 2015-04-10 08:31:27 +0200 | [diff] [blame] | 138 | src/log.c |
Radek Krejci | ee62758 | 2015-04-20 17:39:59 +0200 | [diff] [blame] | 139 | src/dict.c |
Michal Vasko | c3d9f8c | 2015-07-31 14:37:24 +0200 | [diff] [blame] | 140 | src/resolve.c |
Radek Krejci | b1c1251 | 2015-08-11 11:22:04 +0200 | [diff] [blame] | 141 | src/validation.c |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 142 | src/xml.c |
Radek Krejci | b1c1251 | 2015-08-11 11:22:04 +0200 | [diff] [blame] | 143 | src/parser.c |
Radek Krejci | 998a0b8 | 2015-08-17 13:14:36 +0200 | [diff] [blame] | 144 | src/parser_yin.c |
| 145 | src/parser_xml.c |
Radek Krejci | 5449d47 | 2015-10-26 14:35:56 +0100 | [diff] [blame] | 146 | src/parser_json.c |
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 147 | src/parser_yang_bis.c |
| 148 | src/parser_yang_lex.c |
Pavol Vican | f7cc285 | 2016-03-22 23:27:35 +0100 | [diff] [blame] | 149 | src/parser_yang.c |
Michal Vasko | 2d162e1 | 2015-09-24 14:33:29 +0200 | [diff] [blame] | 150 | src/tree_schema.c |
| 151 | src/tree_data.c |
Radek Krejci | 0aa821a | 2016-12-08 11:21:35 +0100 | [diff] [blame] | 152 | src/extensions.c |
Radek Krejci | efdd0ce | 2015-05-26 16:48:29 +0200 | [diff] [blame] | 153 | src/printer.c |
Michal Vasko | abbdaa0 | 2015-10-06 15:47:25 +0200 | [diff] [blame] | 154 | src/xpath.c |
Radek Krejci | 998a0b8 | 2015-08-17 13:14:36 +0200 | [diff] [blame] | 155 | src/printer_yang.c |
Michal Vasko | a63ca34 | 2016-02-05 14:29:19 +0100 | [diff] [blame] | 156 | src/printer_yin.c |
Michal Vasko | 9b9e4a0 | 2015-08-21 09:11:14 +0200 | [diff] [blame] | 157 | src/printer_xml.c |
Radek Krejci | 998a0b8 | 2015-08-17 13:14:36 +0200 | [diff] [blame] | 158 | src/printer_tree.c |
| 159 | src/printer_info.c |
| 160 | src/printer_json.c |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 161 | src/yang_types.c) |
Radek Krejci | e74ea8c | 2015-04-09 18:06:20 +0200 | [diff] [blame] | 162 | |
Radek Krejci | 5a06554 | 2015-05-22 15:02:07 +0200 | [diff] [blame] | 163 | set(lintsrc |
Michal Vasko | f3e59f1 | 2015-06-18 11:53:56 +0200 | [diff] [blame] | 164 | tools/lint/main.c |
Radek Krejci | 797590b | 2016-10-10 16:23:04 +0200 | [diff] [blame] | 165 | tools/lint/main_ni.c |
Michal Vasko | f3e59f1 | 2015-06-18 11:53:56 +0200 | [diff] [blame] | 166 | tools/lint/commands.c |
Michal Vasko | e0cb252 | 2015-07-01 10:24:53 +0200 | [diff] [blame] | 167 | tools/lint/completion.c |
Michal Vasko | 203b4e7 | 2015-06-30 15:25:15 +0200 | [diff] [blame] | 168 | linenoise/linenoise.c) |
Radek Krejci | 5a06554 | 2015-05-22 15:02:07 +0200 | [diff] [blame] | 169 | |
Michal Vasko | 9a54274 | 2016-06-23 13:04:51 +0200 | [diff] [blame] | 170 | set(yang2yinsrc |
| 171 | tools/yang2yin/main.c) |
| 172 | |
Tomas Cejka | 422c007 | 2015-07-21 18:18:25 +0200 | [diff] [blame] | 173 | set(headers |
| 174 | src/libyang.h |
Michal Vasko | 2d162e1 | 2015-09-24 14:33:29 +0200 | [diff] [blame] | 175 | src/tree_schema.h |
Radek Krejci | c6704c8 | 2015-10-06 11:12:45 +0200 | [diff] [blame] | 176 | src/tree_data.h |
Radek Krejci | a1a6b76 | 2016-11-14 09:53:38 +0900 | [diff] [blame] | 177 | src/extensions.h |
Radek Krejci | 41912fe | 2015-10-22 10:22:12 +0200 | [diff] [blame] | 178 | src/xml.h |
| 179 | src/dict.h) |
Tomas Cejka | 422c007 | 2015-07-21 18:18:25 +0200 | [diff] [blame] | 180 | |
Radek Krejci | 5708fe6 | 2016-09-14 12:25:12 +0200 | [diff] [blame] | 181 | set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) |
| 182 | add_library(yangobj OBJECT ${libsrc}) |
| 183 | add_library(yang SHARED $<TARGET_OBJECTS:yangobj>) |
Radek Krejci | 8f7cf40 | 2015-08-13 08:05:48 +0200 | [diff] [blame] | 184 | set_target_properties(yang PROPERTIES VERSION ${LIBYANG_VERSION} SOVERSION ${LIBYANG_SOVERSION}) |
Radek Krejci | c43058d | 2017-01-04 16:29:58 +0100 | [diff] [blame] | 185 | set_target_properties(yang PROPERTIES COMPILE_FLAGS "-fvisibility=hidden") |
Michal Vasko | e4e8fbd | 2015-08-24 14:54:49 +0200 | [diff] [blame] | 186 | |
Radek Krejci | 89658b3 | 2016-02-08 11:14:46 +0100 | [diff] [blame] | 187 | # link math |
| 188 | target_link_libraries(yang m) |
| 189 | |
Radek Krejci | 858ad95 | 2017-01-04 11:16:32 +0100 | [diff] [blame] | 190 | #link dl |
| 191 | target_link_libraries(yang ${CMAKE_DL_LIBS}) |
| 192 | |
Radek Krejci | 7d9f46a | 2016-01-29 13:53:18 +0100 | [diff] [blame] | 193 | # find pthreads |
| 194 | set(CMAKE_THREAD_PREFER_PTHREAD TRUE) |
| 195 | find_package(Threads REQUIRED) |
| 196 | target_link_libraries(yang ${CMAKE_THREAD_LIBS_INIT}) |
| 197 | |
Michal Vasko | e4e8fbd | 2015-08-24 14:54:49 +0200 | [diff] [blame] | 198 | # find PCRE library |
| 199 | find_package(PCRE REQUIRED) |
| 200 | include_directories(${PCRE_INCLUDE_DIRS}) |
Radek Krejci | 1d949ec | 2015-10-02 13:35:05 +0200 | [diff] [blame] | 201 | target_link_libraries(yang ${PCRE_LIBRARIES}) |
Radek Krejci | e74ea8c | 2015-04-09 18:06:20 +0200 | [diff] [blame] | 202 | |
Jan Kundrát | bffd9e4 | 2016-11-04 16:33:49 +0100 | [diff] [blame] | 203 | install(TARGETS yang DESTINATION ${CMAKE_INSTALL_LIBDIR}) |
| 204 | install(FILES ${headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libyang) |
Radek Krejci | e74ea8c | 2015-04-09 18:06:20 +0200 | [diff] [blame] | 205 | |
Michal Vasko | e5cf992 | 2015-11-11 11:06:40 +0100 | [diff] [blame] | 206 | find_package(PkgConfig) |
| 207 | if(PKG_CONFIG_FOUND) |
| 208 | # generate and install pkg-config file |
| 209 | configure_file("libyang.pc.in" "libyang.pc" @ONLY) |
Jan Kundrát | bffd9e4 | 2016-11-04 16:33:49 +0100 | [diff] [blame] | 210 | install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libyang.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") |
Michal Vasko | 98ae1e1 | 2015-12-15 11:11:28 +0100 | [diff] [blame] | 211 | # check that pkg-config includes the used path |
| 212 | execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable pc_path pkg-config RESULT_VARIABLE RETURN OUTPUT_VARIABLE PC_PATH ERROR_QUIET) |
| 213 | if(RETURN EQUAL 0) |
Jan Kundrát | bffd9e4 | 2016-11-04 16:33:49 +0100 | [diff] [blame] | 214 | string(REGEX MATCH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/pkgconfig" SUBSTR "${PC_PATH}") |
Michal Vasko | 33c001c | 2016-02-11 09:01:52 +0100 | [diff] [blame] | 215 | string(LENGTH "${SUBSTR}" SUBSTR_LEN) |
Michal Vasko | b8d90a3 | 2016-02-09 13:59:42 +0100 | [diff] [blame] | 216 | if(SUBSTR_LEN EQUAL 0) |
Jan Kundrát | bffd9e4 | 2016-11-04 16:33:49 +0100 | [diff] [blame] | 217 | message(WARNING "pkg-config will not detect the new package after installation, adjust PKG_CONFIG_PATH using \"export PKG_CONFIG_PATH=\${PKG_CONFIG_PATH}:${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/pkgconfig\".") |
Michal Vasko | 98ae1e1 | 2015-12-15 11:11:28 +0100 | [diff] [blame] | 218 | endif() |
| 219 | endif() |
Michal Vasko | e5cf992 | 2015-11-11 11:06:40 +0100 | [diff] [blame] | 220 | endif() |
| 221 | |
Radek Krejci | e74ea8c | 2015-04-09 18:06:20 +0200 | [diff] [blame] | 222 | # generate doxygen documentation for libyang API |
Radek Krejci | e262609 | 2015-10-08 11:25:44 +0200 | [diff] [blame] | 223 | find_package(Doxygen) |
| 224 | if(DOXYGEN_FOUND) |
| 225 | set(DOXYGEN_SKIP_DOT TRUE) |
| 226 | add_custom_target(doc |
| 227 | COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile |
| 228 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) |
| 229 | configure_file(Doxyfile.in Doxyfile) |
| 230 | endif() |
Radek Krejci | e74ea8c | 2015-04-09 18:06:20 +0200 | [diff] [blame] | 231 | |
| 232 | # clean cmake cache |
| 233 | add_custom_target(cclean |
Radek Krejci | 25155ac | 2015-10-08 11:26:20 +0200 | [diff] [blame] | 234 | COMMAND make clean |
| 235 | COMMAND find . -iname '*cmake*' -not -name CMakeLists.txt -not -path './CMakeModules*' -exec rm -rf {} + |
| 236 | COMMAND rm -rf Makefile Doxyfile |
| 237 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) |
Radek Krejci | 2cb3054 | 2015-04-10 08:33:57 +0200 | [diff] [blame] | 238 | |
Radek Krejci | c43058d | 2017-01-04 16:29:58 +0100 | [diff] [blame] | 239 | # YANG extensions plugins |
| 240 | add_subdirectory(src/extensions) |
| 241 | |
| 242 | # yanglint |
Radek Krejci | 5a06554 | 2015-05-22 15:02:07 +0200 | [diff] [blame] | 243 | add_executable(yanglint ${lintsrc}) |
Radek Krejci | 40dcad2 | 2017-06-08 11:35:32 +0200 | [diff] [blame] | 244 | target_link_libraries(yanglint yang) |
Jan Kundrát | bffd9e4 | 2016-11-04 16:33:49 +0100 | [diff] [blame] | 245 | install(TARGETS yanglint DESTINATION ${CMAKE_INSTALL_BINDIR}) |
| 246 | install(FILES ${PROJECT_SOURCE_DIR}/tools/lint/yanglint.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) |
Radek Krejci | 5a06554 | 2015-05-22 15:02:07 +0200 | [diff] [blame] | 247 | |
Radek Krejci | c43058d | 2017-01-04 16:29:58 +0100 | [diff] [blame] | 248 | # yang2yin |
Michal Vasko | 9a54274 | 2016-06-23 13:04:51 +0200 | [diff] [blame] | 249 | add_executable(yang2yin ${yang2yinsrc}) |
| 250 | |
Mislav Novakovic | 021b9a1 | 2015-10-01 20:50:21 +0200 | [diff] [blame] | 251 | if(ENABLE_VALGRIND_TESTS) |
| 252 | set(ENABLE_BUILD_TESTS ON) |
| 253 | endif() |
| 254 | |
| 255 | if(ENABLE_BUILD_TESTS) |
Radek Krejci | e02ce0a | 2015-11-04 14:14:20 +0100 | [diff] [blame] | 256 | find_package(CMocka 1.0.0) |
| 257 | if(CMOCKA_FOUND) |
| 258 | enable_testing() |
| 259 | add_subdirectory(tests) |
| 260 | endif(CMOCKA_FOUND) |
| 261 | endif(ENABLE_BUILD_TESTS) |
Mislav Novakovic | a827b5f | 2016-02-29 11:47:22 +0100 | [diff] [blame] | 262 | |
| 263 | if(JAVASCRIPT_BINDING) |
| 264 | include(swig/javascript/CMakeLists.txt) |
| 265 | endif() |