Reputation: 41
I need to modify a file during cmake execution, working on minGW. This is my code:
if(WIN32 OR MINGW)
# set Boost_COMPILER to mgw13, to avoid (mgw131, detected mgw13, set Boost_COMPILER to override) error with boost_random
message(STATUS "[build_cots.cmake]: set 'mgw13' value to Boost_COMPILER and BOOST_DETECTED_TOOLSET for Windows")
set(Boost_COMPILER "mgw13")
set(BOOST_DETECTED_TOOLSET "mgw13")
# change cmake mgw version from mgw131 to mgw13 to make it work
execute_process(COMMAND echo Before sed
COMMAND sed -i 's/"mgw131/"mgw13/g' libboost_random-variant-mgw131-mt-d-x64-1_70-static.cmake
COMMAND echo After sed
WORKING_DIRECTORY "/builds/sdo/drama_oscar/attitude_simulator/ExternalProject/Install/Boost/lib/cmake/boost_random-1.70.0"
COMMAND_ECHO STDOUT
COMMAND_ERROR_IS_FATAL ANY)
endif()
And these are logs obtained:
[100%] Built target Boost
-- [build_cots.cmake]: set 'mgw13' value to Boost_COMPILER and BOOST_DETECTED_TOOLSET for Windows
'echo' 'Before' 'sed'
'sed' '-i' ''s/"mgw131/"mgw13/g'' 'libboost_random-variant-mgw131-mt-d-x64-1_70-static.cmake'
'echo' 'After' 'sed'
After sed
sed: -e expression #1, char 1: unknown command: `''
CMake Error at cots/build_cots.cmake:77 (execute_process):
execute_process failed command indexes:
2: "Child return code: 1"
Call Stack (most recent call first):
CMakeLists.txt:53 (include)
-- Configuring incomplete, errors occurred!
I only need change "mgw131 by "mgw13 in this file, any idea will be welcome
Upvotes: -2
Views: 518
Reputation: 41
Only double quotes are used in CMake for quoting the arguments. Single quote has no special meaning and becomes part of the arguments. BTW, this is clearly seen from your debug output: ''s/"mgw131/"mgw13/g'' (outer quotes are used for pretty printing, but inner quotes are part of the parameter). The error message unknown command: `'' also talks about single quote.
Instead
's/"mgw131/"mgw13/g'
write
"s/"mgw131/"mgw13/g"
@Tsyvarev
Upvotes: 0