Re: [CMake] The else() in CMAKE_TOOLCHAIN_FILE
Hi, Daniel, I've tried this, but it doesn't work, it returns same error as before. And there are 2 lines in CMakeCache.txt: //No help, variable specified on the command line. A:BOOL=ON Best Regards, ashi On Tue, Apr 2, 2013 at 7:44 PM, Daniel Pfeifer dan...@pfeifer-mail.dewrote: http://cmake.org/cmake/help/v2.8.10/cmake.html#opt:-Dvar:typevalue What is missing in the documentation, is that no cache entry is created if the type is not given. Set A as a cache entry of type BOOL like this: $ cmake -DCMAKE_TOOLCHAIN_FILE=./config.cmake -DA:BOOL=ON . 2013/4/2 Ashi ashi08...@gmail.com 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 ashi08...@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 -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] The else() in CMAKE_TOOLCHAIN_FILE
Yeah, my current approach is exactly creating different toolchain files. Best Regards, ashi On Wed, Apr 3, 2013 at 8:19 PM, Yngve Inntjore Levinsen yngve.levin...@gmail.com wrote: On 03. april 2013 13:13, Johannes Zarl wrote: Hi, On Tuesday, 2. April 2013, 06:42:47, Ashi wrote: 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! I'm not entirely sure what you're trying to do, but it seems like you would want to make A, B, and C into cache variables. That way subsequent cmake runs will use the same value... Johannes Hi, I'm thinking that one solution could be to create three (or four?) toolchain files, one for each if clause? Cheers, Yngve -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] The else() in CMAKE_TOOLCHAIN_FILE
Hi, On Tuesday, 2. April 2013, 06:42:47, Ashi wrote: 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! I'm not entirely sure what you're trying to do, but it seems like you would want to make A, B, and C into cache variables. That way subsequent cmake runs will use the same value... Johannes -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] The else() in CMAKE_TOOLCHAIN_FILE
On 03. april 2013 13:13, Johannes Zarl wrote: Hi, On Tuesday, 2. April 2013, 06:42:47, Ashi wrote: 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! I'm not entirely sure what you're trying to do, but it seems like you would want to make A, B, and C into cache variables. That way subsequent cmake runs will use the same value... Johannes Hi, I'm thinking that one solution could be to create three (or four?) toolchain files, one for each if clause? Cheers, Yngve -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] The else() in CMAKE_TOOLCHAIN_FILE
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 ashi08...@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 -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake