CMake: Move reusable code to new cmake/ directory

This commit is contained in:
Ahmad Fatoum 2018-05-20 20:08:43 +02:00
parent ae26e083b4
commit ff55af14f9
No known key found for this signature in database
GPG key ID: C3EAC3DE9321D59B
4 changed files with 38 additions and 34 deletions

View file

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

View file

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