21193

Parse error. Function missing ending “)” CMAKE [duplicate]

Question:

This question already has an answer here:

<ul><li> <a href="/questions/35689501/cmakes-execute-process-and-arbitrary-shell-scripts" dir="ltr" rel="nofollow">CMake's execute_process and arbitrary shell scripts</a> <span class="question-originals-answer-count"> 2 answers </span> </li> </ul>

I wanted to extract a string from a header in an execute_process. But there is a bug with the command and I try a lot of things, always the same error.

execute_process( COMMAND cat $(version_h) | grep -a "define myVersion " | cut -d " " -f3 | cut -d '"' -f2`

OUTPUT_VARIABLE _Version)

If I write the command in the console line, there is no problem.

The error says: "Parse error. Function missing ending ")". Instead found unterminated string with text " "

Answer1:

execute_process() only deals with processes and their arguments, i.e. there is no shell involved.

So, you have two main options:

<ol><li>execute_process(COMMAND bash -c "..." OUTPUT_VARIABLE _Version)</li> <li>execute_process(COMMAND cat ... COMMAND grep ... COMMAND cut ... COMMAND cut ... OUTPUT_VARIABLE _Version)</li> </ol>

In the second version, the standard output and standard inputs of the commands chain together.

If you want to do anything more complex, you'll have to create a separate script and invoke it in a process-, not shell-, oriented way, i.e. option 1.

Answer2:

The problem was that I need to remove a quote character and I guess there is a confusion with Cmake and the bash command.

execute_process(COMMAND cat ... COMMAND grep ... COMMAND cut ... COMMAND cut -c2- COMMAND rev COMMAND cut -c2- COMMAND rev OUTPUT_VARIABLE _Version)

Recommend

  • Exceptions with okHttp and SPDY
  • XML Deserialization - convert attribute value into class automatically (.net)
  • Add date without exceeding a month
  • Message Response Zombies occurring with errors Codes 0xC0C01B4C and 0xc0c016b5 no Orchestration
  • Converting Negative Decimal To String Loses the -
  • Why do the numeric format strings in C# round the number when not using decimals (F0)?
  • Python functions: Pass global variables if only accessing them?
  • Sending keystrokes from a C# application to a Java application - strange behaviour?
  • Use double quote then curly brace in powershell -Command
  • Binding ContextMenu Tag to Owner
  • Create a table from a list of tuples in Python 3
  • How can I get process name of specific PID with ps command in alpine
  • Connection pooling with URLConnection?
  • richtextbox to string
  • How do we generate stack trace in TOMCAT?
  • Unicorn and Rails eat up 2x MySQL connections
  • How to determine the CCSID used in CPYFRMIMPF command?
  • php is_file always return false
  • How to enable large page memory for the JVM?
  • I18n locale disregarding fallbacks
  • close() was never explicitly called on database
  • Groovy: Unexpected token “:”
  • Do I need to reset a Perl hash index?
  • Magento Fatal error: Maximum execution error solution, on WAMP
  • Word Open XML Mail Merge
  • Bad request using file_get_contents for PUT request in PHP
  • Python CGI os.system causing malformed header
  • When to use `image` and when to use `Matrix` in Emgu CV?
  • Spring Data JPA custom method causing PropertyReferenceException
  • FB SDK and cURL: Unknown SSL protocol error in connection to graph.facebook.com:443
  • Using $this when not in object context
  • What is the “return” in scheme?
  • How do I fake an specific browser client when using Java's Net library?
  • How reduce the height of an mschart by breaking up the y-axis
  • Perl system calls when running as another user using sudo
  • Knitr HTML Loop - Some HTML output, some R output
  • Which linear programming package should I use for high numbers of constraints and “warm starts” [clo
  • How to model a transition system with SPIN
  • ORA-29908: missing primary invocation for ancillary operator
  • Converting MP3 duration time