Skip to content

Instantly share code, notes, and snippets.

@mluparu
Created June 30, 2018 23:23
Show Gist options
  • Save mluparu/6d9f0f26b538cf6b343e54f3fb3992d4 to your computer and use it in GitHub Desktop.
Save mluparu/6d9f0f26b538cf6b343e54f3fb3992d4 to your computer and use it in GitHub Desktop.
CMake in Visual Studio: MinGW configuration targeting both x64 and i686
{
"configurations": [
{
"environments": [
{
"MINGW64_ROOT": "C:\\msys64\\mingw64",
"BIN_ROOT": "${env.MINGW64_ROOT}\\bin",
"FLAVOR": "x86_64-w64-mingw32",
"TOOLSET_VERSION": "7.3.0",
"INCLUDE": "${env.MINGW64_ROOT}\\include\\c++\\${env.TOOLSET_VERSION};${env.MINGW64_ROOT}\\include\\c++\\${env.TOOLSET_VERSION}\\tr1;${env.MINGW64_ROOT}\\include\\c++\\${env.TOOLSET_VERSION}\\${env.FLAVOR}",
"MINGW_PREFIX": "C:/msys64/mingw64",
"MINGW_CHOST": "x86_64-w64-mingw32",
"MINGW_PACKAGE_PREFIX": "mingw-w64-x86_64",
"MSYSTEM": "MINGW64",
"MSYSTEM_CARCH": "x64_64",
"MSYSTEM_PREFIX": "C:/msys64/mingw64",
"MSYSTEM_CHOST": "x86_64-w64-mingw32",
"SHELL": "${env.MINGW_PREFIX}/../usr/bin/bash",
"TEMP": "${env.MINGW_PREFIX}/../tmp",
"TMP": "${env.TEMP}",
"PATH": "${env.MINGW_PREFIX}/bin;${env.MINGW_PREFIX}/../usr/local/bin;${env.MINGW_PREFIX}/../usr/bin;${env.MINGW_PREFIX}/../bin;${env.PATH}",
"environment": "mingw_64"
}
],
"name": "Mingw64-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"inheritEnvironments": [
"mingw_64", "msvc_x64_x64"
],
"buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}",
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "-v",
"ctestCommandArgs": "",
"intelliSenseMode": "linux-gcc-x64",
"variables": [
{
"name": "CMAKE_C_COMPILER",
"value": "${env.BIN_ROOT}\\gcc.exe"
},
{
"name": "CMAKE_CXX_COMPILER",
"value": "${env.BIN_ROOT}\\g++.exe"
}
]
},
{
"environments": [
{
"MINGW32_ROOT": "C:\\msys64\\mingw32",
"BIN_ROOT": "${env.MINGW32_ROOT}\\bin",
"FLAVOR": "i686-w64-mingw32",
"TOOLSET_VERSION": "7.3.0",
"INCLUDE": "${env.MINGW32_ROOT}\\include\\c++\\${env.TOOLSET_VERSION};${env.MINGW32_ROOT}\\include\\c++\\${env.TOOLSET_VERSION}\\tr1;${env.MINGW32_ROOT}\\include\\c++\\${env.TOOLSET_VERSION}\\${env.FLAVOR}",
"MINGW_PREFIX": "C:/msys64/mingw32",
"MINGW_CHOST": "i686-w64-mingw32",
"MINGW_PACKAGE_PREFIX": "mingw-w64-i686",
"MSYSTEM": "MINGW32",
"MSYSTEM_CARCH": "i686",
"MSYSTEM_PREFIX": "C:/msys64/mingw32",
"MSYSTEM_CHOST": " i686-w64-mingw32",
"SHELL": "${env.MINGW_PREFIX}/../usr/bin/bash",
"TEMP": "${env.MINGW_PREFIX}/../tmp",
"TMP": "${env.TEMP}",
"PATH": "${env.MINGW_PREFIX}/bin;${env.MINGW_PREFIX}/../usr/local/bin;${env.MINGW_PREFIX}/../usr/bin;${env.MINGW_PREFIX}/../bin;${env.PATH}",
"environment": "mingw32_i686"
}
],
"name": "MinGW32-i686-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"inheritEnvironments": [
"mingw32_i686", "msvc_x86_x64"
],
"buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}",
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "-v",
"ctestCommandArgs": "",
"intelliSenseMode": "linux-gcc-x86",
"variables": [
{
"name": "CMAKE_C_COMPILER",
"value": "${env.BIN_ROOT}\\gcc.exe"
},
{
"name": "CMAKE_CXX_COMPILER",
"value": "${env.BIN_ROOT}\\g++.exe"
}
]
}
]
}
{
"version": "0.2.1",
"defaults": {},
"configurations": [
{
"project": "CMakeLists.txt",
"projectTarget": "CMakeProject1.exe (CMakeProject1\\CMakeProject1.exe)",
"name": "CMakeProject1.exe (CMakeProject1\\CMakeProject1.exe)",
"type": "cppdbg",
"miDebuggerPath": "${env.MINGW_PREFIX}\\bin\\gdb.exe",
"inheritEnvironments": [
"mingw_64"
],
"program": "${debugInfo.target}",
"MIMode": "gdb",
"externalConsole": true
},
{
"project": "CMakeLists.txt",
"projectTarget": "CMakeProject1.exe (CMakeProject1\\CMakeProject1.exe)",
"name": "i686 - CMakeProject1.exe (CMakeProject1\\CMakeProject1.exe)",
"type": "cppdbg",
"miDebuggerPath": "${env.MINGW_PREFIX}\\bin\\gdb.exe",
"inheritEnvironments": [
"mingw32_i686"
],
"program": "${debugInfo.target}",
"MIMode": "gdb",
"externalConsole": true
}
]
}
@mluparu
Copy link
Author

mluparu commented Jun 30, 2018

To setup the MinGW environment, I followed these steps:

  1. Install MinGW msys2-x86_64-20180531.exe from http://www.msys2.org/
  2. Follow instructions on that page
  3. Install devel packages:
pacman -S make gettext base-devel
pacman -S mingw-w64-x86_64-gcc
pacman -S mingw-w64-i686-gcc
pacman -S mingw-w64-x86_64-ninja mingw-w64-i686-ninja
pacman -S mingw-w64-x86_64-gdb mingw-w64-i686-gdb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment