Created
January 30, 2025 13:48
-
-
Save scivision/f3758ee710638b39bae1106bd1fc0631 to your computer and use it in GitHub Desktop.
CMake execute_process on Windows with paths having spaces
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Toy example--execute_process() on Windows is challenging to handle paths with spaces | |
# Non-Winows sh -c just works. | |
set(setvars "set CC=gcc") | |
set(cmd "cc main.c") | |
set(cmd $ENV{COMSPEC} /c "${setvars} && ${cmd}") | |
string(REPLACE "C:/Program Files/" "C:/Progra~1/" cmd "$cmd}") | |
string(REPLACE "C:/Program Files (x86)/" "C:/Progra~2/" cmd "${cmd}") | |
execute_process(COMMAND ${cmd}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment