Re: [CMake] Problem while setting variables in CMakeCache
2010/9/6 Alexander Neundorf a.neundorf-w...@gmx.net: On Monday 06 September 2010, Stefan Köhnen wrote: Ah, okay. Thanks for your fast reply. Is there a way to change the value in the cache? set(... FORCE) Alex Hello Alex, thanks again for your reply. I tried to use set with FORCE but it didn't work. My CMakeLists.txt looks like this: PROJECT(CMakeTest) SET(VAR_FOR_TEST firstValue CACHE STRING Just for testing) set(VAR_FOR_TEST secondValue FORCE) MESSAGE (${VAR_FOR_TEST}) I think you wanted me to use FORCE in the first set command but I need to change the variable after it is first set. Maybe some more information on what I am trying to do will be helpful. We use the FindCUDA Script, now we try to set the CUDA_NVCC_FLAGS variable depending on the hardware that is used, we have different GPUs with different Computing Capalities (sm_11 and sm_13). The variable CUDA_NVCC_FLAGS is set in the FindCUDA Script ( set(CUDA_NVCC_FLAGS CACHE STRING Semi-colon delimit multiple arguments.) ), I thought it would be possible to set this variable automatically depending on which type of GPU is avaible. We already added code to determine the type of GPU and to build the flags accordingly to our main CMakeLists.txt, but I am not able to store the flags in CUDA_NVCC_FLAGS. The question is how can I change the value of CUDA_NVCC_FLAGS, so that the new value is stored in the cache. Stefan ___ 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] Problem while setting variables in CMakeCache
2010/9/7 Stefan Köhnen stefan.kh...@googlemail.com: 2010/9/6 Alexander Neundorf a.neundorf-w...@gmx.net: On Monday 06 September 2010, Stefan Köhnen wrote: Ah, okay. Thanks for your fast reply. Is there a way to change the value in the cache? set(... FORCE) Alex Hello Alex, thanks again for your reply. I tried to use set with FORCE but it didn't work. My CMakeLists.txt looks like this: PROJECT(CMakeTest) SET(VAR_FOR_TEST firstValue CACHE STRING Just for testing) set(VAR_FOR_TEST secondValue FORCE) This second command also needs to set the cache value: set(VAR_FOR_TEST secondValue CACHE STRING Just for testing FORCE) Keep in mind, that this will prevent the user from changing this value from the GUI, since you are forcing it. An alternative that I've employed with FindCUDA is to set the variable *before* calling find_package(CUDA). set(VAR_FOR_TEST secondValue CACHE STRING Just for testing FORCE) find_package(CUDA) The first set(CACHE) command wins and the one in the FindCUDA script doesn't take effect. A second alternative that I've employed is to keep a flag called PASSED_FIRST_CONFIGURE that is set to ON at the end of the top level CMakeLists.txt file: set(PASSED_FIRST_CONFIGURE ON CACHE INTERNAL Already Configured once?) During execution of the CMake scripts, I can check for this flag and only do set(CACHE FORCE) commands if PASSED_FIRST_CONFIGURE evaluates to false: if(NOT PASSED_FIRST_CONFIGURE) set(flag --use_fast_math) list(FIND CUDA_NVCC_FLAGS ${flag} index) if(index EQUAL -1) list(APPEND CUDA_NVCC_FLAGS ${flag}) set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} CACHE LIST Semi-colon delimit multiple arguments. FORCE) endif() endif() James ___ 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] Problem while setting variables in CMakeCache
2010/9/7 Fraser Hutchison fraser.hutchi...@googlemail.com: On 07/09/2010 1:54 PM, Stefan Köhnen wrote: 2010/9/6 Alexander Neundorfa.neundorf-w...@gmx.net: On Monday 06 September 2010, Stefan Köhnen wrote: Ah, okay. Thanks for your fast reply. Is there a way to change the value in the cache? set(... FORCE) Alex Hello Alex, thanks again for your reply. I tried to use set with FORCE but it didn't work. My CMakeLists.txt looks like this: PROJECT(CMakeTest) SET(VAR_FOR_TEST firstValue CACHE STRING Just for testing) set(VAR_FOR_TEST secondValue FORCE) I think you want set(VAR_FOR_TEST secondValue CACHE STRING Overwritten value FORCE) All the best, Fraser. Yes that is exactly what I was looking for. Thank you very much. I added this and it works perfectly. ___ 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] Problem while setting variables in CMakeCache
2010/9/7 James Bigler jamesbig...@gmail.com: 2010/9/7 Stefan Köhnen stefan.kh...@googlemail.com: 2010/9/6 Alexander Neundorf a.neundorf-w...@gmx.net: On Monday 06 September 2010, Stefan Köhnen wrote: Ah, okay. Thanks for your fast reply. Is there a way to change the value in the cache? set(... FORCE) Alex Hello Alex, thanks again for your reply. I tried to use set with FORCE but it didn't work. My CMakeLists.txt looks like this: PROJECT(CMakeTest) SET(VAR_FOR_TEST firstValue CACHE STRING Just for testing) set(VAR_FOR_TEST secondValue FORCE) This second command also needs to set the cache value: set(VAR_FOR_TEST secondValue CACHE STRING Just for testing FORCE) Keep in mind, that this will prevent the user from changing this value from the GUI, since you are forcing it. An alternative that I've employed with FindCUDA is to set the variable *before* calling find_package(CUDA). set(VAR_FOR_TEST secondValue CACHE STRING Just for testing FORCE) find_package(CUDA) The first set(CACHE) command wins and the one in the FindCUDA script doesn't take effect. A second alternative that I've employed is to keep a flag called PASSED_FIRST_CONFIGURE that is set to ON at the end of the top level CMakeLists.txt file: set(PASSED_FIRST_CONFIGURE ON CACHE INTERNAL Already Configured once?) During execution of the CMake scripts, I can check for this flag and only do set(CACHE FORCE) commands if PASSED_FIRST_CONFIGURE evaluates to false: if(NOT PASSED_FIRST_CONFIGURE) set(flag --use_fast_math) list(FIND CUDA_NVCC_FLAGS ${flag} index) if(index EQUAL -1) list(APPEND CUDA_NVCC_FLAGS ${flag}) set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} CACHE LIST Semi-colon delimit multiple arguments. FORCE) endif() endif() James Hello James, thanks for your reply, I implemented your first suggestion and this works perfectly. I think your idea with PASSED_FIRST_CONFIGURE flag is propably the most flexible way to implement this, maybe we will use something similar to allow changes from the GUI. Stefan ___ 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] Problem while setting variables in CMakeCache
set(VAR_FOR_TEST secondValue CACHE STRING Just for testing FORCE) find_package(CUDA) thanks for your reply, I implemented your first suggestion and this works perfectly. I miss-typed that set command above. I needed to leave outthe FORCE flag. This will initialize VAR_FOR_TEST to your initial value making the set command in find_package have no effect. This will also allow users to change the value in the GUI, because subsequent runs of cmake will not forcibly change the value in the cache. set(CUDA_NVCC_FLAGS -arch;sm_20 CACHE STRING Flags for nvcc) find_package(CUDA) James ___ 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] Problem while setting variables in CMakeCache
On 09/06/2010 06:33 PM, Stefan Köhnen wrote: Hello, I am trying to set a variable that appears in CMakeCache. I made this small example to show what I am trying to do. CMakeLists.txt: PROJECT(CMakeTest) SET(VAR_FOR_TEST firstValue CACHE STRING Just for testing) set(VAR_FOR_TEST secondValue) MESSAGE (${VAR_FOR_TEST}) When I run cmake from the build-folder I get the message secondValue, but when I look in the CMakeCache.txt-file I see this: //Just for testing VAR_FOR_TEST:STRING=firstValue Why is VAR_FOR_TEST set to firstValue, there is probably something I missed in my CMakeLists.txt but I found no example for this kind of problem on the Internet. My CMake version is 2.6-patch 3, but I think the problem is my code not CMake. See http://www.cmake.org/pipermail/cmake/2010-July/037939.html et seq. Regards, Michael ___ 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] Problem while setting variables in CMakeCache
Ah, okay. Thanks for your fast reply. Is there a way to change the value in the cache? Stefan 2010/9/6 Alexander Neundorf neund...@kde.org: On Monday 06 September 2010, Stefan Köhnen wrote: Hello, I am trying to set a variable that appears in CMakeCache. I made this small example to show what I am trying to do. CMakeLists.txt: PROJECT(CMakeTest) SET(VAR_FOR_TEST firstValue CACHE STRING Just for testing) set(VAR_FOR_TEST secondValue) MESSAGE (${VAR_FOR_TEST}) When I run cmake from the build-folder I get the message secondValue, but when I look in the CMakeCache.txt-file I see this: //Just for testing VAR_FOR_TEST:STRING=firstValue Why is VAR_FOR_TEST set to firstValue, there is probably something I missed in my CMakeLists.txt but I found no example for this kind of problem on the Internet. The first set() stores the value in the cache. The second set() create basically a second variable with the same name, which is not in the cache, and which shadows the one from the cache. Alex ___ 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] Problem while setting variables in CMakeCache
On Monday 06 September 2010, Stefan Köhnen wrote: Ah, okay. Thanks for your fast reply. Is there a way to change the value in the cache? set(... FORCE) Alex ___ 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