1. 使用cmake中的生成表达式的时候发现不能够打印其中的信息,如下面的postfix变量不能通过message的输出信息,原因是在cmake config阶段还没有这个信息
2. 可以通过下面的代码块中的方式打印生成表达式中的信息
3. 各种生成表达式的使用可以参考下面的官方链接
cmake_minimum_required(VERSION 3.17)
project(test_cmake)
set(postfix $<$<CONFIG:Debug>:d>)
add_custom_target(genexdebug COMMAND ${CMAKE_COMMAND} -E echo "$<$<CONFIG:Debug>:d>")
命令行输入:
mkdir temp && cd temp
cmake -DCMAKE_BUILD_TYPE=ON ..
make genexdebug
说明:
$<condition:true_string>
Evaluates to true_string
if condition
is 1
. Otherwise evaluates to the empty string.
$<IF:condition,true_string,false_string>
Evaluates to true_string
if condition
is 1
. Otherwise evaluates to false_string
.
参考链接: