Avoid if() quoted auto-dereference

When testing CMAKE_<LANG>_COMPILER_ID values, do not explicitly
dereference or quote the variable. We want if() to auto-dereference the
variable and not its value. Also replace MATCHES with STREQUAL where
equivalent.
This commit is contained in:
Ben Boeckel 2014-10-14 10:25:32 -04:00
parent a7596fef6e
commit 29c3edb87a
25 changed files with 50 additions and 50 deletions

View File

@ -555,7 +555,7 @@ CMAKE_SETUP_TESTING()
if(NOT CMake_TEST_EXTERNAL_CMAKE) if(NOT CMake_TEST_EXTERNAL_CMAKE)
if(NOT CMake_VERSION_IS_RELEASE) if(NOT CMake_VERSION_IS_RELEASE)
if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND
NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS 4.2) NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS 4.2)
set(C_FLAGS_LIST -Wcast-align -Werror-implicit-function-declaration -Wchar-subscripts set(C_FLAGS_LIST -Wcast-align -Werror-implicit-function-declaration -Wchar-subscripts
-Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security

View File

@ -20,7 +20,7 @@ if(CMAKE_GENERATOR MATCHES "Visual Studio 6")
set(CMAKE_SKIP_COMPATIBILITY_TESTS 1) set(CMAKE_SKIP_COMPATIBILITY_TESTS 1)
endif() endif()
if(WIN32 AND "${CMAKE_C_COMPILER_ID}" MATCHES "^(Intel)$") if(WIN32 AND CMAKE_C_COMPILER_ID STREQUAL "Intel")
set(_INTEL_WINDOWS 1) set(_INTEL_WINDOWS 1)
endif() endif()

View File

@ -108,7 +108,7 @@ if(NOT CMAKE_C_COMPILER_ID_RUN)
CMAKE_DETERMINE_COMPILER_ID(C CFLAGS CMakeCCompilerId.c) CMAKE_DETERMINE_COMPILER_ID(C CFLAGS CMakeCCompilerId.c)
# Set old compiler and platform id variables. # Set old compiler and platform id variables.
if("${CMAKE_C_COMPILER_ID}" MATCHES "GNU") if(CMAKE_C_COMPILER_ID MATCHES "GNU")
set(CMAKE_COMPILER_IS_GNUCC 1) set(CMAKE_COMPILER_IS_GNUCC 1)
endif() endif()
if("${CMAKE_C_PLATFORM_ID}" MATCHES "MinGW") if("${CMAKE_C_PLATFORM_ID}" MATCHES "MinGW")
@ -131,11 +131,11 @@ endif ()
# "arm-unknown-nto-qnx6" instead of the correct "arm-unknown-nto-qnx6.3.0-" # "arm-unknown-nto-qnx6" instead of the correct "arm-unknown-nto-qnx6.3.0-"
if (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX) if (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX)
if("${CMAKE_C_COMPILER_ID}" MATCHES "GNU" OR "${CMAKE_C_COMPILER_ID}" MATCHES "Clang") if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
get_filename_component(COMPILER_BASENAME "${CMAKE_C_COMPILER}" NAME) get_filename_component(COMPILER_BASENAME "${CMAKE_C_COMPILER}" NAME)
if (COMPILER_BASENAME MATCHES "^(.+-)(clang|g?cc)(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\.exe)?$") if (COMPILER_BASENAME MATCHES "^(.+-)(clang|g?cc)(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\.exe)?$")
set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1})
elseif("${CMAKE_C_COMPILER_ID}" MATCHES "Clang") elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
if(CMAKE_C_COMPILER_TARGET) if(CMAKE_C_COMPILER_TARGET)
set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_C_COMPILER_TARGET}-) set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_C_COMPILER_TARGET}-)
endif() endif()
@ -150,7 +150,7 @@ if (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX)
if ("${_CMAKE_TOOLCHAIN_PREFIX}" MATCHES "(.+-)?llvm-$") if ("${_CMAKE_TOOLCHAIN_PREFIX}" MATCHES "(.+-)?llvm-$")
set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1})
endif () endif ()
elseif("${CMAKE_C_COMPILER_ID}" MATCHES "TI") elseif(CMAKE_C_COMPILER_ID MATCHES "TI")
# TI compilers are named e.g. cl6x, cl470 or armcl.exe # TI compilers are named e.g. cl6x, cl470 or armcl.exe
get_filename_component(COMPILER_BASENAME "${CMAKE_C_COMPILER}" NAME) get_filename_component(COMPILER_BASENAME "${CMAKE_C_COMPILER}" NAME)
if (COMPILER_BASENAME MATCHES "^(.+)?cl([^.]+)?(\\.exe)?$") if (COMPILER_BASENAME MATCHES "^(.+)?cl([^.]+)?(\\.exe)?$")

View File

@ -48,7 +48,7 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src)
CMAKE_DETERMINE_COMPILER_ID_VENDOR(${lang}) CMAKE_DETERMINE_COMPILER_ID_VENDOR(${lang})
endif() endif()
if (COMPILER_QNXNTO AND CMAKE_${lang}_COMPILER_ID STREQUAL GNU) if (COMPILER_QNXNTO AND CMAKE_${lang}_COMPILER_ID STREQUAL "GNU")
execute_process( execute_process(
COMMAND "${CMAKE_${lang}_COMPILER}" COMMAND "${CMAKE_${lang}_COMPILER}"
-V -V

View File

@ -152,12 +152,12 @@ if(NOT CMAKE_Fortran_COMPILER_ID_RUN)
endif() endif()
# Set old compiler and platform id variables. # Set old compiler and platform id variables.
if("${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU") if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
set(CMAKE_COMPILER_IS_GNUG77 1) set(CMAKE_COMPILER_IS_GNUG77 1)
endif() endif()
if("${CMAKE_Fortran_PLATFORM_ID}" MATCHES "MinGW") if(CMAKE_Fortran_PLATFORM_ID MATCHES "MinGW")
set(CMAKE_COMPILER_IS_MINGW 1) set(CMAKE_COMPILER_IS_MINGW 1)
elseif("${CMAKE_Fortran_PLATFORM_ID}" MATCHES "Cygwin") elseif(CMAKE_Fortran_PLATFORM_ID MATCHES "Cygwin")
set(CMAKE_COMPILER_IS_CYGWIN 1) set(CMAKE_COMPILER_IS_CYGWIN 1)
endif() endif()
endif() endif()
@ -175,7 +175,7 @@ endif ()
# "arm-unknown-nto-qnx6" instead of the correct "arm-unknown-nto-qnx6.3.0-" # "arm-unknown-nto-qnx6" instead of the correct "arm-unknown-nto-qnx6.3.0-"
if (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX) if (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX)
if("${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU") if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
get_filename_component(COMPILER_BASENAME "${CMAKE_Fortran_COMPILER}" NAME) get_filename_component(COMPILER_BASENAME "${CMAKE_Fortran_COMPILER}" NAME)
if (COMPILER_BASENAME MATCHES "^(.+-)g?fortran(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\.exe)?$") if (COMPILER_BASENAME MATCHES "^(.+-)g?fortran(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\.exe)?$")
set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1})

View File

@ -90,7 +90,7 @@ set(ENV{LANG} C)
# Now check for C, works for gcc and Intel compiler at least # Now check for C, works for gcc and Intel compiler at least
if (NOT CMAKE_EXTRA_GENERATOR_C_SYSTEM_INCLUDE_DIRS) if (NOT CMAKE_EXTRA_GENERATOR_C_SYSTEM_INCLUDE_DIRS)
if ("${CMAKE_C_COMPILER_ID}" MATCHES GNU OR "${CMAKE_C_COMPILER_ID}" MATCHES Intel OR "${CMAKE_C_COMPILER_ID}" MATCHES Clang) if (CMAKE_C_COMPILER_ID MATCHES GNU OR CMAKE_C_COMPILER_ID MATCHES Intel OR CMAKE_C_COMPILER_ID MATCHES Clang)
_DETERMINE_GCC_SYSTEM_INCLUDE_DIRS(c _dirs _defines) _DETERMINE_GCC_SYSTEM_INCLUDE_DIRS(c _dirs _defines)
set(CMAKE_EXTRA_GENERATOR_C_SYSTEM_INCLUDE_DIRS "${_dirs}" CACHE INTERNAL "C compiler system include directories") set(CMAKE_EXTRA_GENERATOR_C_SYSTEM_INCLUDE_DIRS "${_dirs}" CACHE INTERNAL "C compiler system include directories")
set(CMAKE_EXTRA_GENERATOR_C_SYSTEM_DEFINED_MACROS "${_defines}" CACHE INTERNAL "C compiler system defined macros") set(CMAKE_EXTRA_GENERATOR_C_SYSTEM_DEFINED_MACROS "${_defines}" CACHE INTERNAL "C compiler system defined macros")

View File

@ -30,12 +30,12 @@
# License text for the above reference.) # License text for the above reference.)
# if it's the MS C/CXX compiler, search for link # if it's the MS C/CXX compiler, search for link
if("${CMAKE_C_SIMULATE_ID}" STREQUAL "MSVC" if(CMAKE_C_SIMULATE_ID STREQUAL "MSVC"
OR "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC" OR CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC"
OR "${CMAKE_Fortran_SIMULATE_ID}" STREQUAL "MSVC" OR CMAKE_Fortran_SIMULATE_ID STREQUAL "MSVC"
OR "${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC" OR CMAKE_C_COMPILER_ID STREQUAL "MSVC"
OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" OR CMAKE_CXX_COMPILER_ID STREQUAL "MSVC"
OR ("${CMAKE_GENERATOR}" MATCHES "Visual Studio" OR (CMAKE_GENERATOR MATCHES "Visual Studio"
AND NOT CMAKE_VS_PLATFORM_NAME STREQUAL "Tegra-Android")) AND NOT CMAKE_VS_PLATFORM_NAME STREQUAL "Tegra-Android"))
find_program(CMAKE_LINKER NAMES link HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) find_program(CMAKE_LINKER NAMES link HINTS ${_CMAKE_TOOLCHAIN_LOCATION})

View File

@ -70,7 +70,7 @@ macro(CMAKE_FORCE_C_COMPILER compiler id)
set(CMAKE_C_COMPILER_FORCED TRUE) set(CMAKE_C_COMPILER_FORCED TRUE)
# Set old compiler id variables. # Set old compiler id variables.
if("${CMAKE_C_COMPILER_ID}" MATCHES "GNU") if(CMAKE_C_COMPILER_ID MATCHES "GNU")
set(CMAKE_COMPILER_IS_GNUCC 1) set(CMAKE_COMPILER_IS_GNUCC 1)
endif() endif()
endmacro() endmacro()
@ -94,7 +94,7 @@ macro(CMAKE_FORCE_Fortran_COMPILER compiler id)
set(CMAKE_Fortran_COMPILER_FORCED TRUE) set(CMAKE_Fortran_COMPILER_FORCED TRUE)
# Set old compiler id variables. # Set old compiler id variables.
if("${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU") if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
set(CMAKE_COMPILER_IS_GNUG77 1) set(CMAKE_COMPILER_IS_GNUG77 1)
endif() endif()
endmacro() endmacro()

View File

@ -160,7 +160,7 @@ set(_MPI_XL_Fortran_COMPILER_NAMES mpixlf95 mpixlf95_r mpxlf95 mpxlf95
# or if we know it matches the regular compiler. # or if we know it matches the regular compiler.
foreach (lang C CXX Fortran) foreach (lang C CXX Fortran)
foreach (id GNU Intel PGI XL) foreach (id GNU Intel PGI XL)
if (NOT CMAKE_${lang}_COMPILER_ID OR "${CMAKE_${lang}_COMPILER_ID}" STREQUAL "${id}") if (NOT CMAKE_${lang}_COMPILER_ID OR CMAKE_${lang}_COMPILER_ID STREQUAL id)
list(APPEND _MPI_${lang}_COMPILER_NAMES ${_MPI_${id}_${lang}_COMPILER_NAMES}) list(APPEND _MPI_${lang}_COMPILER_NAMES ${_MPI_${id}_${lang}_COMPILER_NAMES})
endif() endif()
unset(_MPI_${id}_${lang}_COMPILER_NAMES) # clean up the namespace here unset(_MPI_${id}_${lang}_COMPILER_NAMES) # clean up the namespace here

View File

@ -71,7 +71,7 @@ endif()
# Generate C symbol sources. # Generate C symbol sources.
set(symbol_sources) set(symbol_sources)
if(NOT "${CMAKE_Fortran_COMPILER_ID}" MATCHES "^(PathScale|Cray)$") if(NOT CMAKE_Fortran_COMPILER_ID MATCHES "^(PathScale|Cray)$")
# Provide mymodule_ and my_module_ init symbols because: # Provide mymodule_ and my_module_ init symbols because:
# - PGI Fortran uses module init symbols # - PGI Fortran uses module init symbols
# but not for: # but not for:

View File

@ -28,7 +28,7 @@ include(Platform/UnixPaths)
# eCos can be built only with gcc # eCos can be built only with gcc
get_property(_IN_TC GLOBAL PROPERTY IN_TRY_COMPILE) get_property(_IN_TC GLOBAL PROPERTY IN_TRY_COMPILE)
if(CMAKE_C_COMPILER AND NOT "${CMAKE_C_COMPILER_ID}" MATCHES "GNU" AND NOT _IN_TC) if(CMAKE_C_COMPILER AND NOT CMAKE_C_COMPILER_ID MATCHES "GNU" AND NOT _IN_TC)
message(FATAL_ERROR "GNU gcc is required for eCos") message(FATAL_ERROR "GNU gcc is required for eCos")
endif() endif()
if(CMAKE_CXX_COMPILER AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" AND NOT _IN_TC) if(CMAKE_CXX_COMPILER AND NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" AND NOT _IN_TC)

View File

@ -9,7 +9,7 @@ set(SRCS)
# and also generate assembler files from C: # and also generate assembler files from C:
if("${CMAKE_GENERATOR}" MATCHES "Makefile|Xcode" AND if("${CMAKE_GENERATOR}" MATCHES "Makefile|Xcode" AND
NOT CMAKE_OSX_ARCHITECTURES) NOT CMAKE_OSX_ARCHITECTURES)
if(("${CMAKE_C_COMPILER_ID}" MATCHES "^(GNU|Clang|AppleClang|HP|SunPro|XL)$") OR ("${CMAKE_C_COMPILER_ID}" STREQUAL "Intel" AND UNIX)) if((CMAKE_C_COMPILER_ID MATCHES "^(GNU|Clang|AppleClang|HP|SunPro|XL)$") OR (CMAKE_C_COMPILER_ID STREQUAL "Intel" AND UNIX))
set(C_FLAGS "${CMAKE_C_FLAGS}") set(C_FLAGS "${CMAKE_C_FLAGS}")
separate_arguments(C_FLAGS) separate_arguments(C_FLAGS)
if(CMAKE_OSX_SYSROOT AND CMAKE_C_SYSROOT_FLAG AND NOT ";${C_FLAGS};" MATCHES ";${CMAKE_C_SYSROOT_FLAG};") if(CMAKE_OSX_SYSROOT AND CMAKE_C_SYSROOT_FLAG AND NOT ";${C_FLAGS};" MATCHES ";${CMAKE_C_SYSROOT_FLAG};")

View File

@ -1501,7 +1501,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
set_tests_properties ( SimpleInstall-Stage2 PROPERTIES DEPENDS SimpleInstall) set_tests_properties ( SimpleInstall-Stage2 PROPERTIES DEPENDS SimpleInstall)
# Test static linking on toolchains known to support it. # Test static linking on toolchains known to support it.
if("${CMAKE_C_COMPILER_ID}" MATCHES "^(GNU)$" if(CMAKE_C_COMPILER_ID STREQUAL "GNU"
AND NOT APPLE AND NOT WIN32 AND NOT CYGWIN AND NOT APPLE AND NOT WIN32 AND NOT CYGWIN
AND EXISTS "/usr/lib/libm.a") AND EXISTS "/usr/lib/libm.a")
add_test(LinkStatic ${CMAKE_CTEST_COMMAND} add_test(LinkStatic ${CMAKE_CTEST_COMMAND}

View File

@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8.3.20110103)
project(ForceInclude C) project(ForceInclude C)
# Make sure the proper compiler is in use. # Make sure the proper compiler is in use.
if(NOT MSVC AND NOT "${CMAKE_C_COMPILER_ID}" MATCHES "^(Intel)$") if(NOT MSVC AND NOT CMAKE_C_COMPILER_ID STREQUAL "Intel")
message(FATAL_ERROR "The ForceInclude test works only with MSVC or Intel") message(FATAL_ERROR "The ForceInclude test works only with MSVC or Intel")
endif() endif()

View File

@ -13,11 +13,11 @@ message("CMAKE_Fortran_COMPILER = ${CMAKE_Fortran_COMPILER}")
message("CMAKE_Fortran_FLAGS = ${CMAKE_Fortran_FLAGS}") message("CMAKE_Fortran_FLAGS = ${CMAKE_Fortran_FLAGS}")
set(_SHARED SHARED) set(_SHARED SHARED)
if("${CMAKE_Fortran_COMPILER_ID}" MATCHES "^(XL|VisualAge)$") if(CMAKE_Fortran_COMPILER_ID MATCHES "^(XL|VisualAge)$")
# We do not implement SHARED Fortran libs on AIX yet! # We do not implement SHARED Fortran libs on AIX yet!
# Workaround: Set LINKER_LANGUAGE to C, which uses 'xlc' and Fortran implicits. # Workaround: Set LINKER_LANGUAGE to C, which uses 'xlc' and Fortran implicits.
set(_SHARED STATIC) set(_SHARED STATIC)
elseif("${CMAKE_Fortran_COMPILER_ID}" STREQUAL "GNU") elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
# g77 2.96 does not support shared libs on Itanium because g2c is not -fPIC # g77 2.96 does not support shared libs on Itanium because g2c is not -fPIC
execute_process(COMMAND ${CMAKE_Fortran_COMPILER} --version execute_process(COMMAND ${CMAKE_Fortran_COMPILER} --version
OUTPUT_VARIABLE output ERROR_VARIABLE output) OUTPUT_VARIABLE output ERROR_VARIABLE output)
@ -29,10 +29,10 @@ endif()
# Pick a module .def file with the properly mangled symbol name. # Pick a module .def file with the properly mangled symbol name.
set(world_def "") set(world_def "")
if(WIN32 AND NOT CYGWIN) if(WIN32 AND NOT CYGWIN)
if("${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU") if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
set(world_def world_gnu.def) set(world_def world_gnu.def)
elseif("${CMAKE_Fortran_COMPILER_ID}" MATCHES "Intel" OR elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Intel" OR
"${CMAKE_GENERATOR}" MATCHES "Visual Studio") # Intel plugin CMAKE_GENERATOR MATCHES "Visual Studio") # Intel plugin
set(world_def world_icl.def) set(world_def world_icl.def)
endif() endif()
endif() endif()
@ -119,7 +119,7 @@ endfunction()
# call the test_fortran_c_interface_module function # call the test_fortran_c_interface_module function
if("${CMAKE_Fortran_COMPILER_ID}:${CMAKE_C_COMPILER_ID}" MATCHES if("${CMAKE_Fortran_COMPILER_ID}:${CMAKE_C_COMPILER_ID}" MATCHES
"(Intel:MSVC|Absoft:GNU)" "(Intel:MSVC|Absoft:GNU)"
OR ("${CMAKE_Fortran_COMPILER_ID}" MATCHES "${CMAKE_C_COMPILER_ID}" )) OR (CMAKE_Fortran_COMPILER_ID MATCHES CMAKE_C_COMPILER_ID ))
test_fortran_c_interface_module() test_fortran_c_interface_module()
else() else()
message("Fortran does not match c compiler") message("Fortran does not match c compiler")
@ -128,7 +128,7 @@ else()
# hack to make g77 work after CL has been enabled # hack to make g77 work after CL has been enabled
# as a languge, cmake needs language specific versions # as a languge, cmake needs language specific versions
# of these variables.... # of these variables....
if(WIN32 AND "${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU") if(WIN32 AND CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
set(CMAKE_CREATE_CONSOLE_EXE ) set(CMAKE_CREATE_CONSOLE_EXE )
set(CMAKE_LIBRARY_PATH_FLAG "-L") set(CMAKE_LIBRARY_PATH_FLAG "-L")
set(CMAKE_LINK_LIBRARY_FLAG "-l") set(CMAKE_LINK_LIBRARY_FLAG "-l")
@ -137,8 +137,8 @@ else()
# gnu and sunpro do not use the same flags here... # gnu and sunpro do not use the same flags here...
# however if LDFLAGS is used to set -m64 it causes odd stuf # however if LDFLAGS is used to set -m64 it causes odd stuf
# with the fortran build # with the fortran build
if( ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU") if( (CMAKE_C_COMPILER_ID MATCHES "GNU")
AND ("${CMAKE_Fortran_COMPILER_ID}" MATCHES "SunPro")) AND (CMAKE_Fortran_COMPILER_ID MATCHES "SunPro"))
set(CMAKE_EXE_LINKER_FLAGS "") set(CMAKE_EXE_LINKER_FLAGS "")
set(CMAKE_Fortran_FLAGS "") set(CMAKE_Fortran_FLAGS "")
endif() endif()

View File

@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8)
project(FortranC C Fortran) project(FortranC C Fortran)
# Skip this test for compilers not known to be compatible. # Skip this test for compilers not known to be compatible.
if(NOT ("${CMAKE_C_COMPILER_ID}" STREQUAL "${CMAKE_Fortran_COMPILER_ID}" OR if(NOT (CMAKE_C_COMPILER_ID STREQUAL CMAKE_Fortran_COMPILER_ID OR
"${CMAKE_C_COMPILER_ID}-${CMAKE_Fortran_COMPILER_ID}" MATCHES "^(MSVC-Intel)$")) "${CMAKE_C_COMPILER_ID}-${CMAKE_Fortran_COMPILER_ID}" MATCHES "^(MSVC-Intel)$"))
message(STATUS "${CMAKE_C_COMPILER_ID} C and ${CMAKE_Fortran_COMPILER_ID} Fortran not known to be compatible!") message(STATUS "${CMAKE_C_COMPILER_ID} C and ${CMAKE_Fortran_COMPILER_ID} Fortran not known to be compatible!")
return() return()

View File

@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 2.8.4.20110303 FATAL_ERROR) cmake_minimum_required(VERSION 2.8.4.20110303 FATAL_ERROR)
project(LinkStatic C) project(LinkStatic C)
if(NOT "${CMAKE_C_COMPILER_ID}" MATCHES "^(GNU)$") if(NOT CMAKE_C_COMPILER_ID STREQUAL "GNU")
message(FATAL_ERROR "This test works only with the GNU compiler!") message(FATAL_ERROR "This test works only with the GNU compiler!")
endif() endif()

View File

@ -13,7 +13,7 @@ add_custom_command(OUTPUT example_dll_gen.def
add_library(example_dll_gen SHARED example_dll_gen.c example_dll_gen.def) add_library(example_dll_gen SHARED example_dll_gen.c example_dll_gen.def)
# Test /DEF:<file> flag recognition for VS. # Test /DEF:<file> flag recognition for VS.
if(MSVC OR "${CMAKE_C_COMPILER_ID}" MATCHES "^(Intel)$") if(MSVC OR CMAKE_C_COMPILER_ID STREQUAL "Intel")
add_library(example_dll_2 SHARED example_dll_2.c) add_library(example_dll_2 SHARED example_dll_2.c)
set_property(TARGET example_dll_2 PROPERTY LINK_FLAGS set_property(TARGET example_dll_2 PROPERTY LINK_FLAGS
/DEF:"${ModuleDefinition_SOURCE_DIR}/example_dll_2.def") /DEF:"${ModuleDefinition_SOURCE_DIR}/example_dll_2.def")

View File

@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8)
project(PDBDirectoryAndName C) project(PDBDirectoryAndName C)
# Make sure the proper compiler is in use. # Make sure the proper compiler is in use.
if(NOT MSVC AND NOT "${CMAKE_C_COMPILER_ID}" MATCHES "^(Intel)$") if(NOT MSVC AND NOT CMAKE_C_COMPILER_ID STREQUAL "Intel")
message(FATAL_ERROR "The PDBDirectoryAndName test works only with MSVC or Intel") message(FATAL_ERROR "The PDBDirectoryAndName test works only with MSVC or Intel")
endif() endif()

View File

@ -2,7 +2,7 @@ cmake_minimum_required (VERSION 2.6)
project(PrecompiledHeader C) project(PrecompiledHeader C)
# Make sure the proper compiler is in use. # Make sure the proper compiler is in use.
if(NOT MSVC AND NOT "${CMAKE_C_COMPILER_ID}" MATCHES "^(Intel)$") if(NOT MSVC AND NOT CMAKE_C_COMPILER_ID STREQUAL "Intel")
message(FATAL_ERROR "The PrecompiledHeader test works only with MSVC or Intel") message(FATAL_ERROR "The PrecompiledHeader test works only with MSVC or Intel")
endif() endif()

View File

@ -114,7 +114,7 @@ endif()
set(EXPR_OP1 "/") set(EXPR_OP1 "/")
if((NOT MSVC OR PP_NMAKE) AND if((NOT MSVC OR PP_NMAKE) AND
NOT "${CMAKE_C_COMPILER_ID}" MATCHES "^(Intel)$") NOT CMAKE_C_COMPILER_ID STREQUAL "Intel")
# MSVC cl, Intel icl: % # MSVC cl, Intel icl: %
# When the cl compiler is invoked from the command line then % must # When the cl compiler is invoked from the command line then % must
# be written %% (to distinguish from %ENV% syntax). However cl does # be written %% (to distinguish from %ENV% syntax). However cl does

View File

@ -265,7 +265,7 @@ TEST_FAIL(CXX_RUN_SHOULD_FAIL "CHECK_CXX_SOURCE_RUNS() succeeded, but should hav
TEST_ASSERT(CXX_RUN_SHOULD_WORK "CHECK_CXX_SOURCE_RUNS() failed") TEST_ASSERT(CXX_RUN_SHOULD_WORK "CHECK_CXX_SOURCE_RUNS() failed")
foreach(lang C CXX) foreach(lang C CXX)
if(NOT "${CMAKE_${lang}_COMPILER_ID}" MATCHES "^(PathScale)$") if(NOT CMAKE_${lang}_COMPILER_ID STREQUAL "PathScale")
set(${lang}_DD --) set(${lang}_DD --)
endif() endif()
endforeach() endforeach()
@ -280,7 +280,7 @@ include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG(${CXX_DD}-_this_is_not_a_flag_ CXX_BOGUS_FLAG) CHECK_CXX_COMPILER_FLAG(${CXX_DD}-_this_is_not_a_flag_ CXX_BOGUS_FLAG)
TEST_FAIL(CXX_BOGUS_FLAG "CHECK_CXX_COMPILER_FLAG() succeeded, but should have failed") TEST_FAIL(CXX_BOGUS_FLAG "CHECK_CXX_COMPILER_FLAG() succeeded, but should have failed")
if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
unset(C_STRICT_PROTOTYPES CACHE) unset(C_STRICT_PROTOTYPES CACHE)
CHECK_C_COMPILER_FLAG("-Werror;-Wstrict-prototypes" C_STRICT_PROTOTYPES) CHECK_C_COMPILER_FLAG("-Werror;-Wstrict-prototypes" C_STRICT_PROTOTYPES)
TEST_ASSERT(C_STRICT_PROTOTYPES "CHECK_C_COMPILER_FLAG failed -Werror -Wstrict-prototypes") TEST_ASSERT(C_STRICT_PROTOTYPES "CHECK_C_COMPILER_FLAG failed -Werror -Wstrict-prototypes")

View File

@ -20,7 +20,7 @@ set_property(DIRECTORY
# Suppress printf/scanf format warnings; we test if the sizes match. # Suppress printf/scanf format warnings; we test if the sizes match.
foreach(lang C CXX) foreach(lang C CXX)
if(KWIML_LANGUAGE_${lang} AND "${CMAKE_${lang}_COMPILER_ID}" STREQUAL GNU) if(KWIML_LANGUAGE_${lang} AND CMAKE_${lang}_COMPILER_ID STREQUAL "GNU")
set(CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS} -Wno-format") set(CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS} -Wno-format")
endif() endif()
endforeach() endforeach()

View File

@ -56,10 +56,10 @@ SET(CMAKE_REQUIRED_LIBRARIES)
SET(CMAKE_REQUIRED_FLAGS) SET(CMAKE_REQUIRED_FLAGS)
# Disable warnings to avoid changing 3rd party code. # Disable warnings to avoid changing 3rd party code.
IF("${CMAKE_C_COMPILER_ID}" MATCHES IF(CMAKE_C_COMPILER_ID MATCHES
"^(GNU|Clang|AppleClang|XL|VisualAge|SunPro|MIPSpro|HP|Intel)$") "^(GNU|Clang|AppleClang|XL|VisualAge|SunPro|MIPSpro|HP|Intel)$")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w")
ELSEIF("${CMAKE_C_COMPILER_ID}" MATCHES "^(PathScale)$") ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "PathScale")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -woffall") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -woffall")
ELSEIF(BORLAND) ELSEIF(BORLAND)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w-") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w-")
@ -666,14 +666,14 @@ ENDMACRO(CHECK_CRYPTO_WIN CRYPTO_LIST)
MACRO(CHECK_ICONV LIB TRY_ICONV_CONST) MACRO(CHECK_ICONV LIB TRY_ICONV_CONST)
IF(NOT HAVE_ICONV) IF(NOT HAVE_ICONV)
CMAKE_PUSH_CHECK_STATE() # Save the state of the variables CMAKE_PUSH_CHECK_STATE() # Save the state of the variables
IF ("CMAKE_C_COMPILER_ID" MATCHES "^GNU$") IF (CMAKE_C_COMPILER_ID STREQUAL "GNU")
# #
# During checking iconv proto type, we should use -Werror to avoid the # During checking iconv proto type, we should use -Werror to avoid the
# success of iconv detection with a warnig which success is a miss # success of iconv detection with a warnig which success is a miss
# detection. So this needs for all build mode(even it's a release mode). # detection. So this needs for all build mode(even it's a release mode).
# #
SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror") SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror")
ENDIF ("CMAKE_C_COMPILER_ID" MATCHES "^GNU$") ENDIF (CMAKE_C_COMPILER_ID STREQUAL "GNU")
IF (MSVC) IF (MSVC)
# NOTE: /WX option is the same as gcc's -Werror option. # NOTE: /WX option is the same as gcc's -Werror option.
SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} /WX") SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} /WX")

View File

@ -201,10 +201,10 @@ INCLUDE_DIRECTORIES(
) )
# Disable warnings to avoid changing 3rd party code. # Disable warnings to avoid changing 3rd party code.
IF("${CMAKE_C_COMPILER_ID}" MATCHES IF(CMAKE_C_COMPILER_ID MATCHES
"^(GNU|Clang|AppleClang|XL|VisualAge|SunPro|MIPSpro|HP|Intel)$") "^(GNU|Clang|AppleClang|XL|VisualAge|SunPro|MIPSpro|HP|Intel)$")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w")
ELSEIF("${CMAKE_C_COMPILER_ID}" MATCHES "^(PathScale)$") ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "PathScale")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -woffall") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -woffall")
ELSEIF(BORLAND) ELSEIF(BORLAND)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w-") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w-")