<div dir="ltr">I think I find something to explain this: the config.cmake(the CMAKE_TOOLCHAIN_FILE) is reloaded several times. on first-load, the A is set, but on second-load and later-load, the A is not set. I think I can get around this problem when A is kept set. However, I don't know how can I keep the value set in cmake. Could anyone give me some suggestion? Thanks! <br>
<div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Apr 1, 2013 at 7:47 PM, Ashi <span dir="ltr"><<a href="mailto:ashi08104@gmail.com" target="_blank">ashi08104@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">Hi all, I've a problem in using else() in CMAKE_TOOLCHAIN_FILE, all files are:<br><br>#==CMakeLists.txt==<br>message("TEST")<br><br>#==config.cmake==<br>if(A)<br> message("A")<br>
elseif(B)<br> message("B")<br>elseif(C)<br> message("C")<br>else()<br> message(FATAL_ERROR "NONE")<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: /I 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>
</blockquote></div><br></div></div>