[CMake] wrapping a macro
René J. V. Bertin
rjvbertin at gmail.com
Sat Jun 13 10:51:26 EDT 2015
Hello,
Is it possible to wrap an existing macro that returns a result via one of its
arguments? I think it will be clear what I would like to do from the following
example:
if(${INTRINSICS_TEST_TYPE} MATCHES "compiles")
macro(check_intrinsics_availability source var)
check_c_source_compiles(source var)
endmacro()
elseif(${INTRINSICS_TEST_TYPE} MATCHES "runs")
include(CheckCSourceRuns)
macro(check_intrinsics_availability source var)
check_c_source_runs(source var)
endmacro()
elseif(${INTRINSICS_TEST_TYPE} MATCHES "none")
macro(check_intrinsics_availability source var)
set(${var} 1)
set(${var}_EXITCODE 0)
endmacro()
else()
macro(check_intrinsics_availability source var)
set(${var} 0)
set(${var}_EXITCODE 1)
endmacro()
endif()
This does not have the intended effect: when INTRINSICS_TEST_TYPE == "compiles",
cmake prints "Performing test var - Failed". Evidently I'd like it to perform
test ${var}, in other words, the check_intrinsics_availability macro should
behave exactly as either check_c_source_compiles or check_c_source_runs.
Additionally, the "none" and fallback cases are supposed to behave if
check_c_source_?? succeeded or failed, respectively. Are they implemented
correctly?
Thanks,
R.
More information about the CMake
mailing list