Created
May 6, 2021 00:58
-
-
Save shnam7/3182c0f53b293c27c4e03fda102417cb to your computer and use it in GitHub Desktop.
CMake - detecting target architecture when using vscode
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
| 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