Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake WORLD_WRITE permission isn't applied on INSTALL

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?

like image 332
Stewart Avatar asked Nov 07 '22 05:11

Stewart


1 Answers

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

like image 156
Stewart Avatar answered Nov 15 '22 12:11

Stewart