# how can i build static program by cmake+clang+nmake on windows?

**URL:** https://discourse.cmake.org/t/how-can-i-build-static-program-by-cmake-clang-nmake-on-windows/9226
**Category:** Code
**Tags:** os:windows
**Created:** [October 20, 2023, 4:02am UTC](https://discourse.cmake.org/t/how-can-i-build-static-program-by-cmake-clang-nmake-on-windows/9226 "2023-10-20T04:02:24Z")
**Posts on this page:** 1
**Showing post:** 7

<div class="post-metadata">

### Author: ![marc.chevrier](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/ecb155/32.png) [@marc.chevrier](https://discourse.cmake.org/u/marc.chevrier)
#### Post date: [October 21, 2023, 5:39pm UTC](https://discourse.cmake.org/t/how-can-i-build-static-program-by-cmake-clang-nmake-on-windows/9226/7 "2023-10-21T17:39:19Z")

</div>

The following is perfectly operational but require, at least, CMake version 3.15 (you specified version 3.5 through `cmake_minimum_required()` command):

```cmake
cmake_minimum_required(VERSION 3.15)

set(CMAKE_C_COMPILER "C:/Software/LLVM/bin/clang.exe")
set(CMAKE_CXX_COMPILER "C:/Software/LLVM/bin/clang++.exe")

project(helloworld)

set(CMAKE_VERBOSE_MAKEFILE ON)

set(CMAKE_CXX_STANDARD 17)
set(SOURCE helloworld.cpp)
add_executable(${PROJECT_NAME} ${SOURCE})
set_property(TARGET main PROPERTY MSVC_RUNTIME_LIBRARY MultiThreadedDebug)

```

By the way, I strongly suggest to you to read the [CMake documentation](https://cmake.org/cmake/help/latest/index.html). For example, setting variable `CMAKE_CXX_COMPILER_TARGET` outside a toolchain file is irrelevant.

---

_[View the full topic](https://discourse.cmake.org/t/how-can-i-build-static-program-by-cmake-clang-nmake-on-windows/9226)._
