[CMake] cmake picks a compiler
Dave Yost
Dave at Yost.com
Tue Mar 3 15:23:45 EST 2015
Hi.
In our CMakeLists.txt file we want to force the user to pick a c++ compiler explicitly, something like this:
if (NOT DEFINED CMAKE_CXX_COMPILER)
set(CMAKE_CXX_COMPILER $ENV{CXX})
if (NOT DEFINED CMAKE_CXX_COMPILER)
message(FATAL_ERROR "
You must choose your compiler, in one of two ways:
cmake -DCMAKE_CXX_COMPILER=/path/to/compiler++
CXX=/path/to/compiler++ cmake")
endif()
endif()
message("CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER}")
Problem is, CMAKE_CXX_COMPILER is already set because cmake looked around and picked a compiler (which causes a lot of messages to be output before cmake executes the above statements).
Z% CMAKE_CXX_COMPILER=/usr/bin/clang++ cmake ..
-- The CXX compiler identification is GNU 4.9.2
-- 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
-- Check for working CXX compiler: /opt/local/bin/c++
-- Check for working CXX compiler: /opt/local/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMAKE_CXX_COMPILER: /opt/local/bin/c++
I need a command I can put in my CMakeLists.txt file to disable the cmake feature that automatically locates a c++ compiler.
Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150303/3e328219/attachment.html>
More information about the CMake
mailing list