77
88project (libyang C)
99
10+ # include custom Modules
11+ set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR} /CMakeModules/" )
12+
1013include (GNUInstallDirs)
1114include (CheckSymbolExists)
15+ include (UseCompat)
1216
1317set (LIBYANG_DESCRIPTION "libyang is YANG data modelling language parser and toolkit written (and providing API) in C." )
1418
@@ -21,18 +25,23 @@ set(CMAKE_MACOSX_RPATH TRUE)
2125# micro version is changed with a set of small changes or bugfixes anywhere in the project.
2226set (LIBYANG_MAJOR_VERSION 1)
2327set (LIBYANG_MINOR_VERSION 0)
24- set (LIBYANG_MICRO_VERSION 130 )
28+ set (LIBYANG_MICRO_VERSION 167 )
2529set (LIBYANG_VERSION ${LIBYANG_MAJOR_VERSION} .${LIBYANG_MINOR_VERSION} .${LIBYANG_MICRO_VERSION} )
2630
2731# Version of the library
2832# Major version is changed with every backward non-compatible API/ABI change in libyang, minor version changes
2933# with backward compatible change and micro version is connected with any internal change of the library.
3034set (LIBYANG_MAJOR_SOVERSION 1)
31- set (LIBYANG_MINOR_SOVERSION 6 )
32- set (LIBYANG_MICRO_SOVERSION 7 )
35+ set (LIBYANG_MINOR_SOVERSION 7 )
36+ set (LIBYANG_MICRO_SOVERSION 11 )
3337set (LIBYANG_SOVERSION_FULL ${LIBYANG_MAJOR_SOVERSION} .${LIBYANG_MINOR_SOVERSION} .${LIBYANG_MICRO_SOVERSION} )
3438set (LIBYANG_SOVERSION ${LIBYANG_MAJOR_SOVERSION} )
3539
40+ # check the supported platform
41+ if (NOT UNIX )
42+ message (FATAL_ERROR "Only *nix like systems are supported." )
43+ endif ()
44+
3645# set default build type if not specified by user
3746if (NOT CMAKE_BUILD_TYPE )
3847 set (CMAKE_BUILD_TYPE debug)
@@ -81,7 +90,8 @@ elseif(CMAKE_C_COMPILER_ID STREQUAL "Clang")
8190 set (COMPILER_UNUSED_ATTR "UNUSED_ ## x __attribute__((__unused__))" )
8291 set (COMPILER_PACKED_ATTR "__attribute__((__packed__))" )
8392else ()
84- message (WARNING "You are using an unknown compiler, it must support C11 standard \" _Generic\" statement or the \" __builtin_types_compatible_p\" built-in function." )
93+ message (WARNING "You are using an unknown compiler, it must support C11 standard \" _Generic\" statement"
94+ " or the \" __builtin_types_compatible_p\" built-in function." )
8595 set (COMPILER_UNUSED_ATTR "UNUSED_ ## x" )
8696 set (COMPILER_PACKED_ATTR "" )
8797endif ()
@@ -93,9 +103,6 @@ configure_file(${PROJECT_SOURCE_DIR}/src/common.h.in ${PROJECT_BINARY_DIR}/src/c
93103set (EXTENSIONS_PLUGINS_DIR_MACRO "${PLUGINS_DIR} /extensions" )
94104set (USER_TYPES_PLUGINS_DIR_MACRO "${PLUGINS_DIR} /user_types" )
95105
96- # include custom Modules
97- set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR} /CMakeModules/" )
98-
99106# setup bindings
100107set (GEN_LANGUAGE_BINDINGS 0 CACHE BOOL "Enable language bindings generation." )
101108set (GEN_CPP_BINDINGS 1 CACHE BOOL "Enable C++ bindings." )
@@ -132,11 +139,6 @@ endif()
132139# static build requires static libpcre library
133140option (ENABLE_STATIC "Build static (.a) library" OFF )
134141
135- # check the supported platform
136- if (NOT UNIX )
137- message (FATAL_ERROR "Only *nix like systems are supported." )
138- endif ()
139-
140142set (libsrc
141143 src/common.c
142144 src/context.c
@@ -190,10 +192,8 @@ set(headers
190192 src/xml.h
191193 src/dict.h)
192194
193- check_symbol_exists(vdprintf "stdio.h;stdarg.h" HAVE_VDPRINTF)
194- if (HAVE_VDPRINTF)
195- add_definitions (-DHAVE_VDPRINTF)
196- endif (HAVE_VDPRINTF)
195+ # link compat
196+ use_compat()
197197
198198# create static libyang library
199199if (ENABLE_STATIC)
@@ -202,7 +202,7 @@ if(ENABLE_STATIC)
202202 set (CMAKE_FIND_LIBRARY_SUFFIXES .a)
203203 set (CMAKE_EXE_LINK_DYNAMIC_C_FLAGS) # remove -Wl,-Bdynamic
204204 set (CMAKE_EXE_LINK_DYNAMIC_CXX_FLAGS)
205- add_library (yang STATIC ${libsrc} )
205+ add_library (yang STATIC ${libsrc} $<TARGET_OBJECTS:compat> )
206206
207207 # switch off the tests
208208 if (ENABLE_BUILD_TESTS)
@@ -217,7 +217,7 @@ if(ENABLE_STATIC)
217217else ()
218218 set (CMAKE_POSITION_INDEPENDENT_CODE TRUE )
219219 add_library (yangobj OBJECT ${libsrc} )
220- add_library (yang SHARED $<TARGET_OBJECTS:yangobj>)
220+ add_library (yang SHARED $<TARGET_OBJECTS:yangobj> $<TARGET_OBJECTS:compat> )
221221
222222 #only for tests with visible internal symbols
223223 add_library (yangobj_tests OBJECT ${libsrc} )
@@ -226,7 +226,7 @@ else()
226226 target_link_libraries (yang ${CMAKE_DL_LIBS} )
227227
228228 set_target_properties (yangobj PROPERTIES COMPILE_FLAGS "-fvisibility=hidden" )
229- endif (ENABLE_STATIC )
229+ endif ()
230230
231231set_target_properties (yang PROPERTIES VERSION ${LIBYANG_SOVERSION_FULL} SOVERSION ${LIBYANG_SOVERSION} )
232232
@@ -296,7 +296,7 @@ if(ENABLE_BUILD_TESTS)
296296 if (CMOCKA_FOUND AND CMAKE_BUILD_TYPE MATCHES debug)
297297 list (APPEND EXTENSIONS_LIST "libyang_ext_test" )
298298 endif (CMOCKA_FOUND AND CMAKE_BUILD_TYPE MATCHES debug)
299- endif (ENABLE_BUILD_TESTS )
299+ endif ()
300300
301301if (ENABLE_STATIC)
302302 set (EXTENSIONS_LIST_SIZE " 0 " )
@@ -330,18 +330,18 @@ if(ENABLE_STATIC)
330330 set (STATIC_LOADED_PLUGINS_COUNT "${ITEM} " )
331331else ()
332332 add_subdirectory (src/user_types)
333- endif (ENABLE_STATIC )
333+ endif ()
334334
335335configure_file (${PROJECT_SOURCE_DIR} /src/plugin_config.h.in ${PROJECT_BINARY_DIR} /src/plugin_config.h)
336336
337337# yanglint
338- add_executable (yanglint ${lintsrc} )
338+ add_executable (yanglint ${lintsrc} $<TARGET_OBJECTS:compat> )
339339target_link_libraries (yanglint yang)
340340install (TARGETS yanglint DESTINATION ${CMAKE_INSTALL_BINDIR} )
341341install (FILES ${PROJECT_SOURCE_DIR} /tools/lint/yanglint.1 DESTINATION ${CMAKE_INSTALL_MANDIR} /man1)
342342
343343#yangre
344- add_executable (yangre ${resrc} )
344+ add_executable (yangre ${resrc} $<TARGET_OBJECTS:compat> )
345345target_link_libraries (yangre yang)
346346install (TARGETS yangre DESTINATION ${CMAKE_INSTALL_BINDIR} )
347347install (FILES ${PROJECT_SOURCE_DIR} /tools/re/yangre.1 DESTINATION ${CMAKE_INSTALL_MANDIR} /man1)
@@ -367,11 +367,11 @@ if(ENABLE_BUILD_TESTS)
367367 message (STATUS "Disabling tests because of missing CMocka" )
368368 set (ENABLE_BUILD_TESTS NO )
369369 endif (CMOCKA_FOUND)
370- endif (ENABLE_BUILD_TESTS )
370+ endif ()
371371
372372if (ENABLE_BUILD_FUZZ_TARGETS)
373373 add_subdirectory (tests/fuzz)
374- endif (ENABLE_BUILD_FUZZ_TARGETS )
374+ endif ()
375375
376376if (GEN_LANGUAGE_BINDINGS AND GEN_CPP_BINDINGS)
377377 add_subdirectory (swig)
0 commit comments