bash - cmake doesn't correctly parse whitespace in command line parameter -


when call cmake this, works:

cmake -g'android gradle - ninja' ..

however, i'm setting bash script lets me specify target platform, changing -g argument dynamically.

#!/usr/bin/env bash  cmake_generator="ninja" if [[ $target_platform == "android" ]] ;     cmake_generator="'android gradle - ninja'" fi  cmake -g$cmake_generator .. 

this gives me following error:

cmake error: not create named generator 'android

apparently cmake splits generator name @ whitespace , interprets multiple arguments. i've tried multiple combinations of escaping single/double quotes whitespaces can't work. i'm not sure if cmake or bash issue. ideas?

quotes missing in following command:

cmake -g$cmake_generator .. 

should be

cmake -g"$cmake_generator" .. 

because word splitting occurs after parameter expansion more information in bash documentation


Comments

Popular posts from this blog

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

android - ConstraintLayout: Realign baseline constraint in case if dependent view visibility was set to GONE -

c# - Populating Gridview inside Listview ItemTemplate On Web User Control from Code Behind -