11cmake_minimum_required (VERSION 2.8.9 )
22project (libyang C )
33
4+ include (GNUInstallDirs )
5+
46set (LIBYANG_DESCRIPTION "libyang is YANG data modelling language parser and toolkit written (and providing API) in C." )
57
68# set version
@@ -42,21 +44,6 @@ if(NOT UNIX)
4244 message (FATAL_ERROR "Only *nix like systems are supported." )
4345endif ()
4446
45- if (NOT LIB_INSTALL_DIR)
46- set (LIB_INSTALL_DIR lib)
47- endif ()
48-
49- if (NOT INCLUDE_INSTALL_DIR)
50- set (INCLUDE_INSTALL_DIR include/libyang)
51- endif ()
52-
53- if (NOT BIN_INSTALL_DIR)
54- set (BIN_INSTALL_DIR bin)
55- endif ()
56- if (NOT MAN_INSTALL_DIR)
57- set (MAN_INSTALL_DIR share/man/)
58- endif ()
59-
6047# set default build type if not specified by user
6148if (NOT CMAKE_BUILD_TYPE )
6249 set (CMAKE_BUILD_TYPE debug)
@@ -136,21 +123,21 @@ find_package(PCRE REQUIRED)
136123include_directories (${PCRE_INCLUDE_DIRS} )
137124target_link_libraries (yang ${PCRE_LIBRARIES} )
138125
139- install (TARGETS yang DESTINATION ${LIB_INSTALL_DIR } )
140- install (FILES ${headers} DESTINATION ${INCLUDE_INSTALL_DIR} )
126+ install (TARGETS yang DESTINATION ${CMAKE_INSTALL_LIBDIR } )
127+ install (FILES ${headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} /libyang )
141128
142129find_package (PkgConfig )
143130if (PKG_CONFIG_FOUND)
144131 # generate and install pkg-config file
145132 configure_file ("libyang.pc.in" "libyang.pc" @ONLY )
146- install (FILES "${CMAKE_CURRENT_BINARY_DIR} /libyang.pc" DESTINATION "${CMAKE_INSTALL_PREFIX} / ${LIB_INSTALL_DIR } /pkgconfig" )
133+ install (FILES "${CMAKE_CURRENT_BINARY_DIR} /libyang.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR } /pkgconfig" )
147134 # check that pkg-config includes the used path
148135 execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} --variable pc_path pkg-config RESULT_VARIABLE RETURN OUTPUT_VARIABLE PC_PATH ERROR_QUIET )
149136 if (RETURN EQUAL 0)
150- string (REGEX MATCH "${CMAKE_INSTALL_PREFIX} /${LIB_INSTALL_DIR } /pkgconfig" SUBSTR "${PC_PATH} " )
137+ string (REGEX MATCH "${CMAKE_INSTALL_PREFIX} /${CMAKE_INSTALL_LIBDIR } /pkgconfig" SUBSTR "${PC_PATH} " )
151138 string (LENGTH "${SUBSTR} " SUBSTR_LEN)
152139 if (SUBSTR_LEN EQUAL 0)
153- message (WARNING "pkg-config will not detect the new package after installation, adjust PKG_CONFIG_PATH using \" export PKG_CONFIG_PATH=\$ {PKG_CONFIG_PATH}:${CMAKE_INSTALL_PREFIX} /${LIB_INSTALL_DIR } /pkgconfig\" ." )
140+ message (WARNING "pkg-config will not detect the new package after installation, adjust PKG_CONFIG_PATH using \" export PKG_CONFIG_PATH=\$ {PKG_CONFIG_PATH}:${CMAKE_INSTALL_PREFIX} /${CMAKE_INSTALL_LIBDIR } /pkgconfig\" ." )
154141 endif ()
155142 endif ()
156143endif ()
@@ -174,8 +161,8 @@ add_custom_target(cclean
174161
175162add_executable (yanglint ${lintsrc} )
176163target_link_libraries (yanglint yang )
177- install (TARGETS yanglint DESTINATION ${BIN_INSTALL_DIR } )
178- install (FILES ${PROJECT_SOURCE_DIR} /tools/lint/yanglint.1 DESTINATION ${MAN_INSTALL_DIR } /man1)
164+ install (TARGETS yanglint DESTINATION ${CMAKE_INSTALL_BINDIR } )
165+ install (FILES ${PROJECT_SOURCE_DIR} /tools/lint/yanglint.1 DESTINATION ${CMAKE_INSTALL_MANDIR } /man1)
179166
180167add_executable (yang2yin ${yang2yinsrc} )
181168
0 commit comments