2017-05-21 05:05:38 -07:00
|
|
|
# Fix CMAKE_INSTALL_MANDIR on BSD before including GNUInstallDirs. #6771
|
|
|
|
if(CMAKE_SYSTEM_NAME MATCHES "BSD" AND NOT DEFINED CMAKE_INSTALL_MANDIR)
|
|
|
|
if(DEFINED ENV{MANPREFIX})
|
|
|
|
set(CMAKE_INSTALL_MANDIR "$ENV{MANPREFIX}/man")
|
2017-10-20 17:36:26 -07:00
|
|
|
elseif(CMAKE_INSTALL_PREFIX MATCHES "^/usr/local$")
|
|
|
|
set(CMAKE_INSTALL_MANDIR "man")
|
2017-05-21 05:05:38 -07:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2015-05-17 11:45:30 -07:00
|
|
|
# For $CMAKE_INSTALL_{DATAROOT,MAN, ...}DIR
|
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
build: install with the correct permissions
The install() command will create the parent directories, but it does so
with the user's umask. We want to do our best to make sure the correct
permissions are being set, without clobbering existing permissions.
To do this, this commit introduces an install_helper(), which is similar
in signature to the install() command, to help ensure that directories
are created ahead of the actual install() command. This will attempt to
use 0644 permissions for files and 0755 permissions for directories by
default--though they can be overridden.
To make this work correctly, without trying to introduce some mechanism
with setting the umask, it meant that there's a small portion that makes
use of an "internal" version of the file() command. It has been tested
on CMake 2.8.11, 2.8.12, and 3.0.2, and works correctly on all versions.
This fixes #1201 and #1086.
2014-09-19 04:37:22 -07:00
|
|
|
# This will create any directories that need to be created in the destination
|
|
|
|
# path with the typical owner, group, and user permissions--independent of the
|
|
|
|
# umask setting.
|
|
|
|
function(create_install_dir_with_perms)
|
|
|
|
cmake_parse_arguments(_install_dir
|
|
|
|
""
|
|
|
|
"DESTINATION"
|
|
|
|
"DIRECTORY_PERMISSIONS"
|
|
|
|
${ARGN}
|
|
|
|
)
|
|
|
|
|
|
|
|
if(NOT _install_dir_DESTINATION)
|
|
|
|
message(FATAL_ERROR "Must specify DESTINATION")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT _install_dir_DIRECTORY_PERMISSIONS)
|
|
|
|
set(_install_dir_DIRECTORY_PERMISSIONS
|
|
|
|
OWNER_READ OWNER_WRITE OWNER_EXECUTE
|
|
|
|
GROUP_READ GROUP_EXECUTE
|
|
|
|
WORLD_READ WORLD_EXECUTE)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
install(CODE
|
|
|
|
"
|
2014-11-05 06:50:00 -07:00
|
|
|
set(_current_dir \"\${CMAKE_INSTALL_PREFIX}/${_install_dir_DESTINATION}\")
|
build: install with the correct permissions
The install() command will create the parent directories, but it does so
with the user's umask. We want to do our best to make sure the correct
permissions are being set, without clobbering existing permissions.
To do this, this commit introduces an install_helper(), which is similar
in signature to the install() command, to help ensure that directories
are created ahead of the actual install() command. This will attempt to
use 0644 permissions for files and 0755 permissions for directories by
default--though they can be overridden.
To make this work correctly, without trying to introduce some mechanism
with setting the umask, it meant that there's a small portion that makes
use of an "internal" version of the file() command. It has been tested
on CMake 2.8.11, 2.8.12, and 3.0.2, and works correctly on all versions.
This fixes #1201 and #1086.
2014-09-19 04:37:22 -07:00
|
|
|
set(_dir_permissions \"${_install_dir_DIRECTORY_PERMISSIONS}\")
|
|
|
|
|
|
|
|
set(_parent_dirs)
|
2014-11-05 06:50:00 -07:00
|
|
|
set(_prev_dir)
|
|
|
|
|
|
|
|
# Explicitly prepend DESTDIR when using EXISTS.
|
|
|
|
# file(INSTALL ...) implicitly respects DESTDIR, but EXISTS does not.
|
|
|
|
while(NOT EXISTS \$ENV{DESTDIR}\${_current_dir} AND NOT \${_prev_dir} STREQUAL \${_current_dir})
|
build: install with the correct permissions
The install() command will create the parent directories, but it does so
with the user's umask. We want to do our best to make sure the correct
permissions are being set, without clobbering existing permissions.
To do this, this commit introduces an install_helper(), which is similar
in signature to the install() command, to help ensure that directories
are created ahead of the actual install() command. This will attempt to
use 0644 permissions for files and 0755 permissions for directories by
default--though they can be overridden.
To make this work correctly, without trying to introduce some mechanism
with setting the umask, it meant that there's a small portion that makes
use of an "internal" version of the file() command. It has been tested
on CMake 2.8.11, 2.8.12, and 3.0.2, and works correctly on all versions.
This fixes #1201 and #1086.
2014-09-19 04:37:22 -07:00
|
|
|
list(APPEND _parent_dirs \${_current_dir})
|
2014-11-05 06:50:00 -07:00
|
|
|
set(_prev_dir \${_current_dir})
|
2022-06-22 11:06:15 -07:00
|
|
|
get_filename_component(_current_dir \${_current_dir} DIRECTORY)
|
build: install with the correct permissions
The install() command will create the parent directories, but it does so
with the user's umask. We want to do our best to make sure the correct
permissions are being set, without clobbering existing permissions.
To do this, this commit introduces an install_helper(), which is similar
in signature to the install() command, to help ensure that directories
are created ahead of the actual install() command. This will attempt to
use 0644 permissions for files and 0755 permissions for directories by
default--though they can be overridden.
To make this work correctly, without trying to introduce some mechanism
with setting the umask, it meant that there's a small portion that makes
use of an "internal" version of the file() command. It has been tested
on CMake 2.8.11, 2.8.12, and 3.0.2, and works correctly on all versions.
This fixes #1201 and #1086.
2014-09-19 04:37:22 -07:00
|
|
|
endwhile()
|
|
|
|
|
|
|
|
if(_parent_dirs)
|
|
|
|
list(REVERSE _parent_dirs)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Create any missing folders with the useful permissions. Note: this uses
|
|
|
|
# a hidden option of CMake, but it's been shown to work with 2.8.11 thru
|
|
|
|
# 3.0.2.
|
|
|
|
foreach(_current_dir \${_parent_dirs})
|
|
|
|
if(NOT IS_DIRECTORY \${_current_dir})
|
2014-11-05 06:50:00 -07:00
|
|
|
# file(INSTALL ...) implicitly respects DESTDIR, so there's no need to
|
|
|
|
# prepend it here.
|
build: install with the correct permissions
The install() command will create the parent directories, but it does so
with the user's umask. We want to do our best to make sure the correct
permissions are being set, without clobbering existing permissions.
To do this, this commit introduces an install_helper(), which is similar
in signature to the install() command, to help ensure that directories
are created ahead of the actual install() command. This will attempt to
use 0644 permissions for files and 0755 permissions for directories by
default--though they can be overridden.
To make this work correctly, without trying to introduce some mechanism
with setting the umask, it meant that there's a small portion that makes
use of an "internal" version of the file() command. It has been tested
on CMake 2.8.11, 2.8.12, and 3.0.2, and works correctly on all versions.
This fixes #1201 and #1086.
2014-09-19 04:37:22 -07:00
|
|
|
file(INSTALL DESTINATION \${_current_dir}
|
|
|
|
TYPE DIRECTORY
|
|
|
|
DIR_PERMISSIONS \${_dir_permissions}
|
|
|
|
FILES \"\")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
")
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
# This is to prevent the user's umask from corrupting the expected permissions
|
|
|
|
# for the parent directories. We want to behave like the install tool here:
|
|
|
|
# preserve what's there already, but create new things with useful permissions.
|
|
|
|
function(install_helper)
|
|
|
|
cmake_parse_arguments(_install_helper
|
|
|
|
""
|
|
|
|
"DESTINATION;DIRECTORY;RENAME"
|
|
|
|
"FILES;PROGRAMS;TARGETS;DIRECTORY_PERMISSIONS;FILE_PERMISSIONS"
|
|
|
|
${ARGN}
|
|
|
|
)
|
|
|
|
|
|
|
|
if(NOT _install_helper_DESTINATION AND NOT _install_helper_TARGETS)
|
|
|
|
message(FATAL_ERROR "Must specify the DESTINATION path")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT _install_helper_FILES AND NOT _install_helper_DIRECTORY AND
|
|
|
|
NOT _install_helper_PROGRAMS AND NOT _install_helper_TARGETS)
|
|
|
|
message(FATAL_ERROR "Must specify FILES, PROGRAMS, TARGETS, or a DIRECTORY to install")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT _install_helper_DIRECTORY_PERMISSIONS)
|
|
|
|
set(_install_helper_DIRECTORY_PERMISSIONS
|
|
|
|
OWNER_READ OWNER_WRITE OWNER_EXECUTE
|
|
|
|
GROUP_READ GROUP_EXECUTE
|
|
|
|
WORLD_READ WORLD_EXECUTE)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT _install_helper_FILE_PERMISSIONS)
|
|
|
|
set(_install_helper_FILE_PERMISSIONS
|
|
|
|
OWNER_READ OWNER_WRITE
|
|
|
|
GROUP_READ
|
|
|
|
WORLD_READ)
|
|
|
|
endif()
|
|
|
|
|
2014-10-20 05:58:37 -07:00
|
|
|
if(NOT _install_helper_PROGRAM_PERMISSIONS)
|
|
|
|
set(_install_helper_PROGRAM_PERMISSIONS
|
|
|
|
OWNER_READ OWNER_WRITE OWNER_EXECUTE
|
|
|
|
GROUP_READ GROUP_EXECUTE
|
|
|
|
WORLD_READ WORLD_EXECUTE)
|
|
|
|
endif()
|
|
|
|
|
build: install with the correct permissions
The install() command will create the parent directories, but it does so
with the user's umask. We want to do our best to make sure the correct
permissions are being set, without clobbering existing permissions.
To do this, this commit introduces an install_helper(), which is similar
in signature to the install() command, to help ensure that directories
are created ahead of the actual install() command. This will attempt to
use 0644 permissions for files and 0755 permissions for directories by
default--though they can be overridden.
To make this work correctly, without trying to introduce some mechanism
with setting the umask, it meant that there's a small portion that makes
use of an "internal" version of the file() command. It has been tested
on CMake 2.8.11, 2.8.12, and 3.0.2, and works correctly on all versions.
This fixes #1201 and #1086.
2014-09-19 04:37:22 -07:00
|
|
|
if(_install_helper_RENAME)
|
|
|
|
set(RENAME RENAME ${_install_helper_RENAME})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(_install_helper_TARGETS)
|
|
|
|
set(_install_helper_DESTINATION "")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(_install_helper_TARGETS)
|
|
|
|
# Ensure the bin area exists with the correct permissions.
|
2015-05-17 11:45:30 -07:00
|
|
|
create_install_dir_with_perms(DESTINATION ${CMAKE_INSTALL_BINDIR})
|
build: install with the correct permissions
The install() command will create the parent directories, but it does so
with the user's umask. We want to do our best to make sure the correct
permissions are being set, without clobbering existing permissions.
To do this, this commit introduces an install_helper(), which is similar
in signature to the install() command, to help ensure that directories
are created ahead of the actual install() command. This will attempt to
use 0644 permissions for files and 0755 permissions for directories by
default--though they can be overridden.
To make this work correctly, without trying to introduce some mechanism
with setting the umask, it meant that there's a small portion that makes
use of an "internal" version of the file() command. It has been tested
on CMake 2.8.11, 2.8.12, and 3.0.2, and works correctly on all versions.
This fixes #1201 and #1086.
2014-09-19 04:37:22 -07:00
|
|
|
|
|
|
|
install(
|
|
|
|
TARGETS ${_install_helper_TARGETS}
|
2015-05-17 11:45:30 -07:00
|
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
build: install with the correct permissions
The install() command will create the parent directories, but it does so
with the user's umask. We want to do our best to make sure the correct
permissions are being set, without clobbering existing permissions.
To do this, this commit introduces an install_helper(), which is similar
in signature to the install() command, to help ensure that directories
are created ahead of the actual install() command. This will attempt to
use 0644 permissions for files and 0755 permissions for directories by
default--though they can be overridden.
To make this work correctly, without trying to introduce some mechanism
with setting the umask, it meant that there's a small portion that makes
use of an "internal" version of the file() command. It has been tested
on CMake 2.8.11, 2.8.12, and 3.0.2, and works correctly on all versions.
This fixes #1201 and #1086.
2014-09-19 04:37:22 -07:00
|
|
|
else()
|
|
|
|
create_install_dir_with_perms(
|
|
|
|
DESTINATION ${_install_helper_DESTINATION}
|
|
|
|
DIRECTORY_PERMISSIONS ${_install_helper_DIRECTORY_PERMISSIONS})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(_install_helper_DIRECTORY)
|
|
|
|
install(
|
|
|
|
DIRECTORY ${_install_helper_DIRECTORY}
|
|
|
|
DESTINATION ${_install_helper_DESTINATION}
|
|
|
|
DIRECTORY_PERMISSIONS ${_install_helper_DIRECTORY_PERMISSIONS}
|
|
|
|
FILE_PERMISSIONS ${_install_helper_FILE_PERMISSIONS})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(_install_helper_FILES)
|
|
|
|
install(
|
|
|
|
FILES ${_install_helper_FILES}
|
|
|
|
DESTINATION ${_install_helper_DESTINATION}
|
|
|
|
PERMISSIONS ${_install_helper_FILE_PERMISSIONS}
|
|
|
|
${RENAME})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(_install_helper_PROGRAMS)
|
|
|
|
install(
|
|
|
|
PROGRAMS ${_install_helper_PROGRAMS}
|
|
|
|
DESTINATION ${_install_helper_DESTINATION}
|
2014-10-20 05:58:37 -07:00
|
|
|
PERMISSIONS ${_install_helper_PROGRAM_PERMISSIONS}
|
build: install with the correct permissions
The install() command will create the parent directories, but it does so
with the user's umask. We want to do our best to make sure the correct
permissions are being set, without clobbering existing permissions.
To do this, this commit introduces an install_helper(), which is similar
in signature to the install() command, to help ensure that directories
are created ahead of the actual install() command. This will attempt to
use 0644 permissions for files and 0755 permissions for directories by
default--though they can be overridden.
To make this work correctly, without trying to introduce some mechanism
with setting the umask, it meant that there's a small portion that makes
use of an "internal" version of the file() command. It has been tested
on CMake 2.8.11, 2.8.12, and 3.0.2, and works correctly on all versions.
This fixes #1201 and #1086.
2014-09-19 04:37:22 -07:00
|
|
|
${RENAME})
|
|
|
|
endif()
|
|
|
|
endfunction()
|
2021-10-17 05:46:44 -07:00
|
|
|
|
|
|
|
# Without CONFIGURE_DEPENDS globbing reuses cached file tree on rebuild.
|
|
|
|
# For example it will ignore new files.
|
|
|
|
# CONFIGURE_DEPENDS was introduced in 3.12
|
|
|
|
|
|
|
|
function(glob_wrapper outvar)
|
|
|
|
if(${CMAKE_VERSION} VERSION_LESS 3.12)
|
|
|
|
file(GLOB ${outvar} ${ARGN})
|
|
|
|
else()
|
|
|
|
file(GLOB ${outvar} CONFIGURE_DEPENDS ${ARGN})
|
|
|
|
endif()
|
|
|
|
set(${outvar} ${${outvar}} PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(globrecurse_wrapper outvar root)
|
|
|
|
if(${CMAKE_VERSION} VERSION_LESS 3.12)
|
|
|
|
file(GLOB_RECURSE ${outvar} RELATIVE ${root} ${ARGN})
|
|
|
|
else()
|
|
|
|
file(GLOB_RECURSE ${outvar} CONFIGURE_DEPENDS RELATIVE ${root} ${ARGN})
|
|
|
|
endif()
|
|
|
|
set(${outvar} ${${outvar}} PARENT_SCOPE)
|
|
|
|
endfunction()
|