summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorJosh Blum2011-10-19 16:39:37 -0700
committerJosh Blum2011-10-19 16:39:37 -0700
commite34107884e9a31dbfed62856aa12b1f572139105 (patch)
treefe202b3dcdfad6d017824da0581c49fcd20da697 /cmake
parentbe300d920fe1b7a3eb738565cddd10624ec62a75 (diff)
downloadgnuradio-e34107884e9a31dbfed62856aa12b1f572139105.tar.gz
gnuradio-e34107884e9a31dbfed62856aa12b1f572139105.tar.bz2
gnuradio-e34107884e9a31dbfed62856aa12b1f572139105.zip
cmake: added conditional check for compiler flags
Diffstat (limited to 'cmake')
-rw-r--r--cmake/Modules/GrMiscUtils.cmake13
1 files changed, 13 insertions, 0 deletions
diff --git a/cmake/Modules/GrMiscUtils.cmake b/cmake/Modules/GrMiscUtils.cmake
index 871861e35..10de21c7c 100644
--- a/cmake/Modules/GrMiscUtils.cmake
+++ b/cmake/Modules/GrMiscUtils.cmake
@@ -84,3 +84,16 @@ macro(GR_INCLUDE_SUBDIRECTORY subdir)
list(REMOVE_AT _cmake_source_dirs 0)
list(REMOVE_AT _cmake_binary_dirs 0)
endmacro(GR_INCLUDE_SUBDIRECTORY)
+
+########################################################################
+# Check if a compiler flag works and conditionally set a compile define.
+# - flag the compiler flag to check for
+# - have the variable to set with result
+########################################################################
+INCLUDE(CheckCXXCompilerFlag)
+MACRO(GR_ADD_CXX_COMPILER_FLAG_IF_AVAILABLE flag have)
+ CHECK_CXX_COMPILER_FLAG(${flag} ${have})
+ IF(${have})
+ ADD_DEFINITIONS(${flag})
+ ENDIF(${have})
+ENDMACRO(GR_ADD_CXX_COMPILER_FLAG_IF_AVAILABLE)