Hi,
I have a problem with a self-written CMake macro, but I don't know
exactly what the problem is.
I have defined macro(SetIfElse var val def), which is supposed to assign
the contents of val to var, when val is defined; otherwise it should
assign the contents of def to var. This macro was inspired by the
macro(SET_IF_NOT_SET var val) from the CMake module CTest.cmake
When I feed the CMakeLists.txt file below to cmake, I would expect as
output: 'text=Hello World', but instead I get 'text=Sorry mate!'
Could you please explain what I'm doing wrong?
project(hallo)
cmake_minimum_required(VERSION 2.6)
# Set variable ${var} equal to ${val} if ${val} is defined; else to
${def}.
macro(SetIfElse var val def)
if(DEFINED "${val}")
set("${var}" "${val}")
else(DEFINED "${val}")
set("${var}" "${def}")
endif(DEFINED "${val}")
endmacro(SetIfElse)
set(hello "Hello World")
set(mate "Sorry mate!")
SetIfElse(text "${hello}" "${mate}")
message(STATUS "text=${text}")
_______________________________________________
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