CMakePresets.json

lsh235·2024년 10월 8일
0

이것저것

목록 보기
3/3

CMakePresets.json이란

CMakePresets.json은 CMake 3.19 버전에서 도입된 기능으로, CMake 프로젝트의 구성(build configuration) 및 실행을 쉽게 설정하고 관리하기 위해 사용하는 파일입니다. 이 파일을 통해 프로젝트의 빌드 환경을 미리 정의하고, 빌드 옵션이나 설정을 여러 사용자나 시스템에서 일관되게 적용할 수 있습니다.

구조

크게 두 가지 종류의 프리셋(presets)을 정의합니다.

configurePresets: CMake 구성(configure) 단계에 대한 설정을 정의합니다. 이를 통해 빌드 유형, 빌드 디렉토리, 컴파일러 옵션 등을 설정할 수 있습니다.
buildPresets: 빌드 단계에 대한 설정을 정의하며, 빌드할 때 사용되는 설정을 지정할 수 있습니다.

{
  "version": 3,
  "cmakeMinimumRequired": {
    "major": 3,
    "minor": 19,
    "patch": 0
  },
  "configurePresets": [
    {
      "name": "windows-base",
      "hidden": true,
      "generator": "Ninja",
      "binaryDir": "${sourceDir}/out/build/${presetName}",
      "installDir": "${sourceDir}/out/install/${presetName}",
      "ADDITIONAL_INCLUDE_DIR": "C:/Users/admin/Desktop/~"[?]
      "cacheVariables": {
        "CMAKE_C_COMPILER": "cl.exe",
        "CMAKE_CXX_COMPILER": "cl.exe"
      },
      "condition": {
        "type": "equals",
        "lhs": "${hostSystemName}",
        "rhs": "Windows"
      }
    },
    {
      "name": "x64-debug",
      "displayName": "x64 Debug",
      "inherits": "windows-base",
      "architecture": {
        "value": "x64",
        "strategy": "external"
      },
      "cacheVariables": {
        "CMAKE_BUILD_TYPE": "Debug"
      }
    },
    {
      "name": "x64-release",
      "displayName": "x64 Release",
      "inherits": "x64-debug",
      "cacheVariables": {
        "CMAKE_BUILD_TYPE": "Release"
      }
    },
    {
      "name": "linux-debug",
      "displayName": "Linux Debug",
      "generator": "Ninja",
      "binaryDir": "${sourceDir}/out/build/${presetName}",
      "installDir": "${sourceDir}/out/install/${presetName}",
      "cacheVariables": {
        "CMAKE_BUILD_TYPE": "Debug"
      },
      "condition": {
        "type": "equals",
        "lhs": "${hostSystemName}",
        "rhs": "Linux"
      }
    },
    {
      "name": "linux-release",
      "displayName": "Linux Release",
      "generator": "Ninja",
      "binaryDir": "${sourceDir}/out/build/${presetName}",
      "installDir": "${sourceDir}/out/install/${presetName}",
      "cacheVariables": {
        "CMAKE_BUILD_TYPE": "Release"
      },
      "condition": {
        "type": "equals",
        "lhs": "${hostSystemName}",
        "rhs": "Linux"
      }
    }
  ]
}

0개의 댓글