From d0d236dab007c5e8c901c23c0f09b6670b58686e Mon Sep 17 00:00:00 2001 From: Dawid Drozd Date: Sun, 29 Dec 2019 13:13:34 +0100 Subject: [PATCH] Secure installed files We should be able to remove installed stuff but we want to forbid changes in installed files. Thanks to that we do not modify files by mistake directly from e.g. Clion (when we go to header/source) --- lib/CMakeLists.txt | 4 ++++ lib/cmake/InstallHelp.cmake | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index df048ef..6a6b580 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -122,6 +122,8 @@ configure_package_config_file( install( FILES "${project_config}" "${version_config}" DESTINATION "${config_install_dir}" + # We don't want someone by accident modify his installed files + PERMISSIONS OWNER_EXECUTE OWNER_READ ) # Config @@ -129,6 +131,8 @@ install( install(EXPORT "${TARGETS_EXPORT_NAME}" DESTINATION "${config_install_dir}" NAMESPACE "${namespace}" + # We don't want someone by accident modify his installed files + PERMISSIONS OWNER_EXECUTE OWNER_READ ) # Export headers (Install public headers) diff --git a/lib/cmake/InstallHelp.cmake b/lib/cmake/InstallHelp.cmake index 447f357..83b4fe4 100644 --- a/lib/cmake/InstallHelp.cmake +++ b/lib/cmake/InstallHelp.cmake @@ -8,7 +8,12 @@ macro(install_public_headers_with_directory HEADER_LIST IGNORE_PREFIX) foreach(HEADER ${${HEADER_LIST}}) get_filename_component(DIR ${HEADER} DIRECTORY) string(REPLACE ${IGNORE_PREFIX} "" DIR ${DIR}) - install(FILES ${HEADER} DESTINATION include/${DIR}) + install( + FILES ${HEADER} + DESTINATION include/${DIR} + # We don't want someone by accident modify his installed files + PERMISSIONS OWNER_EXECUTE OWNER_READ + ) endforeach(HEADER) endmacro(install_public_headers_with_directory)