[cmake] check some compiler flags before use (for ubuntu 14.04)
@@ -113,14 +113,45 @@ if(BUILD_AS_CPP)
set(${COMPONENT}_LINKER_LANGUAGE CXX)
endif()
+check_c_compiler_flag("-Wno-error=float-conversion" W_no_error_float_conversion_flag)
+check_c_compiler_flag("-Wno-error=conversion" W_no_error_conversion_flag)
+check_c_compiler_flag("-Wno-conversion" W_no_conversion_flag)
+check_c_compiler_flag("-fpermissive" fpermissive_flag)
+
+
if(NOT USE_SYSTEM_SUITESPARSE)
file(GLOB_RECURSE CXSPARSE_FILES ${CMAKE_CURRENT_SOURCE_DIR} cxsparse_*.c)
if(BUILD_AS_CPP)
- set_source_files_properties(${CXSPARSE_FILES} PROPERTIES COMPILE_FLAGS
- "-Wno-error=float-conversion -Wno-error=conversion -Wno-conversion -fpermissive")
+ set(_flags)
+ if(W_no_error_float_conversion_flag)
+ set(_flags "-Wno-error=float-conversion")
+ endif()
+ if(W_no_error_conversion_flag)
+ set(_flags "${_flags} -Wno-error=conversion")
+ endif()
+ if(W_no_conversion_flag)
+ set(_flags "${_flags} -Wno-conversion")
+ endif()
+ if(fpermissive_flag)
+ set(_flags "${_flags} -fpermissive")
+ endif()
+ if(_flags)
+ set_source_files_properties(${CXSPARSE_FILES} PROPERTIES COMPILE_FLAGS ${_flags})
+ endif()
else()
- set_source_files_properties(${CXSPARSE_FILES} PROPERTIES COMPILE_FLAGS
- "-Wno-error=conversion -Wno-error=float-conversion -Wno-conversion")
+ set(_flags)
+ if(W_no_error_conversion_flag)
+ set(_flags "-Wno-error=conversion")
+ endif()
+ if(W_no_error_float_conversion_flag)
+ set(_flags "${_flags} -Wno-error=float-conversion")
+ endif()
+ if(W_no_conversion_flag)
+ set(_flags "${_flags} -Wno-conversion")
+ endif()
+ if(_flags)
+ set_source_files_properties(${CXSPARSE_FILES} PROPERTIES COMPILE_FLAGS ${_flags})
+ endif()
endif()
endif()
