Radek Krejci | e74ea8c | 2015-04-09 18:06:20 +0200 | [diff] [blame] | 1 | cmake_minimum_required(VERSION 2.6) |
| 2 | project(libyang C) |
| 3 | |
Radek Krejci | 8f7cf40 | 2015-08-13 08:05:48 +0200 | [diff] [blame] | 4 | # set version |
| 5 | set(LIBYANG_MAJOR_VERSION 0) |
Radek Krejci | d66c778 | 2015-08-17 10:25:06 +0200 | [diff] [blame] | 6 | set(LIBYANG_MINOR_VERSION 2) |
Michal Vasko | 813f9a3 | 2015-09-24 13:56:48 +0200 | [diff] [blame] | 7 | set(LIBYANG_MICRO_VERSION 27) |
Radek Krejci | 8f7cf40 | 2015-08-13 08:05:48 +0200 | [diff] [blame] | 8 | set(LIBYANG_VERSION ${LIBYANG_MAJOR_VERSION}.${LIBYANG_MINOR_VERSION}.${LIBYANG_MICRO_VERSION}) |
| 9 | set(LIBYANG_SOVERSION ${LIBYANG_MAJOR_VERSION}.${LIBYANG_MINOR_VERSION}) |
| 10 | |
Michal Vasko | e4e8fbd | 2015-08-24 14:54:49 +0200 | [diff] [blame] | 11 | # include custom Modules |
Radek Krejci | 977c1c8 | 2015-09-01 15:18:03 +0200 | [diff] [blame] | 12 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMakeModules/") |
Michal Vasko | e4e8fbd | 2015-08-24 14:54:49 +0200 | [diff] [blame] | 13 | |
Radek Krejci | e74ea8c | 2015-04-09 18:06:20 +0200 | [diff] [blame] | 14 | # check the supported platform |
| 15 | if(NOT UNIX) |
| 16 | message(FATAL_ERROR "Only *nix like systems are supported.") |
| 17 | endif() |
| 18 | |
| 19 | if(NOT LIB_INSTALL_DIR) |
| 20 | set(LIB_INSTALL_DIR lib) |
| 21 | endif() |
| 22 | |
Tomas Cejka | 422c007 | 2015-07-21 18:18:25 +0200 | [diff] [blame] | 23 | if(NOT INCLUDE_INSTALL_DIR) |
| 24 | set(INCLUDE_INSTALL_DIR include/libyang) |
| 25 | endif() |
| 26 | |
Radek Krejci | e74ea8c | 2015-04-09 18:06:20 +0200 | [diff] [blame] | 27 | # set default build type if not specified by user |
| 28 | if(NOT CMAKE_BUILD_TYPE) |
| 29 | set(CMAKE_BUILD_TYPE debug) |
| 30 | endif() |
| 31 | |
Radek Krejci | 2cb3054 | 2015-04-10 08:33:57 +0200 | [diff] [blame] | 32 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -fvisibility=hidden") |
Radek Krejci | 3045cf3 | 2015-05-28 10:58:52 +0200 | [diff] [blame] | 33 | set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG") |
Radek Krejci | e74ea8c | 2015-04-09 18:06:20 +0200 | [diff] [blame] | 34 | set(CMAKE_C_FLAGS_DEBUG "-g -O0") |
| 35 | |
Radek Krejci | 5a06554 | 2015-05-22 15:02:07 +0200 | [diff] [blame] | 36 | set(libsrc |
Radek Krejci | 9b4ca39 | 2015-04-10 08:31:27 +0200 | [diff] [blame] | 37 | src/common.c |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 38 | src/context.c |
Radek Krejci | 9b4ca39 | 2015-04-10 08:31:27 +0200 | [diff] [blame] | 39 | src/log.c |
Radek Krejci | ee62758 | 2015-04-20 17:39:59 +0200 | [diff] [blame] | 40 | src/dict.c |
Michal Vasko | c3d9f8c | 2015-07-31 14:37:24 +0200 | [diff] [blame] | 41 | src/resolve.c |
Radek Krejci | b1c1251 | 2015-08-11 11:22:04 +0200 | [diff] [blame] | 42 | src/validation.c |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 43 | src/xml.c |
Radek Krejci | b1c1251 | 2015-08-11 11:22:04 +0200 | [diff] [blame] | 44 | src/parser.c |
Radek Krejci | 998a0b8 | 2015-08-17 13:14:36 +0200 | [diff] [blame] | 45 | src/parser_yin.c |
| 46 | src/parser_xml.c |
Michal Vasko | 2d162e1 | 2015-09-24 14:33:29 +0200 | [diff] [blame^] | 47 | src/tree_schema.c |
| 48 | src/tree_data.c |
Radek Krejci | efdd0ce | 2015-05-26 16:48:29 +0200 | [diff] [blame] | 49 | src/printer.c |
Michal Vasko | 5895397 | 2015-07-31 14:53:05 +0200 | [diff] [blame] | 50 | src/yang_library.c |
Radek Krejci | 998a0b8 | 2015-08-17 13:14:36 +0200 | [diff] [blame] | 51 | src/printer_yang.c |
Michal Vasko | 9b9e4a0 | 2015-08-21 09:11:14 +0200 | [diff] [blame] | 52 | src/printer_xml.c |
Radek Krejci | 998a0b8 | 2015-08-17 13:14:36 +0200 | [diff] [blame] | 53 | src/printer_tree.c |
| 54 | src/printer_info.c |
| 55 | src/printer_json.c |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 56 | src/yang_types.c) |
Radek Krejci | e74ea8c | 2015-04-09 18:06:20 +0200 | [diff] [blame] | 57 | |
Radek Krejci | 5a06554 | 2015-05-22 15:02:07 +0200 | [diff] [blame] | 58 | set(lintsrc |
Michal Vasko | f3e59f1 | 2015-06-18 11:53:56 +0200 | [diff] [blame] | 59 | tools/lint/main.c |
| 60 | tools/lint/commands.c |
Michal Vasko | e0cb252 | 2015-07-01 10:24:53 +0200 | [diff] [blame] | 61 | tools/lint/completion.c |
Michal Vasko | 203b4e7 | 2015-06-30 15:25:15 +0200 | [diff] [blame] | 62 | linenoise/linenoise.c) |
Radek Krejci | 5a06554 | 2015-05-22 15:02:07 +0200 | [diff] [blame] | 63 | |
Tomas Cejka | 422c007 | 2015-07-21 18:18:25 +0200 | [diff] [blame] | 64 | set(headers |
| 65 | src/libyang.h |
Michal Vasko | 2d162e1 | 2015-09-24 14:33:29 +0200 | [diff] [blame^] | 66 | src/tree_schema.h |
| 67 | src/tree_data.h) |
Tomas Cejka | 422c007 | 2015-07-21 18:18:25 +0200 | [diff] [blame] | 68 | |
Radek Krejci | 5a06554 | 2015-05-22 15:02:07 +0200 | [diff] [blame] | 69 | add_library(yang SHARED ${libsrc}) |
Radek Krejci | 8f7cf40 | 2015-08-13 08:05:48 +0200 | [diff] [blame] | 70 | set_target_properties(yang PROPERTIES VERSION ${LIBYANG_VERSION} SOVERSION ${LIBYANG_SOVERSION}) |
Michal Vasko | e4e8fbd | 2015-08-24 14:54:49 +0200 | [diff] [blame] | 71 | set(LIBS ${LIBS} yang) |
| 72 | |
| 73 | # find PCRE library |
| 74 | find_package(PCRE REQUIRED) |
| 75 | include_directories(${PCRE_INCLUDE_DIRS}) |
| 76 | set(LIBS ${LIBS} ${PCRE_LIBRARIES}) |
Radek Krejci | e74ea8c | 2015-04-09 18:06:20 +0200 | [diff] [blame] | 77 | |
| 78 | install(TARGETS yang DESTINATION ${LIB_INSTALL_DIR}) |
Tomas Cejka | 422c007 | 2015-07-21 18:18:25 +0200 | [diff] [blame] | 79 | install(FILES ${headers} DESTINATION ${INCLUDE_INSTALL_DIR}) |
Radek Krejci | e74ea8c | 2015-04-09 18:06:20 +0200 | [diff] [blame] | 80 | |
| 81 | # generate doxygen documentation for libyang API |
| 82 | add_custom_target(doc |
Luka Perkov | b2657a2 | 2015-08-13 13:23:34 +0200 | [diff] [blame] | 83 | COMMAND doxygen ${CMAKE_BINARY_DIR}/Doxyfile |
Radek Krejci | e74ea8c | 2015-04-09 18:06:20 +0200 | [diff] [blame] | 84 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) |
Radek Krejci | 0d81764 | 2015-08-13 10:27:20 +0200 | [diff] [blame] | 85 | configure_file(Doxyfile.in Doxyfile) |
Radek Krejci | e74ea8c | 2015-04-09 18:06:20 +0200 | [diff] [blame] | 86 | |
| 87 | # clean cmake cache |
| 88 | add_custom_target(cclean |
| 89 | COMMAND make clean |
Radek Krejci | 977c1c8 | 2015-09-01 15:18:03 +0200 | [diff] [blame] | 90 | COMMAND find . -iname '*cmake*' -not -name CMakeLists.txt -not -path './CMakeModules*' -exec rm -rf {} + |
Radek Krejci | 0d81764 | 2015-08-13 10:27:20 +0200 | [diff] [blame] | 91 | COMMAND rm -rf Makefile Doxyfile |
Radek Krejci | 2cb3054 | 2015-04-10 08:33:57 +0200 | [diff] [blame] | 92 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) |
| 93 | |
Radek Krejci | 5a06554 | 2015-05-22 15:02:07 +0200 | [diff] [blame] | 94 | add_executable(yanglint ${lintsrc}) |
Michal Vasko | e4e8fbd | 2015-08-24 14:54:49 +0200 | [diff] [blame] | 95 | target_link_libraries(yanglint ${LIBS}) |
Radek Krejci | 5a06554 | 2015-05-22 15:02:07 +0200 | [diff] [blame] | 96 | |