build: Add CMake flag to suppress LVL content
authorKarl Schultz <karl@lunarg.com>
Mon, 12 Jun 2017 17:23:57 +0000 (11:23 -0600)
committerKarl Schultz <karl@lunarg.com>
Mon, 12 Jun 2017 21:36:56 +0000 (15:36 -0600)
Add CMake flag INSTALL_LVL_FILES (default ON) that when
set to OFF, suppresses the installation of LVL artifacts
when running "make install" on Linux.

This flag doesn't have much use in the LVL repo because
when turned off, CMake won't generate an install target
in the makefiles.

However, for the downstream VulkanTools and VulkanSamples
repos, it can be useful to avoid installing LVL files on
top of files that may have already been installed from
a previous "make install" installation of the LVL repo.

An example of such a use case would be the desire to
have a more up-to-date version of LVL on the system
than the one last merged into the downstream repo.

This new flag is meant to address the need mentioned in
LVL Pull Request #1844.

Change-Id: I421f37ea4e885fbf0a268eff363a28f0537b1953

CMakeLists.txt
demos/CMakeLists.txt
demos/smoke/CMakeLists.txt
layers/CMakeLists.txt
loader/CMakeLists.txt

index a5b82ed..b4b7d54 100644 (file)
@@ -43,6 +43,12 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
     if (BUILD_WSI_MIR_SUPPORT)
         find_package(Mir REQUIRED)
     endif()
+
+    # This option can be used to suppress the installation of artifacts from the
+    # Vulkan-LoaderAndValidationLayers repo while running "make install" for the
+    # VulkanTools and VulkanSamples repos.  This can be used to prevent the
+    # overwriting of LVL artifacts when installing these downstream repos.
+    option(INSTALL_LVL_FILES "Install content from LoaderAndValidationLayers repo" ON)
 endif()
 
 set(SCRIPTS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/scripts")
@@ -310,7 +316,9 @@ if(NOT WIN32)
 endif()
 
 if(UNIX)
-    install(DIRECTORY "${PROJECT_SOURCE_DIR}/include/vulkan" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
+    if(INSTALL_LVL_FILES)
+        install(DIRECTORY "${PROJECT_SOURCE_DIR}/include/vulkan" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
+    endif()
 
 # uninstall target
 configure_file(
index 917ea88..b9ea9d0 100644 (file)
@@ -155,5 +155,7 @@ if ((${CMAKE_SYSTEM_PROCESSOR} STREQUAL ${CMAKE_HOST_SYSTEM_PROCESSOR}))
 endif()
 
 if(UNIX)
-    install(TARGETS ${API_LOWERCASE}info DESTINATION ${CMAKE_INSTALL_BINDIR})
+    if(INSTALL_LVL_FILES)
+        install(TARGETS ${API_LOWERCASE}info DESTINATION ${CMAKE_INSTALL_BINDIR})
+    endif()
 endif()
index 22aa3ab..5cf400b 100644 (file)
@@ -88,5 +88,7 @@ target_include_directories(smoketest ${includes})
 target_link_libraries(smoketest ${libraries})
 
 if(UNIX)
-    install(TARGETS smoketest DESTINATION ${CMAKE_INSTALL_BINDIR})
+    if(INSTALL_LVL_FILES)
+        install(TARGETS smoketest DESTINATION ${CMAKE_INSTALL_BINDIR})
+    endif()
 endif()
index eb7a351..35a1b41 100644 (file)
@@ -87,16 +87,18 @@ endforeach(config_file)
 # Add targets for JSON file install on Linux.
 # Need to remove the "./" from the library path before installing to /etc.
 if(UNIX)
-    foreach (config_file ${LAYER_JSON_FILES})
-        add_custom_target(${config_file}-staging-json ALL
-            COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/staging-json
-            COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/linux/${config_file}.json ${CMAKE_CURRENT_BINARY_DIR}/staging-json
-            COMMAND sed -i -e "/\"library_path\":/s$./libVkLayer$libVkLayer$" ${CMAKE_CURRENT_BINARY_DIR}/staging-json/${config_file}.json
-            VERBATIM
-            DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/linux/${config_file}.json
-            )
-        install(FILES ${CMAKE_CURRENT_BINARY_DIR}/staging-json/${config_file}.json DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/vulkan/explicit_layer.d)
-    endforeach(config_file)
+    if(INSTALL_LVL_FILES)
+        foreach (config_file ${LAYER_JSON_FILES})
+            add_custom_target(${config_file}-staging-json ALL
+                COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/staging-json
+                COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/linux/${config_file}.json ${CMAKE_CURRENT_BINARY_DIR}/staging-json
+                COMMAND sed -i -e "/\"library_path\":/s$./libVkLayer$libVkLayer$" ${CMAKE_CURRENT_BINARY_DIR}/staging-json/${config_file}.json
+                VERBATIM
+                DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/linux/${config_file}.json
+                )
+            install(FILES ${CMAKE_CURRENT_BINARY_DIR}/staging-json/${config_file}.json DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/vulkan/explicit_layer.d)
+        endforeach(config_file)
+    endif()
 endif()
 
 if (WIN32)
@@ -117,7 +119,9 @@ else()
     target_link_Libraries(VkLayer_${target} VkLayer_utils)
     add_dependencies(VkLayer_${target} generate_helper_files VkLayer_utils)
     set_target_properties(VkLayer_${target} PROPERTIES LINK_FLAGS "-Wl,-Bsymbolic,--exclude-libs,ALL")
-    install(TARGETS VkLayer_${target} DESTINATION ${CMAKE_INSTALL_LIBDIR})
+    if(INSTALL_LVL_FILES)
+        install(TARGETS VkLayer_${target} DESTINATION ${CMAKE_INSTALL_LIBDIR})
+    endif()
     endmacro()
 endif()
 
@@ -163,7 +167,9 @@ if (WIN32)
     add_library(VkLayer_utils STATIC vk_layer_config.cpp vk_layer_extension_utils.cpp vk_layer_utils.cpp vk_format_utils.cpp)
 else()
     add_library(VkLayer_utils SHARED vk_layer_config.cpp vk_layer_extension_utils.cpp vk_layer_utils.cpp vk_format_utils.cpp)
-    install(TARGETS VkLayer_utils DESTINATION ${CMAKE_INSTALL_LIBDIR})
+    if(INSTALL_LVL_FILES)
+        install(TARGETS VkLayer_utils DESTINATION ${CMAKE_INSTALL_LIBDIR})
+    endif()
 endif()
 add_dependencies(VkLayer_utils generate_helper_files)
 
index d15f09c..7303f59 100644 (file)
@@ -145,7 +145,9 @@ else()
     set_target_properties(${API_LOWERCASE} PROPERTIES SOVERSION "1" VERSION "1.0.${vk_header_version}")
     target_link_libraries(${API_LOWERCASE} -ldl -lpthread -lm)
 
-    install(TARGETS ${API_LOWERCASE} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+    if(INSTALL_LVL_FILES)
+        install(TARGETS ${API_LOWERCASE} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+    endif()
 
     # Generate pkg-config file.
     include(FindPkgConfig QUIET)
@@ -155,7 +157,9 @@ else()
             set(PRIVATE_LIBS "${PRIVATE_LIBS} -l${LIB}")
         endforeach()
         configure_file("vulkan.pc.in" "vulkan.pc" @ONLY)
-        install(FILES       "${CMAKE_CURRENT_BINARY_DIR}/vulkan.pc"
-                DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
+        if(INSTALL_LVL_FILES)
+            install(FILES       "${CMAKE_CURRENT_BINARY_DIR}/vulkan.pc"
+                    DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
+        endif()
     endif()
 endif()