Radek Krejci | e74ea8c | 2015-04-09 18:06:20 +0200 | [diff] [blame] | 1 | cmake_minimum_required(VERSION 2.6) |
| 2 | project(libyang C) |
| 3 | |
| 4 | # check the supported platform |
| 5 | if(NOT UNIX) |
| 6 | message(FATAL_ERROR "Only *nix like systems are supported.") |
| 7 | endif() |
| 8 | |
| 9 | if(NOT LIB_INSTALL_DIR) |
| 10 | set(LIB_INSTALL_DIR lib) |
| 11 | endif() |
| 12 | |
| 13 | # set default build type if not specified by user |
| 14 | if(NOT CMAKE_BUILD_TYPE) |
| 15 | set(CMAKE_BUILD_TYPE debug) |
| 16 | endif() |
| 17 | |
Radek Krejci | 2cb3054 | 2015-04-10 08:33:57 +0200 | [diff] [blame] | 18 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -fvisibility=hidden") |
Radek Krejci | 3045cf3 | 2015-05-28 10:58:52 +0200 | [diff] [blame] | 19 | set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG") |
Radek Krejci | e74ea8c | 2015-04-09 18:06:20 +0200 | [diff] [blame] | 20 | set(CMAKE_C_FLAGS_DEBUG "-g -O0") |
| 21 | |
Radek Krejci | 5a06554 | 2015-05-22 15:02:07 +0200 | [diff] [blame] | 22 | set(libsrc |
Radek Krejci | 9b4ca39 | 2015-04-10 08:31:27 +0200 | [diff] [blame] | 23 | src/common.c |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 24 | src/context.c |
Radek Krejci | 9b4ca39 | 2015-04-10 08:31:27 +0200 | [diff] [blame] | 25 | src/log.c |
Radek Krejci | ee62758 | 2015-04-20 17:39:59 +0200 | [diff] [blame] | 26 | src/dict.c |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 27 | src/xml.c |
Radek Krejci | efdd0ce | 2015-05-26 16:48:29 +0200 | [diff] [blame] | 28 | src/parser/yin.c |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 29 | src/tree.c |
Radek Krejci | efdd0ce | 2015-05-26 16:48:29 +0200 | [diff] [blame] | 30 | src/printer.c |
| 31 | src/printer/yang.c |
Michal Vasko | e3d2ee0 | 2015-06-03 15:03:41 +0200 | [diff] [blame] | 32 | src/printer/tree.c |
Radek Krejci | da04f4a | 2015-05-21 12:54:09 +0200 | [diff] [blame] | 33 | src/yang_types.c) |
Radek Krejci | e74ea8c | 2015-04-09 18:06:20 +0200 | [diff] [blame] | 34 | |
Radek Krejci | 5a06554 | 2015-05-22 15:02:07 +0200 | [diff] [blame] | 35 | set(lintsrc |
Michal Vasko | f3e59f1 | 2015-06-18 11:53:56 +0200 | [diff] [blame] | 36 | tools/lint/main.c |
| 37 | tools/lint/commands.c |
Michal Vasko | e0cb252 | 2015-07-01 10:24:53 +0200 | [diff] [blame^] | 38 | tools/lint/completion.c |
Michal Vasko | 203b4e7 | 2015-06-30 15:25:15 +0200 | [diff] [blame] | 39 | linenoise/linenoise.c) |
Radek Krejci | 5a06554 | 2015-05-22 15:02:07 +0200 | [diff] [blame] | 40 | |
| 41 | add_library(yang SHARED ${libsrc}) |
Radek Krejci | e74ea8c | 2015-04-09 18:06:20 +0200 | [diff] [blame] | 42 | set_target_properties(yang PROPERTIES VERSION 0.1.0 SOVERSION 0.1) |
| 43 | |
| 44 | install(TARGETS yang DESTINATION ${LIB_INSTALL_DIR}) |
| 45 | |
| 46 | # generate doxygen documentation for libyang API |
| 47 | add_custom_target(doc |
| 48 | COMMAND doxygen Doxyfile |
| 49 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) |
| 50 | |
| 51 | # clean cmake cache |
| 52 | add_custom_target(cclean |
| 53 | COMMAND make clean |
| 54 | COMMAND find . -iname '*cmake*' -not -name CMakeLists.txt -exec rm -rf {} + |
| 55 | COMMAND rm -rf Makefile |
Radek Krejci | 2cb3054 | 2015-04-10 08:33:57 +0200 | [diff] [blame] | 56 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) |
| 57 | |
Radek Krejci | 5a06554 | 2015-05-22 15:02:07 +0200 | [diff] [blame] | 58 | add_executable(yanglint ${lintsrc}) |
Michal Vasko | 203b4e7 | 2015-06-30 15:25:15 +0200 | [diff] [blame] | 59 | target_link_libraries(yanglint yang) |
Radek Krejci | 5a06554 | 2015-05-22 15:02:07 +0200 | [diff] [blame] | 60 | |