1 cmake_minimum_required(VERSION 2.8)
2 project(CheckCompilerRelatedVariables)
7 message("${var}='${${var}}' is defined")
9 message("${var}='${${var}}' is NOT defined")
15 # Check that the correct number of MSVC** variables are defined...
20 math(EXPR msvc_total "${msvc_total} + 1")
23 math(EXPR msvc_total "${msvc_total} + 1")
26 math(EXPR msvc_total "${msvc_total} + 1")
29 math(EXPR msvc_total "${msvc_total} + 1")
32 math(EXPR msvc_total "${msvc_total} + 1")
35 math(EXPR msvc_total "${msvc_total} + 1")
38 math(EXPR msvc_total "${msvc_total} + 1")
52 # MSVC is set in cl.cmake when cl is the compiler...
54 # Exactly one of the numbered variables should also be set
55 # indicating which version of the cl compiler / Visual Studio
58 if(msvc_total EQUAL 1)
59 message("test passes: exactly one MSVC** variable is defined...")
61 message(FATAL_ERROR "error: ${msvc_total} MSVC** variables are defined -- exactly 1 expected")
65 # The compiler is something other than cl... None of the MSVC** variables
66 # should be defined...
68 if(msvc_total EQUAL 0)
69 message("test passes: no MSVC** variables are defined on non-MSVC build...")
71 message(FATAL_ERROR "error: ${msvc_total} MSVC** variables are defined -- exactly 0 expected")
77 # This is a no-op executable... If this test is going to fail, it fails during
78 # the configure step while cmake is configuring this CMakeLists.txt file...
82 "${CMAKE_CURRENT_BINARY_DIR}/main.cxx"
83 "int main() { return 0; }
88 CheckCompilerRelatedVariables
89 "${CMAKE_CURRENT_BINARY_DIR}/main.cxx"