I have a need to add an argument like "-DImage$$= " to a compile command, i.e. define a macro Image$$ to just expand to a single space character.

I'm using Windows 10  and I configure my project to use Unix Makefiles for building. cmake appears to use "sh" (bash) to execute the build commands, and I have this in one of my cmake files:
---
    function(config_setting_shared_compiler_flags tgt)
        embedded_set_target_compile_flags(TARGET ${tgt} LANGUAGE C FLAGS ${COMMON_COMPILE_FLAGS} "-DImage$$= " "-DLoad$$LR$$= " "-D$$ZI$$Base=$$Base" "-D$$ZI$$Limit=$$Limit" "-D$$RO$$Base=$$Base" "-D$$RO$$Limit=$$Limit" "-D_DATA$$RW$$Base=_DATA$$Base" "-D_DATA$$RW$$Limit=_DATA$$Limit" "-D_DATA$$ZI$$Base=_DATA$$Base" "-D_DATA$$ZI$$Limit=_DATA$$Limit" "-D_STACK$$ZI$$Base=_STACK$$Base" "-D_STACK$$ZI$$Limit=_STACK$$Limit" )
    endfunction()
---

When doing a verbose build I see that the relevant part of the command lines expands to:
---
"-DImage\$\$= "
---
I.e. cmake has escaped the dollar signs with a \, which is what a normal unix shell needs, and this works fine on my system.

We've tried to build this project on a system with Windows 7, which has no working bash, and it uses cmd.exe to run the build lines. cmd.exe does not handle the \ escape the way bash does so the the build fails.

cmd.exe accepts the following syntax:
---
"-DImage$$= "
---

So no need to escape the dollar signs.

Is there a way to stop cmake from escaping dollar signs in this case?

/Thomas

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

Reply via email to