]> granicus.if.org Git - libexpat/commitdiff
CMake: Add BUILD_install to make install optional
authorTobias Taschner <github@tc84.de>
Wed, 26 Oct 2016 19:48:34 +0000 (21:48 +0200)
committerTobias Taschner <github@tc84.de>
Wed, 26 Oct 2016 19:48:34 +0000 (21:48 +0200)
For easier integration in other projects via add_subdirectory() make the install() calls optional.

expat/CMakeLists.txt

index c4c3a4eccf7c5d3d357307e91f7c839edc2b50c0..a01e8a071d23a016102a51b2510facc63a52e090 100755 (executable)
@@ -15,6 +15,7 @@ option(BUILD_examples "build the examples for expat library" ON)
 option(BUILD_tests "build the tests for expat library" ON)\r
 option(BUILD_shared "build a shared expat library" ON)\r
 option(BUILD_doc "build man page for xmlwf" ON)\r
+option(BUILD_install "install expat files in cmake install target" ON)\r
 \r
 # configuration options\r
 set(XML_CONTEXT_BYTES 1024 CACHE STRING "Define to specify how much context to retain around the current parse point")\r
@@ -86,7 +87,13 @@ if(NOT WIN32)
     set_property(TARGET expat PROPERTY NO_SONAME ${NO_SONAME})\r
 endif(NOT WIN32)\r
 \r
-install(TARGETS expat RUNTIME DESTINATION bin\r
+macro(expat_install)\r
+    if(BUILD_install)\r
+        install(${ARGN})\r
+    endif()\r
+endmacro()\r
+\r
+expat_install(TARGETS expat RUNTIME DESTINATION bin\r
                       LIBRARY DESTINATION lib\r
                       ARCHIVE DESTINATION lib)\r
 \r
@@ -96,8 +103,8 @@ set(libdir "\${prefix}/lib")
 set(includedir "\${prefix}/include")\r
 configure_file(expat.pc.in ${CMAKE_CURRENT_BINARY_DIR}/expat.pc)\r
 \r
-install(FILES lib/expat.h lib/expat_external.h DESTINATION include)\r
-install(FILES ${CMAKE_CURRENT_BINARY_DIR}/expat.pc DESTINATION lib/pkgconfig)\r
+expat_install(FILES lib/expat.h lib/expat_external.h DESTINATION include)\r
+expat_install(FILES ${CMAKE_CURRENT_BINARY_DIR}/expat.pc DESTINATION lib/pkgconfig)\r
 \r
 if(BUILD_tools AND NOT WINCE)\r
     set(xmlwf_SRCS\r
@@ -110,7 +117,7 @@ if(BUILD_tools AND NOT WINCE)
     add_executable(xmlwf ${xmlwf_SRCS})\r
     set_property(TARGET xmlwf PROPERTY RUNTIME_OUTPUT_DIRECTORY xmlwf)\r
     target_link_libraries(xmlwf expat)\r
-    install(TARGETS xmlwf DESTINATION bin)\r
+    expat_install(TARGETS xmlwf DESTINATION bin)\r
     if(BUILD_doc AND NOT MSVC)\r
         if(CMAKE_GENERATOR STREQUAL "Unix Makefiles")\r
             set(make_command "$(MAKE)")\r
@@ -119,7 +126,7 @@ if(BUILD_tools AND NOT WINCE)
         endif()\r
 \r
         add_custom_command(TARGET expat PRE_BUILD COMMAND "${make_command}" -C "${PROJECT_SOURCE_DIR}/doc" xmlwf.1)\r
-        install(FILES "${PROJECT_SOURCE_DIR}/doc/xmlwf.1" DESTINATION share/man/man1)\r
+        expat_install(FILES "${PROJECT_SOURCE_DIR}/doc/xmlwf.1" DESTINATION share/man/man1)\r
     endif()\r
 endif(BUILD_tools AND NOT WINCE)\r
 \r