[CMake] CMake Error: Error required internal CMake variable not set, ...

Michael Hertling mhertling at online.de
Wed Jan 12 10:58:44 EST 2011


On 01/12/2011 04:29 PM, Enrique Izaguirre wrote:
> Hello,
> 
> I am new to CMake and following a few examples, I am now trying to
> cross-compile a C++ program from Cygwin to Linux, and I got the following
> errors:
> 
> CMake Error: Error required internal CMake variable not set, cmake may be
> not be built correctly.
> Missing variable is:
> CMAKE_C++_COMPILER_ENV_VAR
> CMake Error: Error required internal CMake variable not set, cmake may be
> not be built correctly.
> Missing variable is:
> CMAKE_C++_COMPILER
> :
> 
> 
> I have a folder named helloC++-linux, where I have all my stuff:
> A simple hello.cpp program
> My CMakeLists.txt contains:
>     #CMakeLists.txt :  CMake configuration file
>     PROJECT(helloC++-linux C++)

Try with PROJECT(helloC++-linux CXX), i.e. CXX instead of C++.
                                 ^^
>     #States that CMake required version must be >= 2.6
>     CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
> 
>     #File to build and executable:
>     ADD_EXECUTABLE(hello.o hello.cpp)
> 
> My Toolchain file (named Toolchain-linuxcpp.cmake) contains:
>    INCLUDE (CMakeForceCompiler)
>    SET(CMAKE_SYSTEM_NAME Linux)
> 
>    #specify the cross-compiler
>    SET(CMAKE_CXX_COMPILER /bin/g++-linux)
> 
> 
> and I tried to build it using following command:
> cmake -DCMAKE_TOOLACHAIN_FILE=./Toolchain-linuxcpp.cmake .
> 
> 
> Before this, I tried it compiling a simple C program, using gcc-linux
> compiler and setting CMAKE_C_COMPILER variable, and it worked correctly, but
> once that I am trying to do it with C++ I got these errors. I couldn't find
> anything about this on the web. Could you help me please?
> 
> Thanks
> 
> Enrique


More information about the CMake mailing list