<div dir="ltr">Hi all, I&#39;ve a problem in using else() in CMAKE_TOOLCHAIN_FILE, all files are:<br><br>#==CMakeLists.txt==<br>message(&quot;TEST&quot;)<br><br>#==config.cmake==<br>if(A)<br>        message(&quot;A&quot;)<br>
elseif(B)<br>        message(&quot;B&quot;)<br>elseif(C)<br>        message(&quot;C&quot;)<br>else()<br>        message(FATAL_ERROR &quot;NONE&quot;)<br>endif()<br><br>and I run the cmake:<br>$ cmake -DCMAKE_TOOLCHAIN_FILE=./config.cmake -DA=true .<br>
<br>cmake returns:<br><br>A<br>A<br>-- The C compiler identification is GNU 4.7.2<br>-- The CXX compiler identification is GNU 4.7.2<br>-- Check for working C compiler: /usr/bin/gcc<br>CMake Error at /home/zhongwei/projects/cmake_test/config.cmake:8 (message):<br>
  NONE<br>Call Stack (most recent call first):<br>  /home/zhongwei/projects/cmake_test/build/CMakeFiles/CMakeSystem.cmake:1 (INCLUDE)<br>  CMakeLists.txt:2 (PROJECT)<br><br><br>CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage<br>
CMake Error: Internal CMake error, TryCompile configure of cmake failed<br>-- Configuring incomplete, errors occurred!<br><br>My problem is why the else() statement is still run when A=true?<br><br>Thanks,<br>ashi<br></div>