cmake: support default install target
Allow the common install target to support the installation of
header files (rather then having a custom target). Developers should
be able to invoke the install target as follows:
cmake --build . --target install
This commit leaves the original custom target to install headers
for interim support.
Signed-off-by: James Knight <james.d.knight@live.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index be7d88a..b4ad4c7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -42,10 +42,19 @@
# directory. To install the headers:
# 1. mkdir build ; cd build
# 2. cmake ..
-# 3. cmake --build . install-headers
+# 3. cmake --build . --target install
-file(GLOB_RECURSE FILES include/spirv/*)
+file(GLOB_RECURSE HEADER_FILES
+ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
+ include/spirv/*)
+foreach(HEADER_FILE ${HEADER_FILES})
+ get_filename_component(HEADER_INSTALL_DIR ${HEADER_FILE} PATH)
+ install(FILES ${HEADER_FILE} DESTINATION ${HEADER_INSTALL_DIR})
+endforeach()
+
+# legacy
add_custom_target(install-headers
- COMMAND cmake -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/include/spirv ${CMAKE_INSTALL_PREFIX}/include/spirv)
+ COMMAND cmake -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/include/spirv
+ ${CMAKE_INSTALL_PREFIX}/include/spirv)
add_subdirectory(example)