From 22ace14fa8156031875c60c302358dcccc1e1b6e Mon Sep 17 00:00:00 2001 From: Karl Schultz Date: Mon, 12 Jun 2017 11:23:57 -0600 Subject: [PATCH] build: Add CMake flag to suppress LVL content 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 | 10 +++++++++- demos/CMakeLists.txt | 4 +++- demos/smoke/CMakeLists.txt | 4 +++- layers/CMakeLists.txt | 30 ++++++++++++++++++------------ loader/CMakeLists.txt | 10 +++++++--- 5 files changed, 40 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a5b82ed..b4b7d54 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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( diff --git a/demos/CMakeLists.txt b/demos/CMakeLists.txt index 917ea88..b9ea9d0 100644 --- a/demos/CMakeLists.txt +++ b/demos/CMakeLists.txt @@ -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() diff --git a/demos/smoke/CMakeLists.txt b/demos/smoke/CMakeLists.txt index 22aa3ab..5cf400b 100644 --- a/demos/smoke/CMakeLists.txt +++ b/demos/smoke/CMakeLists.txt @@ -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() diff --git a/layers/CMakeLists.txt b/layers/CMakeLists.txt index eb7a351..35a1b41 100644 --- a/layers/CMakeLists.txt +++ b/layers/CMakeLists.txt @@ -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) diff --git a/loader/CMakeLists.txt b/loader/CMakeLists.txt index d15f09c..7303f59 100644 --- a/loader/CMakeLists.txt +++ b/loader/CMakeLists.txt @@ -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() -- 2.7.4