# Tell CMake where to find the compiler by setting either the environment variable "CC" or the CMake cache entry CMAKE\_ASM\_COMPILER to the full path to the compiler, or to the compiler name if it is in the PATH.

**URL:** https://discourse.cmake.org/t/tell-cmake-where-to-find-the-compiler-by-setting-either-the-environment-variable-cc-or-the-cmake-cache-entry-cmake-asm-compiler-to-the-full-path-to-the-compiler-or-to-the-compiler-name-if-it-is-in-the-path/7342
**Category:** Usage
**Tags:** os:macos, gen:makefiles, tool:cmake
**Created:** [January 28, 2023, 5:38am UTC](https://discourse.cmake.org/t/tell-cmake-where-to-find-the-compiler-by-setting-either-the-environment-variable-cc-or-the-cmake-cache-entry-cmake-asm-compiler-to-the-full-path-to-the-compiler-or-to-the-compiler-name-if-it-is-in-the-path/7342 "2023-01-28T05:38:26Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![lalarukh](https://discourse.cmake.org/user_avatar/discourse.cmake.org/lalarukh/32/3121_2.png) [@lalarukh](https://discourse.cmake.org/u/lalarukh)
#### Post date: [January 28, 2023, 5:38am UTC](https://discourse.cmake.org/t/tell-cmake-where-to-find-the-compiler-by-setting-either-the-environment-variable-cc-or-the-cmake-cache-entry-cmake-asm-compiler-to-the-full-path-to-the-compiler-or-to-the-compiler-name-if-it-is-in-the-path/7342/1 "2023-01-28T05:38:27Z")

</div>

Hello!  
I have recently installed the ClickHouse from here: ([How to Build ClickHouse on Mac OS X - ClickHouse Documentation](http://devdoc.net/database/ClickhouseDocs_19.4.1.3-docs/development/build_osx/)).  
Successfully I have download the Clickhouse but when I run this command from documentation:  
“cmake … -DCMAKE\_CXX\_COMPILER=`which g++-8` -DCMAKE\_C\_COMPILER=`which gcc-8`” then it returns me errors like:

```auto
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- The ASM compiler identification is unknown
-- Found assembler: /path/to/clang

```

I’ve tried a lot of solutions but all in vain. I don’t know in mac how can I make my cmake to get the C, CXX or ASM compiler.  
Seeking Help!

 ![Screenshot 2023-01-28 at 10.38.00 AM](https://discourse.cmake.org/uploads/default/original/2X/c/cc2cbbb27425717a1eb9177365d3cbb72027259c.png)

---

<div class="post-metadata">

### Author: ![jtxa](https://discourse.cmake.org/user_avatar/discourse.cmake.org/jtxa/32/1535_2.png) [@jtxa](https://discourse.cmake.org/u/jtxa)
#### Post date: [January 28, 2023, 6:46pm UTC](https://discourse.cmake.org/t/tell-cmake-where-to-find-the-compiler-by-setting-either-the-environment-variable-cc-or-the-cmake-cache-entry-cmake-asm-compiler-to-the-full-path-to-the-compiler-or-to-the-compiler-name-if-it-is-in-the-path/7342/2 "2023-01-28T18:46:04Z")

</div>

I guess you have a different g++ version installed or none at all.  
Try the `which g++-8` call directly to see if it is found.  
Try to look for the version-less binary `which g++`

---

<div class="post-metadata">

### Author: ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)
#### Post date: [January 28, 2023, 6:53pm UTC](https://discourse.cmake.org/t/tell-cmake-where-to-find-the-compiler-by-setting-either-the-environment-variable-cc-or-the-cmake-cache-entry-cmake-asm-compiler-to-the-full-path-to-the-compiler-or-to-the-compiler-name-if-it-is-in-the-path/7342/3 "2023-01-28T18:53:07Z")

</div>

when I install `gcc` with brew on current **OSX** it will be `gcc-12` and `which` returns a full path:

```bash
Claus-iMac: clausklein$ brew install gcc
Warning: gcc 12.2.0 is already installed and up-to-date.
To reinstall 12.2.0, run:
  brew reinstall gcc
Claus-iMac: clausklein$ which g++-12
/usr/local/bin/g++-12

```

---

<div class="post-metadata">

### Author: ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)
#### Post date: [January 28, 2023, 6:59pm UTC](https://discourse.cmake.org/t/tell-cmake-where-to-find-the-compiler-by-setting-either-the-environment-variable-cc-or-the-cmake-cache-entry-cmake-asm-compiler-to-the-full-path-to-the-compiler-or-to-the-compiler-name-if-it-is-in-the-path/7342/4 "2023-01-28T18:59:19Z")

</div>

and it works with simple environment vars too:

```bash
Claus-iMac:agent++-4.5.1 clausklein$ head GNUmakefile
BUILD_TYPE?=Debug

export CXX=g++-12
export CC=gcc-12

export CMAKE_BUILD_TYPE=$(BUILD_TYPE)
export CPM_USE_LOCAL_PACKAGES=0
export CPM_SOURCE_CACHE=${HOME}/.cache/CPM

MACHINE:=$(shell uname -m)
Claus-iMac:agent++-4.5.1 clausklein$ make build
mkdir -p ../build-agent++-4.5.1-x86_64-Debug
cmake -B ../build-agent++-4.5.1-x86_64-Debug -S . -G Ninja -D BUILD_SHARED_LIBS=YES
-- The CXX compiler identification is GNU 12.2.0
-- The C compiler identification is GNU 12.2.0
-- Checking whether CXX compiler has -isysroot
-- Checking whether CXX compiler has -isysroot - yes
-- Checking whether CXX compiler supports OSX deployment target flag
-- Checking whether CXX compiler supports OSX deployment target flag - yes
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/local/bin/g++-12 - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Checking whether C compiler has -isysroot
-- Checking whether C compiler has -isysroot - yes
-- Checking whether C compiler supports OSX deployment target flag
-- Checking whether C compiler supports OSX deployment target flag - yes
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/local/bin/gcc-12 - skipped
-- Detecting C compile features
-- Detecting C compile features - done

```

---

<div class="post-metadata">

### Author: ![lalarukh](https://discourse.cmake.org/user_avatar/discourse.cmake.org/lalarukh/32/3121_2.png) [@lalarukh](https://discourse.cmake.org/u/lalarukh)
#### Post date: [January 29, 2023, 6:10am UTC](https://discourse.cmake.org/t/tell-cmake-where-to-find-the-compiler-by-setting-either-the-environment-variable-cc-or-the-cmake-cache-entry-cmake-asm-compiler-to-the-full-path-to-the-compiler-or-to-the-compiler-name-if-it-is-in-the-path/7342/5 "2023-01-29T06:10:27Z")

</div>

Hey @ClausKlein,  
I’ve checked that i’ve already installed g+±12.

```auto
lalarukh@lalarukhs-MacBook-Pro ~ % brew install gcc
Warning: gcc 12.2.0 is already installed and up-to-date.
To reinstall 12.2.0, run:
  brew reinstall gcc

```

need your guidance that how can i make cmake to find the CC, CXX and ASM in my mac.

---

<div class="post-metadata">

### Author: ![lalarukh](https://discourse.cmake.org/user_avatar/discourse.cmake.org/lalarukh/32/3121_2.png) [@lalarukh](https://discourse.cmake.org/u/lalarukh)
#### Post date: [January 29, 2023, 6:21am UTC](https://discourse.cmake.org/t/tell-cmake-where-to-find-the-compiler-by-setting-either-the-environment-variable-cc-or-the-cmake-cache-entry-cmake-asm-compiler-to-the-full-path-to-the-compiler-or-to-the-compiler-name-if-it-is-in-the-path/7342/6 "2023-01-29T06:21:21Z")

</div>

When I checked my g++, it was 12.  
So, instead of g+±8 I ran this command with g+±12:

```auto
cmake .. -DCMAKE_CXX_COMPILER=`which g++-12` -DCMAKE_C_COMPILER=`which gcc-12`

```

And it ran perfectly, found the C and CXX but again couldn’t found the ASM.

```auto
-- The C compiler identification is GNU 12.2.0
-- The CXX compiler identification is GNU 12.2.0
-- The ASM compiler identification is unknown

```

Let me know how can I make ASM to be recognizable by g+±12.

---

<div class="post-metadata">

### Author: ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)
#### Post date: [January 29, 2023, 8:20am UTC](https://discourse.cmake.org/t/tell-cmake-where-to-find-the-compiler-by-setting-either-the-environment-variable-cc-or-the-cmake-cache-entry-cmake-asm-compiler-to-the-full-path-to-the-compiler-or-to-the-compiler-name-if-it-is-in-the-path/7342/7 "2023-01-29T08:20:36Z")

</div>

> [@lalarukh](#):
>
> Let me know how can I make ASM to be recognizable by g+±12.

**I have never used or needed an ASM.**

Perhaps this helps: [GitHub - jaredsburrows/assembly-example: Common Functions and Code written in Assembly Language](https://github.com/jaredsburrows/assembly-example)

Take a try with `NASM`:

```auto
bash-3.2$ brew info nasm
==> nasm: stable 2.16.01 (bottled)
Netwide Assembler (NASM) is an 80x86 assembler
https://www.nasm.us/
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/nasm.rb
License: BSD-2-Clause

```

---

<div class="post-metadata">

### Author: ![lalarukh](https://discourse.cmake.org/user_avatar/discourse.cmake.org/lalarukh/32/3121_2.png) [@lalarukh](https://discourse.cmake.org/u/lalarukh)
#### Post date: [January 29, 2023, 12:06pm UTC](https://discourse.cmake.org/t/tell-cmake-where-to-find-the-compiler-by-setting-either-the-environment-variable-cc-or-the-cmake-cache-entry-cmake-asm-compiler-to-the-full-path-to-the-compiler-or-to-the-compiler-name-if-it-is-in-the-path/7342/8 "2023-01-29T12:06:31Z")

</div>

I have installed the NASM using brew.  
And replaced ASM with NASM in CMakeLists file. But still I’m getting this:  
Getting this error again:

```auto
CMake Error at CMakeLists.txt:3 (project):
  No CMAKE_NASM_COMPILER could be found.

  Tell CMake where to find the compiler by setting the CMake cache entry
  CMAKE_NASM_COMPILER to the full path to the compiler, or to the compiler
  name if it is in the PATH.

```

---

<div class="post-metadata">

### Author: ![jtxa](https://discourse.cmake.org/user_avatar/discourse.cmake.org/jtxa/32/1535_2.png) [@jtxa](https://discourse.cmake.org/u/jtxa)
#### Post date: [January 29, 2023, 1:39pm UTC](https://discourse.cmake.org/t/tell-cmake-where-to-find-the-compiler-by-setting-either-the-environment-variable-cc-or-the-cmake-cache-entry-cmake-asm-compiler-to-the-full-path-to-the-compiler-or-to-the-compiler-name-if-it-is-in-the-path/7342/9 "2023-01-29T13:39:42Z")

</div>

The right language should be `ASM_NASM`.

---

<div class="post-metadata">

### Author: ![lalarukh](https://discourse.cmake.org/user_avatar/discourse.cmake.org/lalarukh/32/3121_2.png) [@lalarukh](https://discourse.cmake.org/u/lalarukh)
#### Post date: [January 29, 2023, 5:27pm UTC](https://discourse.cmake.org/t/tell-cmake-where-to-find-the-compiler-by-setting-either-the-environment-variable-cc-or-the-cmake-cache-entry-cmake-asm-compiler-to-the-full-path-to-the-compiler-or-to-the-compiler-name-if-it-is-in-the-path/7342/10 "2023-01-29T17:27:59Z")

</div>

Thank you so much for this much support.  
Now ASM\_NASM identification is known. But this time I ran into this issue:

```auto
-- The ASM_NASM compiler identification is NASM
-- Found assembler: /usr/local/bin/nasm
-- Using compiler:
g++-12 (Homebrew GCC 12.2.0) 12.2.0
CMake Error at cmake/tools.cmake:24 (message):
  Compilation with GCC is unsupported. Please use Clang instead.
Call Stack (most recent call first):
  CMakeLists.txt:18 (include)

```

---

<div class="post-metadata">

### Author: ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)
#### Post date: [January 29, 2023, 6:13pm UTC](https://discourse.cmake.org/t/tell-cmake-where-to-find-the-compiler-by-setting-either-the-environment-variable-cc-or-the-cmake-cache-entry-cmake-asm-compiler-to-the-full-path-to-the-compiler-or-to-the-compiler-name-if-it-is-in-the-path/7342/11 "2023-01-29T18:13:32Z")

</div>

> [@lalarukh](#):
>
> `Compilation with GCC is unsupported. Please use Clang instead.`

**IMHO** : You should read [How to Build ClickHouse on macOS | ClickHouse Docs](https://clickhouse.com/docs/en/development/build-osx/)
