diff options
author | Josh Blum | 2011-10-19 16:39:37 -0700 |
---|---|---|
committer | Josh Blum | 2011-10-19 16:39:37 -0700 |
commit | e34107884e9a31dbfed62856aa12b1f572139105 (patch) | |
tree | fe202b3dcdfad6d017824da0581c49fcd20da697 | |
parent | be300d920fe1b7a3eb738565cddd10624ec62a75 (diff) | |
download | gnuradio-e34107884e9a31dbfed62856aa12b1f572139105.tar.gz gnuradio-e34107884e9a31dbfed62856aa12b1f572139105.tar.bz2 gnuradio-e34107884e9a31dbfed62856aa12b1f572139105.zip |
cmake: added conditional check for compiler flags
-rw-r--r-- | CMakeLists.txt | 6 | ||||
-rw-r--r-- | cmake/Modules/GrMiscUtils.cmake | 13 |
2 files changed, 17 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index a74ff4c90..c175bdd77 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,13 +55,15 @@ file(WRITE ${EXPORT_FILE}) #blank the file (subdirs will append) ######################################################################## # Compiler specific setup ######################################################################## +include(GrMiscUtils) #compiler flag check + if(CMAKE_COMPILER_IS_GNUCXX AND NOT WIN32) #http://gcc.gnu.org/wiki/Visibility - add_definitions(-fvisibility=hidden) + GR_ADD_CXX_COMPILER_FLAG_IF_AVAILABLE(-fvisibility=hidden HAVE_VISIBILITY_HIDDEN) endif() if(CMAKE_COMPILER_IS_GNUCXX) - add_definitions(-Wsign-compare) + GR_ADD_CXX_COMPILER_FLAG_IF_AVAILABLE(-Wsign-compare HAVE_SIGN_COMPARE) endif(CMAKE_COMPILER_IS_GNUCXX) if(MSVC) 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) |