blob: f7aedd15675e3a5be1696972cc7c146244fe2aa5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/sourcefile.txt
${CMAKE_CURRENT_BINARY_DIR}/sourcefile-use-source-permissions.txt
USE_SOURCE_PERMISSIONS
)
if (UNIX)
find_program(STAT_EXECUTABLE NAMES stat)
if(NOT STAT_EXECUTABLE)
return()
endif()
if (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
execute_process(COMMAND "${STAT_EXECUTABLE}" -f %Lp "${CMAKE_CURRENT_SOURCE_DIR}/sourcefile.txt"
OUTPUT_VARIABLE output1
)
execute_process(COMMAND "${STAT_EXECUTABLE}" -f %Lp "${CMAKE_CURRENT_BINARY_DIR}/sourcefile-use-source-permissions.txt"
OUTPUT_VARIABLE output2
)
elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
execute_process(COMMAND "${STAT_EXECUTABLE}" -f %A "${CMAKE_CURRENT_SOURCE_DIR}/sourcefile.txt"
OUTPUT_VARIABLE output1
)
execute_process(COMMAND "${STAT_EXECUTABLE}" -f %A "${CMAKE_CURRENT_BINARY_DIR}/sourcefile-use-source-permissions.txt"
OUTPUT_VARIABLE output2
)
else()
execute_process(COMMAND "${STAT_EXECUTABLE}" -c %a "${CMAKE_CURRENT_SOURCE_DIR}/sourcefile.txt"
OUTPUT_VARIABLE output1
)
execute_process(COMMAND "${STAT_EXECUTABLE}" -c %a "${CMAKE_CURRENT_BINARY_DIR}/sourcefile-use-source-permissions.txt"
OUTPUT_VARIABLE output2
)
endif()
if (NOT output1 EQUAL output2)
message(FATAL_ERROR "configure file has different permissions source "
"permissions: ${output1} generated permissions: ${output2}")
endif()
endif()
|