blob: 4ab1cc12037d500a81abd58c9503ce7c270cc85f [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
36 tools/lint/main.c)
37
38add_library(yang SHARED ${libsrc})
Radek Krejcie74ea8c2015-04-09 18:06:20 +020039set_target_properties(yang PROPERTIES VERSION 0.1.0 SOVERSION 0.1)
40
41install(TARGETS yang DESTINATION ${LIB_INSTALL_DIR})
42
43# generate doxygen documentation for libyang API
44add_custom_target(doc
45 COMMAND doxygen Doxyfile
46 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
47
48# clean cmake cache
49add_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 Krejci2cb30542015-04-10 08:33:57 +020053 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
54
Radek Krejci5a065542015-05-22 15:02:07 +020055add_executable(yanglint ${lintsrc})
56target_link_libraries(yanglint yang)
57