如何在cmake中连接字符串 [英] How do you concatenate string in cmake
本文介绍了如何在cmake中连接字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在cmake中连接字符串?
Is there a way to concatenate strings in cmake?
我有一个仅包含主要方法.cpp文件的文件夹。我认为通过在所有src文件中使用foreach会很容易。这就是我到目前为止所得到的:
I have a folder that only contains .cpp files with main methods. I thought this would be easy by just using a foreach through all src files. This is what I've got this far:
project(opengl-tutorial)
cmake_minimum_required(VERSION 2.8)
aux_source_directory(. SRC_LIST)
add_definitions(
--std=c++11
)
foreach (src ${SRC_LIST})
# name = ${src} + ".out"
add_executable(${name} ${src})
target_link_libraries(${name} GL GLU GLEW glfw)
endforeach(src ${SRC_LIST})
我该怎么做
推荐答案
$ {src} .out
应该可以很好,因此您可以编写 set(NAME $ {src} .out)
并使用 $ {NAME}
"${src}.out"
should work fine, so you can write set(NAME "${src}.out")
and use ${NAME}
wherever you need to.
这篇关于如何在cmake中连接字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文