diff --git a/Help/prop_inst/CPACK_WIX_ACL.rst b/Help/prop_inst/CPACK_WIX_ACL.rst index e7d526aab..ee42666da 100644 --- a/Help/prop_inst/CPACK_WIX_ACL.rst +++ b/Help/prop_inst/CPACK_WIX_ACL.rst @@ -1,7 +1,8 @@ CPACK_WIX_ACL ------------- -Specifies access permissions for files installed by a WiX installer. +Specifies access permissions for files or directories +installed by a WiX installer. The property can contain multiple list entries, each of which has to match the following format. diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index b221ab43b..744280ad7 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -847,13 +847,37 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons( cmsys::Directory dir; dir.Load(topdir.c_str()); - if(dir.GetNumberOfFiles() == 2) + std::string relativeDirectoryPath = + cmSystemTools::RelativePath(toplevel.c_str(), topdir.c_str()); + + cmInstalledFile const* directoryInstalledFile = + this->GetInstalledFile(relativeDirectoryPath); + + bool emptyDirectory = dir.GetNumberOfFiles() == 2; + bool createDirectory = false; + + if(emptyDirectory) + { + createDirectory = true; + } + + if(directoryInstalledFile) + { + if(directoryInstalledFile->HasProperty("CPACK_WIX_ACL")) + { + createDirectory = true; + } + } + + if(createDirectory) { std::string componentId = fileDefinitions.EmitComponentCreateFolder( - directoryId, GenerateGUID()); - + directoryId, GenerateGUID(), directoryInstalledFile); featureDefinitions.EmitComponentRef(componentId); + } + if(emptyDirectory) + { return; } diff --git a/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx b/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx index 0ad5d0c40..1adb06ade 100644 --- a/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx +++ b/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx @@ -113,7 +113,9 @@ void cmWIXFilesSourceWriter::EmitUninstallShortcut( } std::string cmWIXFilesSourceWriter::EmitComponentCreateFolder( - std::string const& directoryId, std::string const& guid) + std::string const& directoryId, + std::string const& guid, + cmInstalledFile const* installedFile) { std::string componentId = std::string("CM_C_EMPTY_") + directoryId; @@ -127,6 +129,12 @@ std::string cmWIXFilesSourceWriter::EmitComponentCreateFolder( BeginElement("CreateFolder"); + if(installedFile) + { + cmWIXAccessControlList acl(Logger, *installedFile, *this); + acl.Apply(); + } + EndElement("CreateFolder"); EndElement("Component"); EndElement("DirectoryRef"); diff --git a/Source/CPack/WiX/cmWIXFilesSourceWriter.h b/Source/CPack/WiX/cmWIXFilesSourceWriter.h index 23ef561e9..b0a4af8f8 100644 --- a/Source/CPack/WiX/cmWIXFilesSourceWriter.h +++ b/Source/CPack/WiX/cmWIXFilesSourceWriter.h @@ -47,7 +47,8 @@ public: std::string EmitComponentCreateFolder( std::string const& directoryId, - std::string const& guid); + std::string const& guid, + cmInstalledFile const* installedFile); std::string EmitComponentFile( std::string const& directoryId, diff --git a/Source/cmInstalledFile.cxx b/Source/cmInstalledFile.cxx index 3483ecc60..4b53752b4 100644 --- a/Source/cmInstalledFile.cxx +++ b/Source/cmInstalledFile.cxx @@ -76,6 +76,13 @@ void cmInstalledFile::AppendProperty(cmMakefile const* mf, property.ValueExpressions.push_back(ge.Parse(value).release()); } +//---------------------------------------------------------------------------- +bool cmInstalledFile::HasProperty( + const std::string& prop) const +{ + return this->Properties.find(prop) != this->Properties.end(); +} + //---------------------------------------------------------------------------- bool cmInstalledFile::GetProperty( const std::string& prop, std::string& value) const diff --git a/Source/cmInstalledFile.h b/Source/cmInstalledFile.h index 0292cd1bc..7134a4e32 100644 --- a/Source/cmInstalledFile.h +++ b/Source/cmInstalledFile.h @@ -62,6 +62,8 @@ public: void AppendProperty(cmMakefile const* mf, const std::string& prop, const char* value,bool asString=false); + bool HasProperty(const std::string& prop) const; + bool GetProperty(const std::string& prop, std::string& value) const; bool GetPropertyAsBool(const std::string& prop) const;