[CMake] The else() in CMAKE_TOOLCHAIN_FILE
Ashi
ashi08104 at gmail.com
Tue Apr 2 00:42:47 EDT 2013
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!
On Mon, Apr 1, 2013 at 7:47 PM, Ashi <ashi08104 at gmail.com> wrote:
> Hi all, I've a problem in using else() in CMAKE_TOOLCHAIN_FILE, all files
> are:
>
> #==CMakeLists.txt==
> message("TEST")
>
> #==config.cmake==
> if(A)
> message("A")
> elseif(B)
> message("B")
> elseif(C)
> message("C")
> else()
> message(FATAL_ERROR "NONE")
> endif()
>
> and I run the cmake:
> $ cmake -DCMAKE_TOOLCHAIN_FILE=./config.cmake -DA=true .
>
> cmake returns:
>
> A
> A
> -- The C compiler identification is GNU 4.7.2
> -- The CXX compiler identification is GNU 4.7.2
> -- Check for working C compiler: /I usr/bin/gcc
> CMake Error at /home/zhongwei/projects/cmake_test/config.cmake:8 (message):
> NONE
> Call Stack (most recent call first):
> /home/zhongwei/projects/cmake_test/build/CMakeFiles/CMakeSystem.cmake:1
> (INCLUDE)
> CMakeLists.txt:2 (PROJECT)
>
>
> CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
> CMake Error: Internal CMake error, TryCompile configure of cmake failed
> -- Configuring incomplete, errors occurred!
>
> My problem is why the else() statement is still run when A=true?
>
> Thanks,
> ashi
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130402/829696f1/attachment.htm>
More information about the CMake
mailing list