# superbuild passing CMAKE\_CXX\_COMPILER to projects

**URL:** https://discourse.paraview.org/t/superbuild-passing-cmake-cxx-compiler-to-projects/4903
**Category:** ParaView Support
**Created:** [July 20, 2020, 5:17pm UTC](https://discourse.paraview.org/t/superbuild-passing-cmake-cxx-compiler-to-projects/4903 "2020-07-20T17:17:00Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![danlipsa](https://discourse.paraview.org/user_avatar/discourse.paraview.org/danlipsa/32/1563_2.png) [@danlipsa](https://discourse.paraview.org/u/danlipsa)
#### Post date: [July 20, 2020, 5:17pm UTC](https://discourse.paraview.org/t/superbuild-passing-cmake-cxx-compiler-to-projects/4903/1 "2020-07-20T17:17:00Z")

</div>

Should the compilers set at the superbuild level be passed to the individual projects? This does not seem to be the case, at least for las

```
[~/projects/paraview-superbuild/build-clang-osmesa-5.8.1-rc1]$ cmake "-DCMAKE_CXX_COMPILER:PATH=/usr/bin/clang++" "-DCMAKE_C_COMPILER:PATH=/usr/bin/clang" "-DENABLE_zfp:BOOL=ON" "-DENABLE_tbb:BOOL=ON" "-DENABLE_ospray:BOOL=ON" "-DCMAKE_BUILD_TYPE:STRING=Release" "-DENABLE_netcdf:BOOL=ON" "-DENABLE_visitbridge:BOOL=ON" "-DENABLE_ffmpeg:BOOL=ON" "-DENABLE_qt5:BOOL=OFF" "-DENABLE_mpi:BOOL=ON" "-DUSE_SYSTEM_mpi:BOOL=ON" "-DENABLE_paraview:BOOL=ON" "-DENABLE_xdmf3:BOOL=ON" "-DENABLE_h5py:BOOL=ON" "-DBUILD_SHARED_LIBS:BOOL=ON" "-DENABLE_vtkm:BOOL=OFF" "-DENABLE_gdal:BOOL=ON" "-DENABLE_python:BOOL=ON" "-DENABLE_python3:BOOL=ON" "-DENABLE_numpy:BOOL=ON" "USE_SYSTEM_numpy:BOOL=ON" "-DENABLE_scipy:BOOL=ON" "-DENABLE_matplotlib:BOOL=ON" "-DENABLE_vrpn:BOOL=ON" "-DENABLE_cosmotools:BOOL=ON" "-DENABLE_osmesa:BOOL=ON" "-Dmesa_USE_SWR:BOOL=OFF" "-DENABLE_glu:BOOL=ON" "-DENABLE_tbb:BOOL=OFF" "-DENABLE_boxlib:BOOL=ON" "-DENABLE_silo:BOOL=ON" "-DENABLE_boost:BOOL=ON" "-DENABLE_vortexfinder2:BOOL=OFF" "-DENABLE_las:BOOL=ON" "-DBUILD_TESTING:BOOL=ON" "-DENABLE_adios2:BOOL=ON" "-DENABLE_ospray:BOOL=OFF" "-DENABLE_acusolve:BOOL=ON" "-DENABLE_fontconfig:BOOL=ON" "-DENABLE_bzip2:BOOL=ON" ../src
-- The C compiler identification is Clang 6.0.0
-- The CXX compiler identification is Clang 6.0.0
-- Check for working C compiler: /usr/bin/clang
-- Check for working C compiler: /usr/bin/clang - works
...

```

When running:  
`cmake --build . --target las -j40` I get:

```
...
[100%] Performing configure step for 'las'
Not searching for unused variables given on the command line.
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc - works
-- Detecting C compiler ABI info
...
```

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.paraview.org/u/ben.boeckel)
#### Post date: [July 21, 2020, 10:20pm UTC](https://discourse.paraview.org/t/superbuild-passing-cmake-cxx-compiler-to-projects/4903/2 "2020-07-21T22:20:17Z")

</div>

You really want to use the `CC` and `CXX` environment variables. Not all projects use CMake, so passing the variables down won’t work for everything.

---

<div class="post-metadata">

### Author: ![danlipsa](https://discourse.paraview.org/user_avatar/discourse.paraview.org/danlipsa/32/1563_2.png) [@danlipsa](https://discourse.paraview.org/u/danlipsa)
#### Post date: [July 22, 2020, 3:14pm UTC](https://discourse.paraview.org/t/superbuild-passing-cmake-cxx-compiler-to-projects/4903/3 "2020-07-22T15:14:57Z")

</div>

Thanks Ben, Yes that works!  
Just a note to someone that may use this. It only works with:

```
export CC=...
export CXX=...
cmake ...

```

I have tried it with

`CC=... CXX=... cmake ...`

and that does not work as the compilers are only passed to the first process, but probably projects are compiled in subprocesses.

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.paraview.org/u/ben.boeckel)
#### Post date: [July 23, 2020, 4:13pm UTC](https://discourse.paraview.org/t/superbuild-passing-cmake-cxx-compiler-to-projects/4903/4 "2020-07-23T16:13:45Z")

</div>

The second works, but you need `CC=... CXX=... ninja` (or `make`) as well.

---

<div class="post-metadata">

### Author: ![danlipsa](https://discourse.paraview.org/user_avatar/discourse.paraview.org/danlipsa/32/1563_2.png) [@danlipsa](https://discourse.paraview.org/u/danlipsa)
#### Post date: [July 23, 2020, 4:56pm UTC](https://discourse.paraview.org/t/superbuild-passing-cmake-cxx-compiler-to-projects/4903/5 "2020-07-23T16:56:00Z")

</div>

I see. Sounds good. Thanks Ben.
