From 3a225c5d67e85ed296a449addf306dbb0ab2ef9c Mon Sep 17 00:00:00 2001 From: Karl Schultz Date: Fri, 30 Sep 2016 13:32:16 -0600 Subject: [PATCH] build: gh52-CMake changes to enable make install on Linux See BUILD.md for details. Change-Id: Ide1f635a57b57af384d9d1baac20c2256629f812 --- BUILD.md | 38 ++++++++++++++++++++++++++++++++++++++ demos/CMakeLists.txt | 4 ++++ layers/CMakeLists.txt | 19 +++++++++++++++++-- loader/CMakeLists.txt | 1 + 4 files changed, 60 insertions(+), 2 deletions(-) diff --git a/BUILD.md b/BUILD.md index 09982e9..3097efe 100644 --- a/BUILD.md +++ b/BUILD.md @@ -58,6 +58,44 @@ The `LoaderAndLayerInterface` document in the `loader` folder in this repository describes both how ICDs and layers should be properly packaged, and how developers can point to ICDs and layers within their builds. +### Linux Install to System Directories + +Installing the files resulting from your build to the systems directories is optional since +environment variables can usually be used instead to locate the binaries. +There are also risks with interfering with binaries installed by packages. +If you are certain that you would like to install your binaries to system directories, +you can proceed with these instructions. + +Assuming that you've built the code as described above and the current directory is still `dbuild`, +you can execute: + +``` +sudo make install +``` + +This command installs files to: + +* `/usr/local/lib`: Vulkan loader and layers shared objects +* `/usr/local/bin`: vulkaninfo application +* `/etc/vulkan/explicit_layer.d`: Layer JSON files + +You may need to run `ldconfig` in order to refresh the system loader search cache on some Linux systems. + +The list of installed files appears in the build directory in a file named `install_manifest.txt`. +You can easily remove the installed files with: + +``` +cat install_manifest.txt | sudo xargs rm +``` + +See the CMake documentation for details on using `DESTDIR` and `CMAKE_INSTALL_PREFIX` to customize +your installation location. + +Note that some executables in this repository (e.g., `cube`) use the "rpath" linker directive +to load the Vulkan loader from the build directory, `dbuild` in this example. +This means that even after installing the loader to the system directories, these executables +still use the loader from the build directory. + ## Validation Test The test executables can be found in the dbuild/tests directory. diff --git a/demos/CMakeLists.txt b/demos/CMakeLists.txt index ccfd84b..cdfb9e6 100644 --- a/demos/CMakeLists.txt +++ b/demos/CMakeLists.txt @@ -114,3 +114,7 @@ endif() if (${CMAKE_SYSTEM_PROCESSOR} STREQUAL ${CMAKE_HOST_SYSTEM_PROCESSOR}) add_subdirectory(smoke) endif() + +if(UNIX) + install(TARGETS vulkaninfo DESTINATION bin) +endif() diff --git a/layers/CMakeLists.txt b/layers/CMakeLists.txt index 13f9e69..de0dc94 100644 --- a/layers/CMakeLists.txt +++ b/layers/CMakeLists.txt @@ -67,6 +67,21 @@ else() endif() endif() +# 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 /etc/vulkan/explicit_layer.d) + endforeach(config_file) +endif() + if (WIN32) macro(add_vk_layer target) add_custom_command(OUTPUT VkLayer_${target}.def @@ -83,7 +98,7 @@ else() target_link_Libraries(VkLayer_${target} VkLayer_utils) add_dependencies(VkLayer_${target} generate_dispatch_table_helper generate_vk_layer_helpers generate_enum_string_helper VkLayer_utils) set_target_properties(VkLayer_${target} PROPERTIES LINK_FLAGS "-Wl,-Bsymbolic") - install(TARGETS VkLayer_${target} DESTINATION ${PROJECT_BINARY_DIR}/install_staging) + install(TARGETS VkLayer_${target} DESTINATION lib) endmacro() endif() @@ -176,7 +191,7 @@ if (WIN32) add_library(VkLayer_utils STATIC vk_layer_config.cpp vk_layer_extension_utils.cpp vk_layer_utils.cpp) else() add_library(VkLayer_utils SHARED vk_layer_config.cpp vk_layer_extension_utils.cpp vk_layer_utils.cpp) - install(TARGETS VkLayer_utils DESTINATION ${PROJECT_BINARY_DIR}/install_staging) + install(TARGETS VkLayer_utils DESTINATION lib) endif() add_vk_layer(core_validation core_validation.cpp vk_layer_table.cpp vk_safe_struct.cpp descriptor_sets.cpp) diff --git a/loader/CMakeLists.txt b/loader/CMakeLists.txt index 061fb72..742dec4 100644 --- a/loader/CMakeLists.txt +++ b/loader/CMakeLists.txt @@ -85,4 +85,5 @@ else() add_library(vulkan SHARED ${LOADER_SRCS}) set_target_properties(vulkan PROPERTIES SOVERSION "1" VERSION "1.0.28") target_link_libraries(vulkan -ldl -lpthread -lm) + install(TARGETS vulkan LIBRARY DESTINATION lib) endif() -- 2.7.4