Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8918023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:38:46+00:00 2026-06-15T05:38:46+00:00

What is the difference, in cmake, between something like: set(any_new_var ${old_var}) and set(any_new_var ${old_var})

  • 0

What is the difference, in cmake, between something like:

set(any_new_var ${old_var})

and

set(any_new_var "${old_var}")

Any important difference? When have I to use one or the other form?

For example, I try with the next mini test

# test.cmake

# Variable 'a' isn't defined.
set(hola "${a}")

# message(${hola})
message("${hola}")

The output of this mini-test (cmake -P test.cmake) is a empty line (because ‘a’ isn’t defined). If I uncomment the first message, cmake throws an message error:

CMake Error at prueba.cmake:6 (message):
  message called with incorrect number of arguments

Why in the second case it doesn’t throw and error but an empty line?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T05:38:48+00:00Added an answer on June 15, 2026 at 5:38 am

    In CMake strings can be interpreted as lists. The rule is simple: to form the list split the string at semicolons. For example, the string value one;two;three can be thought of as a list of three elements: one, two, and three.

    To invoke a command you write the command name and some words between parentheses. However, these words do not correspond to the arguments the command receive in a one-to-one fashion. Each word become zero or more arguments, and all the arguments get concatenated together.
    Unless a word is quoted, it is treated as a list and is expanded to multiple arguments. A quoted word always becomes a single argument.

    For example, assume that X is bound to one;two;three, Y is bound to the empty string, and Z is bound to foo. The following command invocation has three words, but the command receives four arguments:

    some_command(${X} ${Y} ${Z})
    # The command receives four arguments:
    # 1. one
    # 2. two
    # 3. three
    # 4. foo
    

    If we would have quoted the words, the command would have received three arguments:

    some_command("${X}" "${Y}" "${Z}")
    # The command receives three arguments:
    # 1. one;two;three
    # 2. (the empty list)
    # 3. foo
    

    To return to your original question: the message command can receive a varying number of arguments. It takes all its arguments, concatenates them together into one string, and then prints that string. For some unknown reason it does not accept zero arguments, though.

    The behavior message has with multiple arguments is not very useful, so you tend to use a single quoted argument with it:

    set(SOURCES foo.c hoo.h)
    message(${SOURCES})   # prints foo.cfoo.h
    message("${SOURCES}") # prints foo.c;foo.h
    

    Also, when set receives multiple arguments it builds a string of the arguments separated by semicolons. The variable is then set to that string.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is the difference between cmake and ccmake ? I have the Ubuntu package
Difference between start-pointers and interior-pointers and in what situation we should prefer one over
The difference between Chr and Char when used in converting types is that one
Is there any functional difference in Python between a try statement and an if
Is there any difference (compiler/interpreter/juju wise, etc) between the two versions of checking the
I have a number of projects built using CMake and I'd like to be
What difference does it make when I use a const parameter in a procedure?
Any difference, performance-wise?
What's the difference between CopyIcon and DuplicateIcon ?
What is the difference in the following two CREATE TABLE statements? (The first one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.