blob: da442ed28efac853acb5a044521b5632e136f3d8 (
plain)
1 From 314dc6a95baaca90294a8ea957d9810e3bee0f62 Mon Sep 17 00:00:00 2001
2 From: Eli Schwartz <eschwartz93@gmail.com>
3 Date: Mon, 9 Apr 2018 01:46:30 -0400
4 Subject: [PATCH] cmake: always install the pkg-config file
5
6 There's really never a reason to *not* want this installed. If an option
7 is needed to specify installing in a versioned subdirectory, this option
8 should be explicitly described rather than hidden in something else.
9
10 As an added bonus, this makes the CMake install code slightly *less*
11 complicated.
12 ---
13 CMakeLists.txt | 10 ++++------
14 scripts/pugixml.pc.in | 6 +++---
15 2 files changed, 7 insertions(+), 9 deletions(-)
16
17 diff --git a/CMakeLists.txt b/CMakeLists.txt
18 index 90fa6793..d7bc1b20 100644
19 --- a/CMakeLists.txt
20 +++ b/CMakeLists.txt
21 @@ -4,7 +4,7 @@ project(pugixml)
22
23 option(BUILD_SHARED_LIBS "Build shared instead of static library" OFF)
24 option(BUILD_TESTS "Build tests" OFF)
25 -option(BUILD_PKGCONFIG "Build in PKGCONFIG mode" OFF)
26 +option(USE_VERSIONED_LIBDIR "Use a private subdirectory to install the headers and libs" OFF)
27
28 set(BUILD_DEFINES "" CACHE STRING "Build defines")
29
30 @@ -55,7 +55,7 @@ endif()
31 set_target_properties(pugixml PROPERTIES VERSION 1.9 SOVERSION 1)
32 get_target_property(PUGIXML_VERSION_STRING pugixml VERSION)
33
34 -if(BUILD_PKGCONFIG)
35 +if(USE_VERSIONED_LIBDIR)
36 # Install library into its own directory under LIBDIR
37 set(INSTALL_SUFFIX /pugixml-${PUGIXML_VERSION_STRING})
38 endif()
39 @@ -71,10 +71,8 @@ install(TARGETS pugixml EXPORT pugixml-config
40 install(FILES ${HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}${INSTALL_SUFFIX})
41 install(EXPORT pugixml-config DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pugixml)
42
43 -if(BUILD_PKGCONFIG)
44 - configure_file(scripts/pugixml.pc.in ${PROJECT_BINARY_DIR}/pugixml.pc @ONLY)
45 - install(FILES ${PROJECT_BINARY_DIR}/pugixml.pc DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig)
46 -endif()
47 +configure_file(scripts/pugixml.pc.in ${PROJECT_BINARY_DIR}/pugixml.pc @ONLY)
48 +install(FILES ${PROJECT_BINARY_DIR}/pugixml.pc DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig)
49
50 if(BUILD_TESTS)
51 file(GLOB TEST_SOURCES tests/*.cpp)
52 diff --git a/scripts/pugixml.pc.in b/scripts/pugixml.pc.in
53 index 3c97c28d..804c4d38 100644
54 --- a/scripts/pugixml.pc.in
55 +++ b/scripts/pugixml.pc.in
56 @@ -1,11 +1,11 @@
57 prefix=@CMAKE_INSTALL_PREFIX@
58 exec_prefix=${prefix}
59 -includedir=${prefix}/include/pugixml-@PUGIXML_VERSION_STRING@
60 -libdir=${exec_prefix}/lib/pugixml-@PUGIXML_VERSION_STRING@
61 +includedir=${prefix}/include@INSTALL_SUFFIX@
62 +libdir=${exec_prefix}/lib@INSTALL_SUFFIX@
63
64 Name: pugixml
65 Description: Light-weight, simple and fast XML parser for C++ with XPath support.
66 URL: http://pugixml.org/
67 Version: @PUGIXML_VERSION_STRING@
68 Cflags: -I${includedir}
69 -Libs: -L${libdir} -lpugixml
70 \ No newline at end of file
71 +Libs: -L${libdir} -lpugixml
|