diff options
| author | Karl Schultz <karl@lunarg.com> | 2016-09-30 13:32:16 -0600 |
|---|---|---|
| committer | Karl Schultz <karl@lunarg.com> | 2016-10-03 08:35:01 -0600 |
| commit | 3a225c5d67e85ed296a449addf306dbb0ab2ef9c (patch) | |
| tree | 9f6a327b02165f21df1baaa9e0e3ef9d5b09c758 | |
| parent | 05c8f27a87314b430a5845de84bbb1fcdb418378 (diff) | |
| download | usermoji-3a225c5d67e85ed296a449addf306dbb0ab2ef9c.tar.xz | |
build: gh52-CMake changes to enable make install on Linux
See BUILD.md for details.
Change-Id: Ide1f635a57b57af384d9d1baac20c2256629f812
| -rw-r--r-- | BUILD.md | 38 | ||||
| -rw-r--r-- | demos/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | layers/CMakeLists.txt | 19 | ||||
| -rw-r--r-- | loader/CMakeLists.txt | 1 |
4 files changed, 60 insertions, 2 deletions
@@ -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 ccfd84b7..cdfb9e6a 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 13f9e69c..de0dc949 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 061fb72d..742dec4e 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() |
