| 1 |
MACRO(CONFIGURE_GID_HANDLING _NAME_TARGET) |
| 2 |
# Test for and then set the appropriate preprocessor macros expected by |
| 3 |
# z-file.c to describe how the system handles changing the group ID. |
| 4 |
INCLUDE(CheckSymbolExists) |
| 5 |
|
| 6 |
# Linux man page only mentions unistd.h; FreeBSD's also has sys/types.h. |
| 7 |
# The Linux man page mentions _GNU_SOURCE as necessary. |
| 8 |
SET(OLD_CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}) |
| 9 |
SET(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -D_GNU_SOURCE=) |
| 10 |
CHECK_SYMBOL_EXISTS(setresgid "sys/types.h;unistd.h" SETRESGID_EXISTS) |
| 11 |
SET(CMAKE_REQUIRED_DEFINITIONS ${OLD_CMAKE_REQUIRED_DEFINITIONS}) |
| 12 |
IF(SETRESGID_EXISTS) |
| 13 |
TARGET_COMPILE_DEFINITIONS(${_NAME_TARGET} PRIVATE -D _GNU_SOURCE) |
| 14 |
TARGET_COMPILE_DEFINITIONS(${_NAME_TARGET} PRIVATE -D HAVE_SETRESGID) |
| 15 |
ENDIF() |
| 16 |
|
| 17 |
CHECK_SYMBOL_EXISTS(setegid "unistd.h" SETEGID_EXISTS) |
| 18 |
IF(SETEGID_EXISTS) |
| 19 |
TARGET_COMPILE_DEFINITIONS(${_NAME_TARGET} PRIVATE -D HAVE_SETEGID) |
| 20 |
ENDIF() |
| 21 |
|
| 22 |
IF((SETRESGID_EXISTS) OR (SETEGID_EXISTS)) |
| 23 |
MESSAGE(STATUS "GID handling configured") |
| 24 |
ELSE() |
| 25 |
MESSAGE(FATAL_ERROR "Neither setresgid() nor setegid() appears to be available; at least one is needed for a shared setgid installation") |
| 26 |
ENDIF() |
| 27 |
ENDMACRO() |