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 |
| 36 | tools/lint/main.c) |
| 37 | |
| 38 | add_library(yang SHARED ${libsrc}) |
Radek Krejci | e74ea8c | 2015-04-09 18:06:20 +0200 | [diff] [blame] | 39 | set_target_properties(yang PROPERTIES VERSION 0.1.0 SOVERSION 0.1) |
| 40 | |
| 41 | install(TARGETS yang DESTINATION ${LIB_INSTALL_DIR}) |
| 42 | |
| 43 | # generate doxygen documentation for libyang API |
| 44 | add_custom_target(doc |
| 45 | COMMAND doxygen Doxyfile |
| 46 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) |
| 47 | |
| 48 | # clean cmake cache |
| 49 | add_custom_target(cclean |
| 50 | COMMAND make clean |
| 51 | COMMAND find . -iname '*cmake*' -not -name CMakeLists.txt -exec rm -rf {} + |
| 52 | COMMAND rm -rf Makefile |
Radek Krejci | 2cb3054 | 2015-04-10 08:33:57 +0200 | [diff] [blame] | 53 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) |
| 54 | |
Radek Krejci | 5a06554 | 2015-05-22 15:02:07 +0200 | [diff] [blame] | 55 | add_executable(yanglint ${lintsrc}) |
| 56 | target_link_libraries(yanglint yang) |
| 57 | |