summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--CMakeLists.txt23
-rw-r--r--scripts/pugixml.pc.in11
3 files changed, 29 insertions, 6 deletions
diff --git a/.gitignore b/.gitignore
index 567609b..01f9cb9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
build/
+.vscode/ \ No newline at end of file
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 018e728..3dbdd6f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,6 +4,8 @@ cmake_minimum_required(VERSION 2.6)
option(BUILD_SHARED_LIBS "Build shared instead of static library" OFF)
option(BUILD_TESTS "Build tests" OFF)
+option(BUILD_PKGCONFIG "Build in PKGCONFIG mode" OFF)
+
set(BUILD_DEFINES "" CACHE STRING "Build defines")
if(MSVC)
@@ -46,16 +48,25 @@ if(NOT ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} STRLESS 3.1 AND ";${CMAKE_C
endif()
set_target_properties(pugixml PROPERTIES VERSION 1.7 SOVERSION 1)
+get_target_property(PUGIXML_VERSION_STRING pugixml VERSION)
-install(TARGETS pugixml EXPORT pugixml-config
- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
-)
+if(BUILD_PKGCONFIG)
+ # Install library into its own directory under LIBDIR
+ set(INSTALL_SUFFIX /pugixml-${PUGIXML_VERSION_STRING})
+endif()
-install(FILES ${HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
+install(TARGETS pugixml EXPORT pugixml-config
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}${INSTALL_SUFFIX}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}${INSTALL_SUFFIX}
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
+install(FILES ${HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}${INSTALL_SUFFIX})
install(EXPORT pugixml-config DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pugixml)
+if(BUILD_PKGCONFIG)
+ configure_file(scripts/pugixml.pc.in ${PROJECT_BINARY_DIR}/pugixml.pc @ONLY)
+ install(FILES ${PROJECT_BINARY_DIR}/pugixml.pc DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig)
+endif()
+
if(BUILD_TESTS)
file(GLOB TEST_SOURCES tests/*.cpp)
file(GLOB FUZZ_SOURCES tests/fuzz_*.cpp)
diff --git a/scripts/pugixml.pc.in b/scripts/pugixml.pc.in
new file mode 100644
index 0000000..3c97c28
--- /dev/null
+++ b/scripts/pugixml.pc.in
@@ -0,0 +1,11 @@
+prefix=@CMAKE_INSTALL_PREFIX@
+exec_prefix=${prefix}
+includedir=${prefix}/include/pugixml-@PUGIXML_VERSION_STRING@
+libdir=${exec_prefix}/lib/pugixml-@PUGIXML_VERSION_STRING@
+
+Name: pugixml
+Description: Light-weight, simple and fast XML parser for C++ with XPath support.
+URL: http://pugixml.org/
+Version: @PUGIXML_VERSION_STRING@
+Cflags: -I${includedir}
+Libs: -L${libdir} -lpugixml \ No newline at end of file