diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2014-10-14 14:25:32 (GMT) |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2014-10-20 15:49:16 (GMT) |
commit | 29c3edb87adedd82e816552d958f4c3540a1511b (patch) | |
tree | 089cea993a6c212b2107554eeca443e48993ca08 /Tests | |
parent | a7596fef6e8d6938ce0d7fcba47e896f288b12b4 (diff) | |
download | CMake-29c3edb87adedd82e816552d958f4c3540a1511b.zip CMake-29c3edb87adedd82e816552d958f4c3540a1511b.tar.gz CMake-29c3edb87adedd82e816552d958f4c3540a1511b.tar.bz2 |
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.
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/Assembler/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Tests/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Tests/ForceInclude/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Tests/Fortran/CMakeLists.txt | 18 | ||||
-rw-r--r-- | Tests/FortranC/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Tests/LinkStatic/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Tests/ModuleDefinition/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Tests/PDBDirectoryAndName/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Tests/PrecompiledHeader/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Tests/Preprocess/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Tests/TryCompile/CMakeLists.txt | 4 |
11 files changed, 20 insertions, 20 deletions
diff --git a/Tests/Assembler/CMakeLists.txt b/Tests/Assembler/CMakeLists.txt index fdc5c00..fb17ebb 100644 --- a/Tests/Assembler/CMakeLists.txt +++ b/Tests/Assembler/CMakeLists.txt @@ -9,7 +9,7 @@ set(SRCS) # and also generate assembler files from C: if("${CMAKE_GENERATOR}" MATCHES "Makefile|Xcode" AND 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}") separate_arguments(C_FLAGS) if(CMAKE_OSX_SYSROOT AND CMAKE_C_SYSROOT_FLAG AND NOT ";${C_FLAGS};" MATCHES ";${CMAKE_C_SYSROOT_FLAG};") diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 25cc846..f93ae35 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -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) # 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 EXISTS "/usr/lib/libm.a") add_test(LinkStatic ${CMAKE_CTEST_COMMAND} diff --git a/Tests/ForceInclude/CMakeLists.txt b/Tests/ForceInclude/CMakeLists.txt index 5c02ebb..e231054 100644 --- a/Tests/ForceInclude/CMakeLists.txt +++ b/Tests/ForceInclude/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8.3.20110103) project(ForceInclude C) # 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") endif() diff --git a/Tests/Fortran/CMakeLists.txt b/Tests/Fortran/CMakeLists.txt index 1982a60..8700c94 100644 --- a/Tests/Fortran/CMakeLists.txt +++ b/Tests/Fortran/CMakeLists.txt @@ -13,11 +13,11 @@ message("CMAKE_Fortran_COMPILER = ${CMAKE_Fortran_COMPILER}") message("CMAKE_Fortran_FLAGS = ${CMAKE_Fortran_FLAGS}") 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! # Workaround: Set LINKER_LANGUAGE to C, which uses 'xlc' and Fortran implicits. 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 execute_process(COMMAND ${CMAKE_Fortran_COMPILER} --version OUTPUT_VARIABLE output ERROR_VARIABLE output) @@ -29,10 +29,10 @@ endif() # Pick a module .def file with the properly mangled symbol name. set(world_def "") 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) - elseif("${CMAKE_Fortran_COMPILER_ID}" MATCHES "Intel" OR - "${CMAKE_GENERATOR}" MATCHES "Visual Studio") # Intel plugin + elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Intel" OR + CMAKE_GENERATOR MATCHES "Visual Studio") # Intel plugin set(world_def world_icl.def) endif() endif() @@ -119,7 +119,7 @@ endfunction() # call the test_fortran_c_interface_module function if("${CMAKE_Fortran_COMPILER_ID}:${CMAKE_C_COMPILER_ID}" MATCHES "(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() else() message("Fortran does not match c compiler") @@ -128,7 +128,7 @@ else() # hack to make g77 work after CL has been enabled # as a languge, cmake needs language specific versions # 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_LIBRARY_PATH_FLAG "-L") set(CMAKE_LINK_LIBRARY_FLAG "-l") @@ -137,8 +137,8 @@ else() # gnu and sunpro do not use the same flags here... # however if LDFLAGS is used to set -m64 it causes odd stuf # with the fortran build - if( ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU") - AND ("${CMAKE_Fortran_COMPILER_ID}" MATCHES "SunPro")) + if( (CMAKE_C_COMPILER_ID MATCHES "GNU") + AND (CMAKE_Fortran_COMPILER_ID MATCHES "SunPro")) set(CMAKE_EXE_LINKER_FLAGS "") set(CMAKE_Fortran_FLAGS "") endif() diff --git a/Tests/FortranC/CMakeLists.txt b/Tests/FortranC/CMakeLists.txt index f335583..79c670d 100644 --- a/Tests/FortranC/CMakeLists.txt +++ b/Tests/FortranC/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8) project(FortranC C Fortran) # 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)$")) message(STATUS "${CMAKE_C_COMPILER_ID} C and ${CMAKE_Fortran_COMPILER_ID} Fortran not known to be compatible!") return() diff --git a/Tests/LinkStatic/CMakeLists.txt b/Tests/LinkStatic/CMakeLists.txt index 2062c43..200d4e5 100644 --- a/Tests/LinkStatic/CMakeLists.txt +++ b/Tests/LinkStatic/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 2.8.4.20110303 FATAL_ERROR) 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!") endif() diff --git a/Tests/ModuleDefinition/CMakeLists.txt b/Tests/ModuleDefinition/CMakeLists.txt index a30f643..bfbb343 100644 --- a/Tests/ModuleDefinition/CMakeLists.txt +++ b/Tests/ModuleDefinition/CMakeLists.txt @@ -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) # 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) set_property(TARGET example_dll_2 PROPERTY LINK_FLAGS /DEF:"${ModuleDefinition_SOURCE_DIR}/example_dll_2.def") diff --git a/Tests/PDBDirectoryAndName/CMakeLists.txt b/Tests/PDBDirectoryAndName/CMakeLists.txt index 90af600..180f9fe 100644 --- a/Tests/PDBDirectoryAndName/CMakeLists.txt +++ b/Tests/PDBDirectoryAndName/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8) project(PDBDirectoryAndName C) # 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") endif() diff --git a/Tests/PrecompiledHeader/CMakeLists.txt b/Tests/PrecompiledHeader/CMakeLists.txt index 6958131..98bdd88 100644 --- a/Tests/PrecompiledHeader/CMakeLists.txt +++ b/Tests/PrecompiledHeader/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required (VERSION 2.6) project(PrecompiledHeader C) # 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") endif() diff --git a/Tests/Preprocess/CMakeLists.txt b/Tests/Preprocess/CMakeLists.txt index cdfdcc1..8ff0cfd 100644 --- a/Tests/Preprocess/CMakeLists.txt +++ b/Tests/Preprocess/CMakeLists.txt @@ -114,7 +114,7 @@ endif() set(EXPR_OP1 "/") 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: % # When the cl compiler is invoked from the command line then % must # be written %% (to distinguish from %ENV% syntax). However cl does diff --git a/Tests/TryCompile/CMakeLists.txt b/Tests/TryCompile/CMakeLists.txt index a4d9490..e497503 100644 --- a/Tests/TryCompile/CMakeLists.txt +++ b/Tests/TryCompile/CMakeLists.txt @@ -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") foreach(lang C CXX) - if(NOT "${CMAKE_${lang}_COMPILER_ID}" MATCHES "^(PathScale)$") + if(NOT CMAKE_${lang}_COMPILER_ID STREQUAL "PathScale") set(${lang}_DD --) endif() endforeach() @@ -280,7 +280,7 @@ include(CheckCXXCompilerFlag) 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") -if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") +if(CMAKE_C_COMPILER_ID STREQUAL "GNU") unset(C_STRICT_PROTOTYPES CACHE) CHECK_C_COMPILER_FLAG("-Werror;-Wstrict-prototypes" C_STRICT_PROTOTYPES) TEST_ASSERT(C_STRICT_PROTOTYPES "CHECK_C_COMPILER_FLAG failed -Werror -Wstrict-prototypes") |