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