Check*: Tolerate variables set with names of languages
Fix the language checks added by commit90dead024c
(CheckCompilerFlag: unified way to check compiler flags per language, 2020-09-25, v3.19.0-rc1~88^2), commit10ae907de0
(CheckSoureCompiles: Add a unified way to check if a source compiles, 2020-09-14, v3.19.0-rc1~118^2~1), and commit357e2ef429
(CheckSoureRuns: Add a unified way to check if a source runs, 2020-09-14, v3.19.0-rc1~118^2) to work when variables of the language names are set. Fixes: #21500
This commit is contained in:
parent
01d91ae5f2
commit
f3d4254b3d
@ -11,20 +11,20 @@ cmake_policy(SET CMP0057 NEW) # if() supports IN_LIST
|
||||
|
||||
function(CMAKE_CHECK_COMPILER_FLAG _lang _flag _var)
|
||||
|
||||
if(_lang STREQUAL C)
|
||||
if(_lang STREQUAL "C")
|
||||
set(_lang_src "int main(void) { return 0; }")
|
||||
set(_lang_fail_regex FAIL_REGEX "command[ -]line option .* is valid for .* but not for C")
|
||||
elseif(_lang STREQUAL CXX)
|
||||
elseif(_lang STREQUAL "CXX")
|
||||
set(_lang_src "int main() { return 0; }")
|
||||
set(_lang_fail_regex FAIL_REGEX "command[ -]line option .* is valid for .* but not for C\\+\\+")
|
||||
elseif(_lang STREQUAL CUDA)
|
||||
elseif(_lang STREQUAL "CUDA")
|
||||
set(_lang_src "__host__ int main() { return 0; }")
|
||||
set(_lang_fail_regex FAIL_REGEX "command[ -]line option .* is valid for .* but not for C\\+\\+" # Host GNU
|
||||
FAIL_REGEX "argument unused during compilation: .*") # Clang
|
||||
elseif(_lang STREQUAL Fortran)
|
||||
elseif(_lang STREQUAL "Fortran")
|
||||
set(_lang_src " program test\n stop\n end program")
|
||||
set(_lang_fail_regex FAIL_REGEX "command[ -]line option .* is valid for .* but not for Fortran")
|
||||
elseif(_lang STREQUAL OBJC)
|
||||
elseif(_lang STREQUAL "OBJC")
|
||||
set(_lang_src [=[
|
||||
#ifndef __OBJC__
|
||||
# error "Not an Objective-C compiler"
|
||||
@ -32,7 +32,7 @@ function(CMAKE_CHECK_COMPILER_FLAG _lang _flag _var)
|
||||
int main(void) { return 0; }]=])
|
||||
set(_lang_fail_regex FAIL_REGEX "command[ -]line option .* is valid for .* but not for Objective-C" # GNU
|
||||
FAIL_REGEX "argument unused during compilation: .*") # Clang
|
||||
elseif(_lang STREQUAL OBJCXX)
|
||||
elseif(_lang STREQUAL "OBJCXX")
|
||||
set(_lang_src [=[
|
||||
#ifndef __OBJC__
|
||||
# error "Not an Objective-C++ compiler"
|
||||
@ -40,7 +40,7 @@ int main(void) { return 0; }]=])
|
||||
int main(void) { return 0; }]=])
|
||||
set(_lang_fail_regex FAIL_REGEX "command[ -]line option .* is valid for .* but not for Objective-C\\+\\+" # GNU
|
||||
FAIL_REGEX "argument unused during compilation: .*") # Clang
|
||||
elseif(_lang STREQUAL ISPC)
|
||||
elseif(_lang STREQUAL "ISPC")
|
||||
set(_lang_src "float func(uniform int32, float a) { return a / 2.25; }")
|
||||
else()
|
||||
message (SEND_ERROR "check_compiler_flag: ${_lang}: unknown language.")
|
||||
|
@ -10,25 +10,25 @@ cmake_policy(SET CMP0057 NEW) # if() supports IN_LIST
|
||||
function(CMAKE_CHECK_SOURCE_COMPILES _lang _source _var)
|
||||
if(NOT DEFINED "${_var}")
|
||||
|
||||
if(_lang STREQUAL C)
|
||||
if(_lang STREQUAL "C")
|
||||
set(_lang_textual "C")
|
||||
set(_lang_ext "c")
|
||||
elseif(_lang STREQUAL CXX)
|
||||
elseif(_lang STREQUAL "CXX")
|
||||
set(_lang_textual "C++")
|
||||
set(_lang_ext "cxx")
|
||||
elseif(_lang STREQUAL CUDA)
|
||||
elseif(_lang STREQUAL "CUDA")
|
||||
set(_lang_textual "CUDA")
|
||||
set(_lang_ext "cu")
|
||||
elseif(_lang STREQUAL Fortran)
|
||||
elseif(_lang STREQUAL "Fortran")
|
||||
set(_lang_textual "Fortran")
|
||||
set(_lang_ext "F90")
|
||||
elseif(_lang STREQUAL ISPC)
|
||||
elseif(_lang STREQUAL "ISPC")
|
||||
set(_lang_textual "ISPC")
|
||||
set(_lang_ext "ispc")
|
||||
elseif(_lang STREQUAL OBJC)
|
||||
elseif(_lang STREQUAL "OBJC")
|
||||
set(_lang_textual "Objective-C")
|
||||
set(_lang_ext "m")
|
||||
elseif(_lang STREQUAL OBJCXX)
|
||||
elseif(_lang STREQUAL "OBJCXX")
|
||||
set(_lang_textual "Objective-C++")
|
||||
set(_lang_ext "mm")
|
||||
else()
|
||||
|
@ -10,22 +10,22 @@ cmake_policy(SET CMP0057 NEW) # if() supports IN_LIST
|
||||
function(CMAKE_CHECK_SOURCE_RUNS _lang _source _var)
|
||||
if(NOT DEFINED "${_var}")
|
||||
|
||||
if(_lang STREQUAL C)
|
||||
if(_lang STREQUAL "C")
|
||||
set(_lang_textual "C")
|
||||
set(_lang_ext "c")
|
||||
elseif(_lang STREQUAL CXX)
|
||||
elseif(_lang STREQUAL "CXX")
|
||||
set(_lang_textual "C++")
|
||||
set(_lang_ext "cxx")
|
||||
elseif(_lang STREQUAL CUDA)
|
||||
elseif(_lang STREQUAL "CUDA")
|
||||
set(_lang_textual "CUDA")
|
||||
set(_lang_ext "cu")
|
||||
elseif(_lang STREQUAL Fortran)
|
||||
elseif(_lang STREQUAL "Fortran")
|
||||
set(_lang_textual "Fortran")
|
||||
set(_lang_ext "F90")
|
||||
elseif(_lang STREQUAL OBJC)
|
||||
elseif(_lang STREQUAL "OBJC")
|
||||
set(_lang_textual "Objective-C")
|
||||
set(_lang_ext "m")
|
||||
elseif(_lang STREQUAL OBJCXX)
|
||||
elseif(_lang STREQUAL "OBJCXX")
|
||||
set(_lang_textual "Objective-C++")
|
||||
set(_lang_ext "mm")
|
||||
else()
|
||||
|
@ -2,6 +2,8 @@
|
||||
enable_language (C)
|
||||
include(CheckCompilerFlag)
|
||||
|
||||
set(C 1) # test that this is tolerated
|
||||
|
||||
check_compiler_flag(C "-_this_is_not_a_flag_" SHOULD_FAIL)
|
||||
if(SHOULD_FAIL)
|
||||
message(SEND_ERROR "invalid C compile flag didn't fail.")
|
||||
|
@ -2,6 +2,8 @@
|
||||
enable_language (CUDA)
|
||||
include(CheckCompilerFlag)
|
||||
|
||||
set(CUDA 1) # test that this is tolerated
|
||||
|
||||
check_compiler_flag(CUDA "-_this_is_not_a_flag_" SHOULD_FAIL)
|
||||
if(SHOULD_FAIL)
|
||||
message(SEND_ERROR "invalid CUDA compile flag didn't fail.")
|
||||
|
@ -2,6 +2,8 @@
|
||||
enable_language (CXX)
|
||||
include(CheckCompilerFlag)
|
||||
|
||||
set(CXX 1) # test that this is tolerated
|
||||
|
||||
check_compiler_flag(CXX "-_this_is_not_a_flag_" SHOULD_FAIL)
|
||||
if(SHOULD_FAIL)
|
||||
message(SEND_ERROR "invalid CXX compile flag didn't fail.")
|
||||
|
@ -1,6 +1,8 @@
|
||||
enable_language (Fortran)
|
||||
include(CheckCompilerFlag)
|
||||
|
||||
set(Fortran 1) # test that this is tolerated
|
||||
|
||||
check_compiler_flag(Fortran "-_this_is_not_a_flag_" SHOULD_FAIL)
|
||||
if(SHOULD_FAIL)
|
||||
message(SEND_ERROR "invalid Fortran compile flag didn't fail.")
|
||||
|
@ -1,6 +1,8 @@
|
||||
enable_language (OBJC)
|
||||
include(CheckCompilerFlag)
|
||||
|
||||
set(OBJC 1) # test that this is tolerated
|
||||
|
||||
check_compiler_flag(OBJC "-_this_is_not_a_flag_" SHOULD_FAIL)
|
||||
if(SHOULD_FAIL)
|
||||
message(SEND_ERROR "invalid OBJC compile flag didn't fail.")
|
||||
|
@ -1,6 +1,8 @@
|
||||
enable_language (OBJCXX)
|
||||
include(CheckCompilerFlag)
|
||||
|
||||
set(OBJCXX 1) # test that this is tolerated
|
||||
|
||||
check_compiler_flag(OBJCXX "-_this_is_not_a_flag_" SHOULD_FAIL)
|
||||
if(SHOULD_FAIL)
|
||||
message(SEND_ERROR "invalid OBJCXX compile flag didn't fail.")
|
||||
|
@ -2,6 +2,8 @@
|
||||
enable_language (C)
|
||||
include(CheckSourceCompiles)
|
||||
|
||||
set(C 1) # test that this is tolerated
|
||||
|
||||
check_source_compiles(C "I don't build" SHOULD_FAIL)
|
||||
if(SHOULD_FAIL)
|
||||
message(SEND_ERROR "invalid C source didn't fail.")
|
||||
|
@ -2,6 +2,8 @@
|
||||
enable_language (CUDA)
|
||||
include(CheckSourceCompiles)
|
||||
|
||||
set(CUDA 1) # test that this is tolerated
|
||||
|
||||
check_source_compiles(CUDA "I don't build" SHOULD_FAIL)
|
||||
if(SHOULD_FAIL)
|
||||
message(SEND_ERROR "invalid CUDA source didn't fail.")
|
||||
|
@ -2,6 +2,8 @@
|
||||
enable_language (CXX)
|
||||
include(CheckSourceCompiles)
|
||||
|
||||
set(CXX 1) # test that this is tolerated
|
||||
|
||||
check_source_compiles(CXX "I don't build" SHOULD_FAIL)
|
||||
if(SHOULD_FAIL)
|
||||
message(SEND_ERROR "invalid CXX source didn't fail.")
|
||||
|
@ -3,6 +3,8 @@
|
||||
enable_language (Fortran)
|
||||
include(CheckSourceCompiles)
|
||||
|
||||
set(Fortran 1) # test that this is tolerated
|
||||
|
||||
check_source_compiles(Fortran [=[
|
||||
PROGRAM TEST_HAVE_PRINT
|
||||
PRINT *, 'Hello'
|
||||
|
@ -1,6 +1,8 @@
|
||||
enable_language (OBJC)
|
||||
include(CheckSourceCompiles)
|
||||
|
||||
set(OBJC 1) # test that this is tolerated
|
||||
|
||||
check_source_compiles(OBJC [[
|
||||
#import <Foundation/Foundation.h>
|
||||
int main() {
|
||||
|
@ -1,6 +1,8 @@
|
||||
enable_language (OBJCXX)
|
||||
include(CheckSourceCompiles)
|
||||
|
||||
set(OBJCXX 1) # test that this is tolerated
|
||||
|
||||
check_source_compiles(OBJCXX [[
|
||||
#include <vector>
|
||||
#import <Foundation/Foundation.h>
|
||||
|
@ -2,6 +2,8 @@
|
||||
enable_language (C)
|
||||
include(CheckSourceRuns)
|
||||
|
||||
set(C 1) # test that this is tolerated
|
||||
|
||||
check_source_runs(C "int main() {return 2;}" SHOULD_FAIL)
|
||||
if(SHOULD_FAIL)
|
||||
message(SEND_ERROR "C check_source_runs succeeded, but should have failed.")
|
||||
|
@ -2,6 +2,8 @@
|
||||
enable_language (CUDA)
|
||||
include(CheckSourceRuns)
|
||||
|
||||
set(CUDA 1) # test that this is tolerated
|
||||
|
||||
check_source_runs(CUDA "int main() {return 2;}" SHOULD_FAIL)
|
||||
if(SHOULD_FAIL)
|
||||
message(SEND_ERROR "CUDA check_source_runs succeeded, but should have failed.")
|
||||
|
@ -2,6 +2,8 @@
|
||||
enable_language (CXX)
|
||||
include(CheckSourceRuns)
|
||||
|
||||
set(CXX 1) # test that this is tolerated
|
||||
|
||||
check_source_runs(CXX "int main() {return 2;}" SHOULD_FAIL)
|
||||
if(SHOULD_FAIL)
|
||||
message(SEND_ERROR "CXX check_source_runs succeeded, but should have failed.")
|
||||
|
@ -3,6 +3,8 @@
|
||||
enable_language (Fortran)
|
||||
include(CheckSourceRuns)
|
||||
|
||||
set(Fortran 1) # test that this is tolerated
|
||||
|
||||
check_source_runs(Fortran [=[
|
||||
PROGRAM TEST_HAVE_PRINT
|
||||
PRINT *, 'Hello'
|
||||
|
@ -1,6 +1,8 @@
|
||||
enable_language (OBJC)
|
||||
include(CheckSourceRuns)
|
||||
|
||||
set(OBJC 1) # test that this is tolerated
|
||||
|
||||
check_source_runs(OBJC [[
|
||||
#import <Foundation/Foundation.h>
|
||||
int main() {
|
||||
|
@ -1,6 +1,8 @@
|
||||
enable_language (OBJCXX)
|
||||
include(CheckSourceRuns)
|
||||
|
||||
set(OBJCXX 1) # test that this is tolerated
|
||||
|
||||
check_source_runs(OBJCXX [[
|
||||
#include <vector>
|
||||
#import <Foundation/Foundation.h>
|
||||
|
Loading…
Reference in New Issue
Block a user