From ff55af14f98fc70895ccdbbb4dccdccd68dec9dd Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Sun, 20 May 2018 20:08:43 +0200 Subject: CMake: Move reusable code to new cmake/ directory --- cmake/AddIfFlagCompiles.cmake | 12 ++++++++++++ cmake/CheckFileSystemSymlinkSupport.cmake | 13 +++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 cmake/AddIfFlagCompiles.cmake create mode 100644 cmake/CheckFileSystemSymlinkSupport.cmake (limited to 'cmake') diff --git a/cmake/AddIfFlagCompiles.cmake b/cmake/AddIfFlagCompiles.cmake new file mode 100644 index 00000000..403607b5 --- /dev/null +++ b/cmake/AddIfFlagCompiles.cmake @@ -0,0 +1,12 @@ +include(CheckCCompilerFlag) +function(add_if_flag_compiles flag) + CHECK_C_COMPILER_FLAG("${flag}" COMPILER_HAS_THOSE_TOGGLES) + set(outcome "Failed") + if(COMPILER_HAS_THOSE_TOGGLES) + foreach(var ${ARGN}) + set(${var} "${flag} ${${var}}" PARENT_SCOPE) + endforeach() + set(outcome "compiles") + endif() + message(STATUS "Testing if ${flag} can be used -- ${outcome}") +endfunction() diff --git a/cmake/CheckFileSystemSymlinkSupport.cmake b/cmake/CheckFileSystemSymlinkSupport.cmake new file mode 100644 index 00000000..798840ef --- /dev/null +++ b/cmake/CheckFileSystemSymlinkSupport.cmake @@ -0,0 +1,13 @@ +# Populates a ${FILESYSTEM_LACKS_SYMLINKS} variable +message(STATUS "Testing if file system supports symlinks") +execute_process( + COMMAND ${CMAKE_COMMAND} -E create_symlink CMakeLists.txt "${CMAKE_CURRENT_BINARY_DIR}/TestingIfSymlinkWorks" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + RESULT_VARIABLE FILESYSTEM_LACKS_SYMLINKS +) +If (FILESYSTEM_LACKS_SYMLINKS) + message(STATUS "Testing if file system supports symlinks -- unsupported") +else() + message(STATUS "Testing if file system supports symlinks -- supported") +endif() + -- cgit v1.2.3