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) |
Radek Krejci | e07cd06 | 2017-09-22 13:21:02 +0200 | [diff] [blame] | 13 | set(LIBYANG_MINOR_VERSION 14) |
Michal Vasko | 6a9c1fb | 2017-09-26 10:31:25 +0200 | [diff] [blame] | 14 | set(LIBYANG_MICRO_VERSION 6) |
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}) |
Michal Vasko | fcd974b | 2017-08-22 10:17:49 +0200 | [diff] [blame] | 17 | |
Michal Vasko | 8f3160e | 2017-09-27 11:25:26 +0200 | [diff] [blame^] | 18 | # set default build type if not specified by user |
| 19 | if(NOT CMAKE_BUILD_TYPE) |
| 20 | set(CMAKE_BUILD_TYPE debug) |
| 21 | endif() |
| 22 | |
| 23 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra") |
| 24 | set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG") |
| 25 | set(CMAKE_C_FLAGS_PACKAGE "-g -O2 -DNDEBUG") |
| 26 | set(CMAKE_C_FLAGS_DEBUG "-g -O0") |
| 27 | |
| 28 | # options |
| 29 | if((CMAKE_BUILD_TYPE STREQUAL debug) OR (CMAKE_BUILD_TYPE STREQUAL Package)) |
| 30 | option(ENABLE_BUILD_TESTS "Build tests" ON) |
| 31 | option(ENABLE_VALGRIND_TESTS "Build tests with valgrind" ON) |
| 32 | else() |
| 33 | option(ENABLE_BUILD_TESTS "Build tests" OFF) |
| 34 | option(ENABLE_VALGRIND_TESTS "Build tests with valgrind" OFF) |
| 35 | endif() |
| 36 | option(ENABLE_LATEST_REVISIONS "Enable reusing of latest revisions of schemas" ON) |
| 37 | option(ENABLE_CACHE "Enable data caching for schemas (time-efficient at the cost of increased space-complexity)" OFF) |
| 38 | |
| 39 | if (ENABLE_LATEST_REVISIONS) |
| 40 | set(ENABLE_LATEST_REVISIONS_MACRO "/**\n * @brief Latest revisions of loaded schemas will be reused.\n */\n#define LY_ENABLED_LATEST_REVISIONS") |
| 41 | else() |
| 42 | set(ENABLE_LATEST_REVISIONS_MACRO "/**\n * @brief Latest revisions of loaded schemas will not be reused and always reloaded.\n */") |
| 43 | endif() |
| 44 | |
Michal Vasko | fcd974b | 2017-08-22 10:17:49 +0200 | [diff] [blame] | 45 | if(ENABLE_CACHE) |
| 46 | set(ENABLE_CACHE_MACRO "/**\n * @brief Cache of some temporary information will be used.\n */\n#define LY_ENABLED_CACHE") |
| 47 | else() |
| 48 | set(ENABLE_CACHE_MACRO "/**\n * @brief Cache of some temporary information will not be used.\n */") |
| 49 | endif() |
| 50 | |
| 51 | configure_file(${PROJECT_SOURCE_DIR}/src/libyang.h.in ${PROJECT_SOURCE_DIR}/src/libyang.h @ONLY) |
Radek Krejci | 8f7cf40 | 2015-08-13 08:05:48 +0200 | [diff] [blame] | 52 | |
Radek Krejci | c43058d | 2017-01-04 16:29:58 +0100 | [diff] [blame] | 53 | if(PLUGINS_DIR) |
Michal Vasko | 8f3160e | 2017-09-27 11:25:26 +0200 | [diff] [blame^] | 54 | set(LIBYANG_EXT_PLUGINS_DIR ${PLUGINS_DIR}) |
Radek Krejci | c43058d | 2017-01-04 16:29:58 +0100 | [diff] [blame] | 55 | else() |
Michal Vasko | 8f3160e | 2017-09-27 11:25:26 +0200 | [diff] [blame^] | 56 | set(LIBYANG_EXT_PLUGINS_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libyang) |
Radek Krejci | c43058d | 2017-01-04 16:29:58 +0100 | [diff] [blame] | 57 | endif() |
Radek Krejci | 858ad95 | 2017-01-04 11:16:32 +0100 | [diff] [blame] | 58 | configure_file(${PROJECT_SOURCE_DIR}/src/extensions_config.h.in ${PROJECT_SOURCE_DIR}/src/extensions_config.h) |
| 59 | |
Michal Vasko | e4e8fbd | 2015-08-24 14:54:49 +0200 | [diff] [blame] | 60 | # include custom Modules |
Radek Krejci | 977c1c8 | 2015-09-01 15:18:03 +0200 | [diff] [blame] | 61 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMakeModules/") |
Michal Vasko | e4e8fbd | 2015-08-24 14:54:49 +0200 | [diff] [blame] | 62 | |
Pavol Vican | f7cc285 | 2016-03-22 23:27:35 +0100 | [diff] [blame] | 63 | find_package(FLEX) |
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 64 | find_package(BISON) |
PavolVican | cf74925 | 2017-06-08 09:31:49 +0200 | [diff] [blame] | 65 | find_program (DEB_BUILDER NAMES debuild) |
| 66 | find_program (RPM_BUILDER NAMES rpmbuild) |
Pavol Vican | 0a9716f | 2016-05-22 17:04:06 +0200 | [diff] [blame] | 67 | find_program (SED_TOOL NAMES sed) |
Pavol Vican | f7cc285 | 2016-03-22 23:27:35 +0100 | [diff] [blame] | 68 | |
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 69 | if(NOT BISON_FOUND) |
Michal Vasko | 8f3160e | 2017-09-27 11:25:26 +0200 | [diff] [blame^] | 70 | 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] | 71 | elseif (NOT FLEX_FOUND) |
Michal Vasko | 8f3160e | 2017-09-27 11:25:26 +0200 | [diff] [blame^] | 72 | 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] | 73 | else() |
Michal Vasko | 8f3160e | 2017-09-27 11:25:26 +0200 | [diff] [blame^] | 74 | if (BISON_VERSION VERSION_LESS 3) |
| 75 | set(EMPTYDIR "") |
| 76 | else () |
| 77 | set(EMPTYDIR "%empty") |
| 78 | endif() |
| 79 | configure_file(${PROJECT_SOURCE_DIR}/src/yang.y.in ${PROJECT_SOURCE_DIR}/src/yang.y) |
| 80 | add_custom_target(bison |
| 81 | WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/src |
| 82 | COMMAND bison -l -o parser_yang_bis.c --defines=parser_yang_bis.h yang.y |
| 83 | COMMAND flex -8 -L -o parser_yang_lex.c --header-file=parser_yang_lex.h yang.l |
| 84 | 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 |
| 85 | ) |
Pavol Vican | cae5488 | 2016-03-30 12:24:43 +0200 | [diff] [blame] | 86 | endif() |
Pavol Vican | f7cc285 | 2016-03-22 23:27:35 +0100 | [diff] [blame] | 87 | |
PavolVican | 5d37752 | 2017-06-07 15:08:14 +0200 | [diff] [blame] | 88 | if (NOT DEFINED ENV{TRAVIS_BRANCH}) |
Michal Vasko | 8f3160e | 2017-09-27 11:25:26 +0200 | [diff] [blame^] | 89 | execute_process(COMMAND "git" "rev-parse" "--abbrev-ref" "HEAD" |
| 90 | OUTPUT_VARIABLE GIT_BRANCH |
| 91 | OUTPUT_STRIP_TRAILING_WHITESPACE |
| 92 | ERROR_QUIET |
| 93 | ) |
| 94 | if (NOT GIT_BRANCH) |
| 95 | set(ENV{TRAVIS_BRANCH} "master") |
| 96 | else() |
| 97 | if (GIT_BRANCH MATCHES "master|devel") |
| 98 | set(ENV{TRAVIS_BRANCH} ${GIT_BRANCH}) |
| 99 | else() |
| 100 | set(ENV{TRAVIS_BRANCH} "master") |
| 101 | endif() |
| 102 | endif() |
| 103 | set(GIT_BRANCH $ENV{TRAVIS_BRANCH}) |
PavolVican | 3739627 | 2017-03-25 00:57:20 +0100 | [diff] [blame] | 104 | endif() |
| 105 | |
PavolVican | 5d37752 | 2017-06-07 15:08:14 +0200 | [diff] [blame] | 106 | if ($ENV{TRAVIS_BRANCH} STREQUAL "master") |
Michal Vasko | 8f3160e | 2017-09-27 11:25:26 +0200 | [diff] [blame^] | 107 | set(PACKAGE_NAME "libyang") |
| 108 | set(BRANCH "master") |
| 109 | set(BUILD_TYPE "Package") |
| 110 | set(CONFLICT_PACKAGE_NAME "libyang-experimental") |
PavolVican | 5d37752 | 2017-06-07 15:08:14 +0200 | [diff] [blame] | 111 | else () |
Michal Vasko | 8f3160e | 2017-09-27 11:25:26 +0200 | [diff] [blame^] | 112 | set(PACKAGE_NAME "libyang-experimental") |
| 113 | set(BRANCH "devel") |
| 114 | set(BUILD_TYPE "debug") |
| 115 | set(CONFLICT_PACKAGE_NAME "libyang") |
PavolVican | 5d37752 | 2017-06-07 15:08:14 +0200 | [diff] [blame] | 116 | endif() |
| 117 | # change version in config files |
| 118 | configure_file(${PROJECT_SOURCE_DIR}/packages/libyang.spec.in ${PROJECT_BINARY_DIR}/build-packages/libyang.spec) |
| 119 | configure_file(${PROJECT_SOURCE_DIR}/packages/libyang.dsc.in ${PROJECT_BINARY_DIR}/build-packages/libyang.dsc) |
| 120 | configure_file(${PROJECT_SOURCE_DIR}/packages/debian.control.in ${PROJECT_BINARY_DIR}/build-packages/debian.control @ONLY) |
| 121 | configure_file(${PROJECT_SOURCE_DIR}/packages/debian.rules.in ${PROJECT_BINARY_DIR}/build-packages/debian.rules) |
| 122 | |
PavolVican | cf74925 | 2017-06-08 09:31:49 +0200 | [diff] [blame] | 123 | if (NOT DEB_BUILDER) |
Michal Vasko | 8f3160e | 2017-09-27 11:25:26 +0200 | [diff] [blame^] | 124 | 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.") |
PavolVican | cf74925 | 2017-06-08 09:31:49 +0200 | [diff] [blame] | 125 | else () |
Michal Vasko | 8f3160e | 2017-09-27 11:25:26 +0200 | [diff] [blame^] | 126 | # target for local build deb package |
| 127 | add_custom_target(build-deb |
| 128 | WORKING_DIRECTORY ${PROJECT_BINARY_DIR} |
| 129 | COMMAND build-packages/local-deb.sh |
| 130 | ) |
| 131 | configure_file(${PROJECT_SOURCE_DIR}/packages/local-deb.sh.in ${PROJECT_BINARY_DIR}/build-packages/local-deb.sh @ONLY) |
PavolVican | cf74925 | 2017-06-08 09:31:49 +0200 | [diff] [blame] | 132 | endif() |
PavolVican | 5d37752 | 2017-06-07 15:08:14 +0200 | [diff] [blame] | 133 | |
PavolVican | cf74925 | 2017-06-08 09:31:49 +0200 | [diff] [blame] | 134 | if (NOT RPM_BUILDER) |
Michal Vasko | 8f3160e | 2017-09-27 11:25:26 +0200 | [diff] [blame^] | 135 | 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.") |
PavolVican | cf74925 | 2017-06-08 09:31:49 +0200 | [diff] [blame] | 136 | else () |
Michal Vasko | 8f3160e | 2017-09-27 11:25:26 +0200 | [diff] [blame^] | 137 | # target for local build rpm package |
| 138 | string(REPLACE ${PROJECT_SOURCE_DIR} "." EXCLUDE_BUILD_DIR ${PROJECT_BINARY_DIR}) |
| 139 | add_custom_target(build-rpm |
| 140 | WORKING_DIRECTORY ${PROJECT_BINARY_DIR} |
| 141 | COMMAND build-packages/local-rpm.sh |
| 142 | ) |
| 143 | configure_file(${PROJECT_SOURCE_DIR}/packages/local-rpm.sh.in ${PROJECT_BINARY_DIR}/build-packages/local-rpm.sh @ONLY) |
PavolVican | cf74925 | 2017-06-08 09:31:49 +0200 | [diff] [blame] | 144 | endif() |
PavolVican | 5d37752 | 2017-06-07 15:08:14 +0200 | [diff] [blame] | 145 | |
Radek Krejci | e74ea8c | 2015-04-09 18:06:20 +0200 | [diff] [blame] | 146 | # check the supported platform |
| 147 | if(NOT UNIX) |
Michal Vasko | 8f3160e | 2017-09-27 11:25:26 +0200 | [diff] [blame^] | 148 | message(FATAL_ERROR "Only *nix like systems are supported.") |
Radek Krejci | 61cd556 | 2015-10-05 14:06:34 +0200 | [diff] [blame] | 149 | endif() |
Mislav Novakovic | 021b9a1 | 2015-10-01 20:50:21 +0200 | [diff] [blame] | 150 | |
Radek Krejci | 5a06554 | 2015-05-22 15:02:07 +0200 | [diff] [blame] | 151 | set(libsrc |
Michal Vasko | 8f3160e | 2017-09-27 11:25:26 +0200 | [diff] [blame^] | 152 | src/common.c |
| 153 | src/context.c |
| 154 | src/log.c |
| 155 | src/dict.c |
| 156 | src/resolve.c |
| 157 | src/validation.c |
| 158 | src/xml.c |
| 159 | src/parser.c |
| 160 | src/parser_yin.c |
| 161 | src/parser_xml.c |
| 162 | src/parser_json.c |
| 163 | src/parser_yang_bis.c |
| 164 | src/parser_yang_lex.c |
| 165 | src/parser_yang.c |
| 166 | src/tree_schema.c |
| 167 | src/tree_data.c |
| 168 | src/extensions.c |
| 169 | src/printer.c |
| 170 | src/xpath.c |
| 171 | src/printer_yang.c |
| 172 | src/printer_yin.c |
| 173 | src/printer_xml.c |
| 174 | src/printer_tree.c |
| 175 | src/printer_info.c |
| 176 | src/printer_json.c |
| 177 | src/yang_types.c) |
Radek Krejci | e74ea8c | 2015-04-09 18:06:20 +0200 | [diff] [blame] | 178 | |
Radek Krejci | 5a06554 | 2015-05-22 15:02:07 +0200 | [diff] [blame] | 179 | set(lintsrc |
Michal Vasko | 8f3160e | 2017-09-27 11:25:26 +0200 | [diff] [blame^] | 180 | tools/lint/main.c |
| 181 | tools/lint/main_ni.c |
| 182 | tools/lint/commands.c |
| 183 | tools/lint/completion.c |
| 184 | tools/lint/configuration.c |
| 185 | linenoise/linenoise.c) |
Radek Krejci | 5a06554 | 2015-05-22 15:02:07 +0200 | [diff] [blame] | 186 | |
Radek Krejci | b4a481c | 2017-07-12 15:12:34 +0200 | [diff] [blame] | 187 | set(resrc |
Michal Vasko | 8f3160e | 2017-09-27 11:25:26 +0200 | [diff] [blame^] | 188 | tools/re/main.c) |
Radek Krejci | b4a481c | 2017-07-12 15:12:34 +0200 | [diff] [blame] | 189 | |
Michal Vasko | 9a54274 | 2016-06-23 13:04:51 +0200 | [diff] [blame] | 190 | set(yang2yinsrc |
Michal Vasko | 8f3160e | 2017-09-27 11:25:26 +0200 | [diff] [blame^] | 191 | tools/yang2yin/main.c) |
Michal Vasko | 9a54274 | 2016-06-23 13:04:51 +0200 | [diff] [blame] | 192 | |
Tomas Cejka | 422c007 | 2015-07-21 18:18:25 +0200 | [diff] [blame] | 193 | set(headers |
Michal Vasko | 8f3160e | 2017-09-27 11:25:26 +0200 | [diff] [blame^] | 194 | src/libyang.h |
| 195 | src/tree_schema.h |
| 196 | src/tree_data.h |
| 197 | src/extensions.h |
| 198 | src/xml.h |
| 199 | src/dict.h) |
Tomas Cejka | 422c007 | 2015-07-21 18:18:25 +0200 | [diff] [blame] | 200 | |
Radek Krejci | 5708fe6 | 2016-09-14 12:25:12 +0200 | [diff] [blame] | 201 | set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) |
| 202 | add_library(yangobj OBJECT ${libsrc}) |
| 203 | add_library(yang SHARED $<TARGET_OBJECTS:yangobj>) |
Radek Krejci | 8f7cf40 | 2015-08-13 08:05:48 +0200 | [diff] [blame] | 204 | set_target_properties(yang PROPERTIES VERSION ${LIBYANG_VERSION} SOVERSION ${LIBYANG_SOVERSION}) |
Radek Krejci | c43058d | 2017-01-04 16:29:58 +0100 | [diff] [blame] | 205 | set_target_properties(yang PROPERTIES COMPILE_FLAGS "-fvisibility=hidden") |
Michal Vasko | e4e8fbd | 2015-08-24 14:54:49 +0200 | [diff] [blame] | 206 | |
Radek Krejci | 89658b3 | 2016-02-08 11:14:46 +0100 | [diff] [blame] | 207 | # link math |
| 208 | target_link_libraries(yang m) |
| 209 | |
Radek Krejci | 858ad95 | 2017-01-04 11:16:32 +0100 | [diff] [blame] | 210 | #link dl |
| 211 | target_link_libraries(yang ${CMAKE_DL_LIBS}) |
| 212 | |
Radek Krejci | 7d9f46a | 2016-01-29 13:53:18 +0100 | [diff] [blame] | 213 | # find pthreads |
| 214 | set(CMAKE_THREAD_PREFER_PTHREAD TRUE) |
| 215 | find_package(Threads REQUIRED) |
| 216 | target_link_libraries(yang ${CMAKE_THREAD_LIBS_INIT}) |
| 217 | |
Michal Vasko | e4e8fbd | 2015-08-24 14:54:49 +0200 | [diff] [blame] | 218 | # find PCRE library |
| 219 | find_package(PCRE REQUIRED) |
| 220 | include_directories(${PCRE_INCLUDE_DIRS}) |
Radek Krejci | 1d949ec | 2015-10-02 13:35:05 +0200 | [diff] [blame] | 221 | target_link_libraries(yang ${PCRE_LIBRARIES}) |
Radek Krejci | e74ea8c | 2015-04-09 18:06:20 +0200 | [diff] [blame] | 222 | |
Jan Kundrát | bffd9e4 | 2016-11-04 16:33:49 +0100 | [diff] [blame] | 223 | install(TARGETS yang DESTINATION ${CMAKE_INSTALL_LIBDIR}) |
| 224 | install(FILES ${headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libyang) |
Radek Krejci | e74ea8c | 2015-04-09 18:06:20 +0200 | [diff] [blame] | 225 | |
Michal Vasko | e5cf992 | 2015-11-11 11:06:40 +0100 | [diff] [blame] | 226 | find_package(PkgConfig) |
| 227 | if(PKG_CONFIG_FOUND) |
Michal Vasko | 8f3160e | 2017-09-27 11:25:26 +0200 | [diff] [blame^] | 228 | # generate and install pkg-config file |
| 229 | configure_file("libyang.pc.in" "libyang.pc" @ONLY) |
| 230 | install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libyang.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") |
| 231 | # check that pkg-config includes the used path |
| 232 | execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable pc_path pkg-config RESULT_VARIABLE RETURN OUTPUT_VARIABLE PC_PATH ERROR_QUIET) |
| 233 | if(RETURN EQUAL 0) |
| 234 | string(REGEX MATCH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/pkgconfig" SUBSTR "${PC_PATH}") |
| 235 | string(LENGTH "${SUBSTR}" SUBSTR_LEN) |
| 236 | if(SUBSTR_LEN EQUAL 0) |
| 237 | 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\".") |
| 238 | endif() |
| 239 | endif() |
Michal Vasko | e5cf992 | 2015-11-11 11:06:40 +0100 | [diff] [blame] | 240 | endif() |
| 241 | |
Radek Krejci | e74ea8c | 2015-04-09 18:06:20 +0200 | [diff] [blame] | 242 | # generate doxygen documentation for libyang API |
Radek Krejci | e262609 | 2015-10-08 11:25:44 +0200 | [diff] [blame] | 243 | find_package(Doxygen) |
| 244 | if(DOXYGEN_FOUND) |
Michal Vasko | 8f3160e | 2017-09-27 11:25:26 +0200 | [diff] [blame^] | 245 | set(DOXYGEN_SKIP_DOT TRUE) |
| 246 | add_custom_target(doc |
| 247 | COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile |
| 248 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) |
| 249 | configure_file(Doxyfile.in Doxyfile) |
Radek Krejci | e262609 | 2015-10-08 11:25:44 +0200 | [diff] [blame] | 250 | endif() |
Radek Krejci | e74ea8c | 2015-04-09 18:06:20 +0200 | [diff] [blame] | 251 | |
| 252 | # clean cmake cache |
| 253 | add_custom_target(cclean |
Michal Vasko | 8f3160e | 2017-09-27 11:25:26 +0200 | [diff] [blame^] | 254 | COMMAND make clean |
| 255 | COMMAND find . -iname '*cmake*' -not -name CMakeLists.txt -not -path './CMakeModules*' -exec rm -rf {} + |
| 256 | COMMAND rm -rf Makefile Doxyfile |
| 257 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) |
Radek Krejci | 2cb3054 | 2015-04-10 08:33:57 +0200 | [diff] [blame] | 258 | |
Radek Krejci | c43058d | 2017-01-04 16:29:58 +0100 | [diff] [blame] | 259 | # YANG extensions plugins |
| 260 | add_subdirectory(src/extensions) |
| 261 | |
| 262 | # yanglint |
Radek Krejci | 5a06554 | 2015-05-22 15:02:07 +0200 | [diff] [blame] | 263 | add_executable(yanglint ${lintsrc}) |
Radek Krejci | 40dcad2 | 2017-06-08 11:35:32 +0200 | [diff] [blame] | 264 | target_link_libraries(yanglint yang) |
Jan Kundrát | bffd9e4 | 2016-11-04 16:33:49 +0100 | [diff] [blame] | 265 | install(TARGETS yanglint DESTINATION ${CMAKE_INSTALL_BINDIR}) |
| 266 | 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] | 267 | |
Radek Krejci | b4a481c | 2017-07-12 15:12:34 +0200 | [diff] [blame] | 268 | #yangre |
| 269 | add_executable(yangre ${resrc}) |
| 270 | target_link_libraries(yangre yang) |
| 271 | install(TARGETS yangre DESTINATION ${CMAKE_INSTALL_BINDIR}) |
| 272 | |
Radek Krejci | c43058d | 2017-01-04 16:29:58 +0100 | [diff] [blame] | 273 | # yang2yin |
Michal Vasko | 9a54274 | 2016-06-23 13:04:51 +0200 | [diff] [blame] | 274 | add_executable(yang2yin ${yang2yinsrc}) |
| 275 | |
Mislav Novakovic | 021b9a1 | 2015-10-01 20:50:21 +0200 | [diff] [blame] | 276 | if(ENABLE_VALGRIND_TESTS) |
Michal Vasko | 8f3160e | 2017-09-27 11:25:26 +0200 | [diff] [blame^] | 277 | set(ENABLE_BUILD_TESTS ON) |
Mislav Novakovic | 021b9a1 | 2015-10-01 20:50:21 +0200 | [diff] [blame] | 278 | endif() |
| 279 | |
| 280 | if(ENABLE_BUILD_TESTS) |
Michal Vasko | 8f3160e | 2017-09-27 11:25:26 +0200 | [diff] [blame^] | 281 | find_package(CMocka 1.0.0) |
| 282 | if(CMOCKA_FOUND) |
| 283 | enable_testing() |
| 284 | add_subdirectory(tests) |
| 285 | endif(CMOCKA_FOUND) |
Radek Krejci | e02ce0a | 2015-11-04 14:14:20 +0100 | [diff] [blame] | 286 | endif(ENABLE_BUILD_TESTS) |
Mislav Novakovic | a827b5f | 2016-02-29 11:47:22 +0100 | [diff] [blame] | 287 | |
| 288 | if(JAVASCRIPT_BINDING) |
Michal Vasko | 8f3160e | 2017-09-27 11:25:26 +0200 | [diff] [blame^] | 289 | include(swig/javascript/CMakeLists.txt) |
Mislav Novakovic | a827b5f | 2016-02-29 11:47:22 +0100 | [diff] [blame] | 290 | endif() |