summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorpeterbud <peterbudai@hotmail.com>2016-09-13 21:03:11 +0200
committerpeterbud <peterbudai@hotmail.com>2016-09-13 21:03:11 +0200
commit0918dd2b9925995577b5578404a86a6c017b4740 (patch)
tree5fa35837da6938314fce7837265533744ec48fcd /CMakeLists.txt
parent6d69483bbc6f2503094643728b2492ac9b26c6f0 (diff)
Adding options PKGCONFIG build options
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt51
1 files changed, 36 insertions, 15 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f1fa23d..270b875 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,6 +4,9 @@ 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 PKGCONFIG file" OFF)
+option(BUILD_USEOWNSUBDIR "Use a separate directory to install include and lib files" OFF)
+
set(BUILD_DEFINES "" CACHE STRING "Build defines")
if(MSVC)
@@ -25,11 +28,6 @@ endif()
include(GNUInstallDirs)
mark_as_advanced(CLEAR CMAKE_INSTALL_LIBDIR CMAKE_INSTALL_INCLUDEDIR)
-set(INSTALL_BIN_DIR "bin" CACHE PATH "Installation directory for executables")
-set(INSTALL_LIB_DIR "lib" CACHE PATH "Installation directory for libraries")
-set(INSTALL_INCLUDE_DIR "include" CACHE PATH "Installation directory for header files")
-set(INSTALL_PKGCONFIG_DIR "lib/pkgconfig" CACHE PATH "Installation directory for pkg-config file")
-
set(HEADERS src/pugixml.hpp src/pugiconfig.hpp)
set(SOURCES ${HEADERS} src/pugixml.cpp)
@@ -53,21 +51,44 @@ endif()
set_target_properties(pugixml PROPERTIES VERSION 1.7 SOVERSION 1)
get_target_property(PUGIXML_VERSION_STRING pugixml VERSION)
-# Install shared library into its own directory under LIBDIR
-install(TARGETS pugixml EXPORT pugixml-config
- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/pugixml-${PUGIXML_VERSION_STRING}
- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/pugixml-${PUGIXML_VERSION_STRING}
- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
-)
+set(INSTALL_BIN_DIR "bin" CACHE PATH "Installation directory for executables")
+if(BUILD_USEOWNSUBDIR)
+ set(INSTALL_LIB_DIR "lib/pugixml-${PUGIXML_VERSION_STRING}" CACHE PATH "Installation directory for libraries")
+ set(INSTALL_INCLUDE_DIR "include/pugixml-${PUGIXML_VERSION_STRING}" CACHE PATH "Installation directory for header files")
+else()
+ set(INSTALL_LIB_DIR "lib" CACHE PATH "Installation directory for libraries")
+ set(INSTALL_INCLUDE_DIR "include" CACHE PATH "Installation directory for header files")
+endif()
+
+set(INSTALL_PKGCONFIG_DIR "lib/pkgconfig" CACHE PATH "Installation directory for pkg-config file")
+
+if(BUILD_USEOWNSUBDIR)
+ # Install shared library into its own directory under LIBDIR
+ install(TARGETS pugixml EXPORT pugixml-config
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/pugixml-${PUGIXML_VERSION_STRING}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/pugixml-${PUGIXML_VERSION_STRING}
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ )
+
+ # Install header files into their own directory under INCLUDEDIR
+ install(FILES ${HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/pugixml-${PUGIXML_VERSION_STRING})
+else()
+ # Install shared library into default LIBDIR directory
+ install(TARGETS pugixml EXPORT pugixml-config
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ )
+
+ # Install header files into default INCLUDEDIR directory
+ install(FILES ${HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
+endif()
-# Install header files into their own directory under INCLUDEDIR
-install(FILES ${HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/pugixml-${PUGIXML_VERSION_STRING})
install(EXPORT pugixml-config DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pugixml)
-if(BUILD_SHARED_LIBS)
+if(BUILD_SHARED_LIBS AND BUILD_PKGCONFIG)
###############################################################################
# prepare pkg-config file
-
configure_file(misc/cmake/pugixml.pc
"${PROJECT_BINARY_DIR}/pugixml.pc" @ONLY)