File: CheckCaseSensitiveFileSystem.cmake

package info (click to toggle)
opm-common 2022.10%2Bds-7
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 78,468 kB
  • sloc: cpp: 164,554; python: 2,872; sh: 216; xml: 174; ansic: 149; pascal: 136; makefile: 12
file content (29 lines) | stat: -rw-r--r-- 999 bytes parent folder | download | duplicates (3)
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
#
# Module to check whether the file system is case sensitive or not
#
# Sets the following variable:
#
# HAVE_CASE_SENSITIVE_FILESYSTEM   True if the file system honors the case of files

message(STATUS "Checking whether the file system is case-sensitive")
# create a file containing uppercase characters
file(WRITE "${CMAKE_BINARY_DIR}/UPPER" "Foo")

# check if the all-lowercase file with the same name can be opened
set(FooContents "")
if (EXISTS "${CMAKE_BINARY_DIR}/upper")
    file(READ "${CMAKE_BINARY_DIR}/upper" FooContents)
endif()

# remove the file again in order not to have it dangling around...
file(REMOVE "${CMAKE_BINARY_DIR}/UPPER")

# check the contents of the file opened with lower-case. If it is
# empty, the file system is case sensitive.
if ("${FooContents}" STREQUAL "Foo")
  message(STATUS "File system is not case-sensitive")
  set(HAVE_CASE_SENSITIVE_FILESYSTEM 0)
else()
  message(STATUS "File system is case-sensitive")
  set(HAVE_CASE_SENSITIVE_FILESYSTEM 1)
endif()