[CMake] Variables in cmake-scripts

mereandor at gmail.com mereandor at gmail.com
Fri Oct 2 10:20:11 EDT 2009


Hi!

I have a question regarding cmake-scripts:

I have this simple example:

----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
)

Here is the input and output that I get:

$ cmake -DTESTVAR=something
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/mereandor/test
$ make install
Install the project...
-- Install configuration: ""
--test= --prefix=/usr/local

Why is ${CMAKE_INSTALL_PREFIX} set and ${TESTVAR} not?

thanks in advance for any help

regards


More information about the CMake mailing list