Ninja and clang for VS 2019
【摘要】
https://stackoverflow.com/questions/55070217/build-project-using-cmake-ninja-and-clang-for-vs-2019
cmake_minimum_required(VERSION 3.11 FATAL_ERROR) #(CMAKE_INSTALL_PREFIX "...
https://stackoverflow.com/questions/55070217/build-project-using-cmake-ninja-and-clang-for-vs-2019
-
cmake_minimum_required(VERSION 3.11 FATAL_ERROR)
-
-
#(CMAKE_INSTALL_PREFIX "C:\\Program Files\\LLVM\\bin")
-
-
project(sink)
-
-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -std=c++17 -pedantic")
-
-
set(SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")
-
set(INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
-
set(BUILD_DIR "${CMAKE_CURRENT_SOURCE_DIR}/build")
-
-
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${BUILD_DIR}/bin")
-
-
file(GLOB SOURCES "${SRC_DIR}/*.cpp" "${SRC_DIR}/*.cc" "${SRC_DIR}/*.c")
-
file(GLOB HEADERS "${INCLUDE_DIR}/*.h" "${INCLUDE_DIR}/*.hpp")
-
-
add_executable(${PROJECT_NAME} ${SOURCES} ${HEADERS})
-
{
-
"configurations": [
-
{
-
"name": "Debug",
-
"generator": "Ninja",
-
"configurationType": "Debug",
-
"inheritEnvironments": [
-
"msvc_x64"
-
],
-
"buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}",
-
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
-
"cmakeCommandArgs": "",
-
"buildCommandArgs": "-v",
-
"ctestCommandArgs": "",
-
"variables": [
-
{
-
"name": "CMAKE_CXX_COMPILER",
-
"type": "PATH",
-
"value": "C:\\Program Files\\LLVM\\bin\\clang-cl.exe"
-
},
-
{
-
"name": "CMAKE_C_COMPILER",
-
"type": "PATH",
-
"value": "C:\\Program Files\\LLVM\\bin\\clang-cl.exe"
-
}
-
]
-
}
-
]
-
}
-
cmake_minimum_required(VERSION 3.11 FATAL_ERROR)
-
-
project(sink)
-
-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Xclang -std=c++17 -Xclang -pedantic")
-
-
set(SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")
-
set(INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
-
set(BUILD_DIR "${CMAKE_CURRENT_SOURCE_DIR}/build")
-
-
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${BUILD_DIR}/bin")
-
-
file(GLOB SOURCES "${SRC_DIR}/*.cpp" "${SRC_DIR}/*.cc" "${SRC_DIR}/*.c")
-
file(GLOB HEADERS "${INCLUDE_DIR}/*.h" "${INCLUDE_DIR}/*.hpp")
-
-
add_executable(${PROJECT_NAME} ${SOURCES} ${HEADERS})
And CMakeSettings.json:
-
{
-
"configurations": [
-
{
-
"name": "Debug",
-
"generator": "Ninja",
-
"configurationType": "Debug",
-
"inheritEnvironments": [ "msvc_x64" ],
-
"buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}",
-
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
-
"cmakeCommandArgs": "-DCMAKE_CXX_COMPILER:PATH=\"C:\\Program Files\\LLVM\\bin\\clang-cl.exe\" -DCMAKE_CXX_FLAGS:STRING=\"/DWIN32 /D_WINDOWS /GR /EHsc\" -DCMAKE_CXX_FLAGS_DEBUG:STRING=\"/MDd /Zi /Ob0 /Od /RTC1\"",
-
"buildCommandArgs": "-v",
-
"ctestCommandArgs": "",
-
"variables": []
-
}
-
]
-
}
文章来源: blog.csdn.net,作者:网奇,版权归原作者所有,如需转载,请联系作者。
原文链接:blog.csdn.net/jacke121/article/details/118080952
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)