Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you concatenate string in cmake

Tags:

cmake

Is there a way to concatenate strings in cmake?

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}) 

How can I do what's described in the comment?

like image 339
sighol Avatar asked Aug 01 '13 17:08

sighol


People also ask

How do you concatenate two strings str1 and str2 in Java?

For better performance use str1. concat(str2) where str1 and str2 are string variables. Show activity on this post. In java concatenate symbol is " + ".

How do I create a list in Cmake?

A list in cmake is a ; separated group of strings. To create a list the set command can be used. For example, set(var a b c d e) creates a list with a;b;c;d;e , and set(var "a b c d e") creates a string or a list with one item in it.

Which of the following is an example of string concatenation?

String concatenation using + Operator For example "One" + "Two" will produce a String object "OneTwo". You can use this operator to combine more than one String e.g. two, three, four or any number of String object like "abc" + "def" + "ghi" + "jklm" will result in "abcdefghijklm".

What is ${} in Cmake?

Local Variables You access a variable by using ${} , such as ${MY_VARIABLE} . 1. CMake has the concept of scope; you can access the value of the variable after you set it as long as you are in the same scope. If you leave a function or a file in a sub directory, the variable will no longer be defined.


1 Answers

"${src}.out" should work fine, so you can write set(NAME "${src}.out") and use ${NAME} wherever you need to.

like image 54
Nafis Zaman Avatar answered Sep 18 '22 08:09

Nafis Zaman