superbuild passing CMAKE_CXX_COMPILER to projects

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
...

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.

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.

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

I see. Sounds good. Thanks Ben.