summaryrefslogtreecommitdiffhomepage
path: root/cmake/AddIfFlagCompiles.cmake
diff options
context:
space:
mode:
authorAhmad Fatoum <[email protected]>2018-05-20 20:08:43 +0200
committerAhmad Fatoum <[email protected]>2018-05-21 01:08:29 +0200
commitff55af14f98fc70895ccdbbb4dccdccd68dec9dd (patch)
treeb0169c4f578be6c7babb3964110d06963755c235 /cmake/AddIfFlagCompiles.cmake
parentae26e083b4471f1404e4f25eee71e4f71e9b13f0 (diff)
downloadraylib-ff55af14f98fc70895ccdbbb4dccdccd68dec9dd.tar.gz
raylib-ff55af14f98fc70895ccdbbb4dccdccd68dec9dd.zip
CMake: Move reusable code to new cmake/ directory
Diffstat (limited to 'cmake/AddIfFlagCompiles.cmake')
-rw-r--r--cmake/AddIfFlagCompiles.cmake12
1 files changed, 12 insertions, 0 deletions
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()