如何在cmake生成器表达式中转义右尖括号符号?

时间:2018-09-13 02:46:38

标签: cmake

这就是我想要做的:

set(BE_QUIET $<$<NOT:$<BOOL:CMAKE_VERBOSE_MAKEFILE>>:&>/dev/null>)

旨在像这样在add_cusom_command中使用它:

add_custom_command(
    ...
    COMMAND ... ${BE_QUIET}
)

除非用户设置CMAKE_VERBOSE_MAKEFILE(或运行make VERBOSE=1),否则想法是禁止自定义命令输出。

问题是cmake将该右尖括号符号视为表达式的结尾。有什么办法可以逃脱吗?

编辑: a,即使我现在知道$<ANGLE-R>,这个想法也行不通-您需要新的表达方式(例如$<CONFIG_FLAGS:VERBOSE>

编辑2:找到了解决方案(注入一些make魔术):

 set(BE_QUIET "$(if" "$(VERBOSE),,&>/dev/null)")

1 个答案:

答案 0 :(得分:0)

使用worker_processes 2; events { worker_connections 1024; } http { sendfile on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE ssl_prefer_server_ciphers on; gzip on; gzip_disable "msie6"; upstream django { server django-blue:7893 (maybe some option); server django-green:7893 (maybe some option); } server { listen 80; client_max_body_size 100M; charset utf-8; server_name 192.168.1.230; location /static { autoindex on; alias /static; add_header Cache-Control "public"; } location /media { autoindex on; alias /media; } location / { proxy_pass http://django/; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $server_name; } } access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; } (文档位于Output Expressions下)

$<ANGLE-R>

但是请注意,由于没有生成器表达式可以告诉我们是否传递了set(BE_QUIET $<$<BOOL:CMAKE_VERBOSE_MAKEFILE>:&$<ANGLE-R>/dev/null>) ,因此无法检测到make VERBOSE=1