Skip to content

Commit bffd9e4

Browse files
committed
Use GNUInstallDirs for destination guessing
Warning: on non-Debian amd64 systems, this will change the installation directory of libraries, they will be put into ${CMAKE_INSTALL_PREFIX}/lib64/ now. The old versions of libraries which might still be in lib/ will be left in place, which means that there's some potential for breakage on developers' systems. The same applies to PKG_CONFIG_PATH which is changed from lib/ to lib64/ on these systems. Still, I think that following cmake conventions is a good reason to follow suit here.
1 parent 37df09e commit bffd9e4

File tree

2 files changed

+9
-24
lines changed

2 files changed

+9
-24
lines changed

CMakeLists.txt

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,6 @@ if(NOT UNIX)
4444
message(FATAL_ERROR "Only *nix like systems are supported.")
4545
endif()
4646

47-
if(NOT LIB_INSTALL_DIR)
48-
set(LIB_INSTALL_DIR lib)
49-
endif()
50-
51-
if(NOT INCLUDE_INSTALL_DIR)
52-
set(INCLUDE_INSTALL_DIR include/libyang)
53-
endif()
54-
55-
if(NOT BIN_INSTALL_DIR)
56-
set(BIN_INSTALL_DIR bin)
57-
endif()
58-
if(NOT MAN_INSTALL_DIR)
59-
set(MAN_INSTALL_DIR share/man/)
60-
endif()
61-
6247
# set default build type if not specified by user
6348
if(NOT CMAKE_BUILD_TYPE)
6449
set(CMAKE_BUILD_TYPE debug)
@@ -138,21 +123,21 @@ find_package(PCRE REQUIRED)
138123
include_directories(${PCRE_INCLUDE_DIRS})
139124
target_link_libraries(yang ${PCRE_LIBRARIES})
140125

141-
install(TARGETS yang DESTINATION ${LIB_INSTALL_DIR})
142-
install(FILES ${headers} DESTINATION ${INCLUDE_INSTALL_DIR})
126+
install(TARGETS yang DESTINATION ${CMAKE_INSTALL_LIBDIR})
127+
install(FILES ${headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libyang)
143128

144129
find_package(PkgConfig)
145130
if(PKG_CONFIG_FOUND)
146131
# generate and install pkg-config file
147132
configure_file("libyang.pc.in" "libyang.pc" @ONLY)
148-
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")
149134
# check that pkg-config includes the used path
150135
execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} --variable pc_path pkg-config RESULT_VARIABLE RETURN OUTPUT_VARIABLE PC_PATH ERROR_QUIET)
151136
if(RETURN EQUAL 0)
152-
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}")
153138
string(LENGTH "${SUBSTR}" SUBSTR_LEN)
154139
if(SUBSTR_LEN EQUAL 0)
155-
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\".")
156141
endif()
157142
endif()
158143
endif()
@@ -176,8 +161,8 @@ add_custom_target(cclean
176161

177162
add_executable(yanglint ${lintsrc})
178163
target_link_libraries(yanglint yang)
179-
install(TARGETS yanglint DESTINATION ${BIN_INSTALL_DIR})
180-
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)
181166

182167
add_executable(yang2yin ${yang2yinsrc})
183168

libyang.pc.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
prefix=@CMAKE_INSTALL_PREFIX@
2-
includedir=${prefix}/@INCLUDE_INSTALL_DIR@
3-
libdir=${prefix}/@LIB_INSTALL_DIR@
2+
includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
3+
libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
44

55
Name: @PROJECT_NAME@
66
Description: @LIBYANG_DESCRIPTION@

0 commit comments

Comments
 (0)