Oops.. Nice Catch.

I am going to hazard a guess and say that "Make" is running a new cmake instance with the install.cmake as its target script to run. This script will have NOTHING to do with the CMakeLists.txt file and therefor will have no idea about variables that are defined in the original CMakeLists.txt file.

If presented with this I would probably opt to use a configured file such as:

install.cmake.in-----
EXECUTE_PROCESS(
COMMAND "/bin/echo" "--tes...@testvar@ --prefix=$ {CMAKE_INSTALL_PREFIX}"
 RESULT_VARIABLE AD_HDM_RV
)

Then in CMakeLists.txt:

configure_file ( ${PROJECT_SOURCE_DIR}/install.cmake.in $ {PROJECT_BINARY_DIR}/install.cmake )
INSTALL(SCRIPT ${PROJECT_BINARY_DIR}/install.cmake)

$ cmake -DTESTVAR=something
.
.
.
.
$ make install

--
Mike Jackson <www.bluequartz.net>


On Oct 2, 2009, at 10:35 AM, merean...@gmail.com wrote:

Isn't "cmake -DTESTVAR=something" supposed to do that?

Am Freitag 02 Oktober 2009 16:30:44 schrieben Sie:
where is TESTVAR ever set?

_________________________________________________________
Mike Jackson                  mike.jack...@bluequartz.net

On Oct 2, 2009, at 10:20 AM, merean...@gmail.com wrote:
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

_______________________________________________
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

Reply via email to