[CMake] how to setup cmake_c/xx_flags per toolchain?

Paweł Sikora pluto at agmk.net
Fri Jan 6 18:56:33 EST 2012


Hi,

i'm trying to setup a toolchain file for cross-compilation with target specfic
options and afaics cmake dosen't use flags from such file:

$ cat CMakeLists.txt 
cmake_minimum_required( VERSION 2.8.7 )
project( test CXX )
add_executable( main main.cpp )

$ cat CMakeToolchain-x86_64-gnu-linux.txt
set( CMAKE_SYSTEM_NAME Linux )
set( CMAKE_SYSTEM_VERSION 1 )
set( CMAKE_CXX_COMPILER /local/devel/toolchain46/x86_64-gnu-linux/bin/x86_64-gnu-linux-g++ )
set( CMAKE_CXX_FLAGS "-Wall -O1 -gdwarf-4 -g2 -std=gnu++0x" )
set( CMAKE_FIND_ROOT_PATH /usr )

$ LANG=C sh -x ./build.sh
+ rm -rf build
+ mkdir build
+ cd build
+ cmake ../ -DCMAKE_TOOLCHAIN_FILE=../CMakeToolchain-x86_64-gnu-linux.txt
-- The CXX compiler identification is GNU
-- Check for working CXX compiler: /local/devel/toolchain46/x86_64-gnu-linux/bin/x86_64-gnu-linux-g++
-- Check for working CXX compiler: /local/devel/toolchain46/x86_64-gnu-linux/bin/x86_64-gnu-linux-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
(...)
[100%] Building CXX object CMakeFiles/main.dir/main.cpp.o
/local/devel/toolchain46/x86_64-gnu-linux/bin/x86_64-gnu-linux-g++     -o CMakeFiles/main.dir/main.cpp.o -c /home/users/pluto/src/cmake-cross-build/main.cpp
                                                                   ^^^ no cxx flags.

is it a bug or a feature?

BR,
Paweł.



More information about the CMake mailing list