Files
opm-common/cmake/Modules/CheckCaseSensitiveFileSystem.cmake
Andreas Lauser fc43fdd427 add a cmake test to check if the used file system is case sensitive
And fix the unit test for INCLUDE. This should make the test pass on
case insensitive file systems like the one of MacOS X. (Who uses that
anyway? ;))
2014-04-23 14:56:27 +02:00

30 lines
999 B
CMake

#
# 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()