I install an empty directory from a CMakeLists.txt
by doing the following:
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/var/log)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/var
DESTINATION ${CMAKE_INSTALL_PREFIX}
DIRECTORY_PERMISSIONS
OWNER_WRITE OWNER_READ OWNER_EXECUTE
GROUP_WRITE GROUP_READ GROUP_EXECUTE
WORLD_WRITE WORLD_READ WORLD_EXECUTE
COMPONENT runtime
)
I expect to see these permissions:
/opt/myapp $ ls -l
drwxrwxrwx root root var
drwxrwxrwx root root var/log
but instead I see:
/opt/myapp $ ls -l
drwxr-xr-x root root var
drwxrwxrwx root root var/log
DIRECTORY_PERMISSIONS
WORLD_WRITE
and GROUP_WRITE
are applied to var/log
but not var
. Currently I need to sudo chmod 777 var
to get my program to run. How can I correct this?
I figured it out after I couldn't reproduce it with a MCVE.
One CMakeLists.txt which was included with add_subdirectory()
contained:
install(DIRECTORY var DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT runtime)
That over-wrote the permissions of the install
command from the higher-level CMakeLists.txt
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With