blob: 68f3f6410a2464c0f63dafc35b9a79744be5a378 [file] [log] [blame]
Radek Krejcie74ea8c2015-04-09 18:06:20 +02001cmake_minimum_required(VERSION 2.6)
2project(libyang C)
3
4# check the supported platform
5if(NOT UNIX)
6 message(FATAL_ERROR "Only *nix like systems are supported.")
7endif()
8
9if(NOT LIB_INSTALL_DIR)
10 set(LIB_INSTALL_DIR lib)
11endif()
12
13# set default build type if not specified by user
14if(NOT CMAKE_BUILD_TYPE)
15 set(CMAKE_BUILD_TYPE debug)
16endif()
17
Radek Krejci2cb30542015-04-10 08:33:57 +020018set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -fvisibility=hidden")
Radek Krejci3045cf32015-05-28 10:58:52 +020019set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG")
Radek Krejcie74ea8c2015-04-09 18:06:20 +020020set(CMAKE_C_FLAGS_DEBUG "-g -O0")
21
Radek Krejci5a065542015-05-22 15:02:07 +020022set(libsrc
Radek Krejci9b4ca392015-04-10 08:31:27 +020023 src/common.c
Radek Krejcida04f4a2015-05-21 12:54:09 +020024 src/context.c
Radek Krejci9b4ca392015-04-10 08:31:27 +020025 src/log.c
Radek Krejciee627582015-04-20 17:39:59 +020026 src/dict.c
Radek Krejcida04f4a2015-05-21 12:54:09 +020027 src/xml.c
Radek Krejciefdd0ce2015-05-26 16:48:29 +020028 src/parser/yin.c
Radek Krejcida04f4a2015-05-21 12:54:09 +020029 src/tree.c
Radek Krejciefdd0ce2015-05-26 16:48:29 +020030 src/printer.c
31 src/printer/yang.c
Michal Vaskoe3d2ee02015-06-03 15:03:41 +020032 src/printer/tree.c
Radek Krejcida04f4a2015-05-21 12:54:09 +020033 src/yang_types.c)
Radek Krejcie74ea8c2015-04-09 18:06:20 +020034
Radek Krejci5a065542015-05-22 15:02:07 +020035set(lintsrc
Michal Vaskof3e59f12015-06-18 11:53:56 +020036 tools/lint/main.c
37 tools/lint/commands.c
Michal Vaskoe0cb2522015-07-01 10:24:53 +020038 tools/lint/completion.c
Michal Vasko203b4e72015-06-30 15:25:15 +020039 linenoise/linenoise.c)
Radek Krejci5a065542015-05-22 15:02:07 +020040
41add_library(yang SHARED ${libsrc})
Radek Krejcie74ea8c2015-04-09 18:06:20 +020042set_target_properties(yang PROPERTIES VERSION 0.1.0 SOVERSION 0.1)
43
44install(TARGETS yang DESTINATION ${LIB_INSTALL_DIR})
45
46# generate doxygen documentation for libyang API
47add_custom_target(doc
48 COMMAND doxygen Doxyfile
49 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
50
51# clean cmake cache
52add_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 Krejci2cb30542015-04-10 08:33:57 +020056 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
57
Radek Krejci5a065542015-05-22 15:02:07 +020058add_executable(yanglint ${lintsrc})
Michal Vasko203b4e72015-06-30 15:25:15 +020059target_link_libraries(yanglint yang)
Radek Krejci5a065542015-05-22 15:02:07 +020060