Skip to content

Instantly share code, notes, and snippets.

@shnam7
Created May 6, 2021 00:58
Show Gist options
  • Select an option

  • Save shnam7/3182c0f53b293c27c4e03fda102417cb to your computer and use it in GitHub Desktop.

Select an option

Save shnam7/3182c0f53b293c27c4e03fda102417cb to your computer and use it in GitHub Desktop.
CMake - detecting target architecture when using vscode
This can be done by adding following to the settings.json
"cmake.configureSettings": {
"TARGET_ARCH": "${buildKitTargetArch}"
},
In CMakeLists.txt, it can be used like this:
#--- check target architecture
if(NOT TARGET_ARCH)
set(TARGET_ARCH "x86_64" CACHE STRING "Choose target architecture, options are: x86, x86_64..." FORCE)
message(STATUS "No build type specified, defaulting to MinSizeRel.")
endif()
if(${TARGET_ARCH} STREQUAL "x64")
set(TARGET_ARCH "x86_64" CACHE STRING "Choose target architecture, options are: x86, x86_64..." FORCE)
endif()
Variables available in vscode-cmake-tool can be found here:
https://github.com/microsoft/vscode-cmake-tools/blob/main/docs/cmake-settings.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment