[CMake] Variables in cmake-scripts

Bill Hoffman bill.hoffman at kitware.com
Fri Oct 2 10:42:45 EDT 2009


James C. Sutherland wrote:
> 
> On Oct 2, 2009, at 8:20 AM, <mereandor at gmail.com> <mereandor at gmail.com> 
> wrote:
>>
>> ----CMakeLists.txt----
>> cmake_minimum_required(VERSION 2.6)
>> SET(TEST CACHE STRING "test variable")
>> INSTALL(SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/install.cmake)
>>
>> ----install.cmake----
>> EXECUTE_PROCESS(
>>  COMMAND "/bin/echo" "--test=${TESTVAR} --prefix=${CMAKE_INSTALL_PREFIX}"
>>  RESULT_VARIABLE AD_HDM_RV
>> )
>>
>>
>> Why is ${CMAKE_INSTALL_PREFIX} set and ${TESTVAR} not?
>>
>> thanks in advance for any help
> 
> CMAKE_INSTALL_PREFIX is a variable that is set by CMake to a default 
> value of /usr/local on linux/unix flavor systems.
> 
> TESTVAR is something you need to set.

The problem is htat the install.cmake script does not load the cache 
from the main CMake run for the project, nor should it.  If you want to 
pass variables to it, you would have to configure them into a custom 
install script.

-Bill


More information about the CMake mailing list