I use cmake for cross compiling. In my toolchain file there is a line
SET(CMAKE_C_FLAGS "-std=gnu99")
This variable is not set in CMakeLists.txt again.
When I run cmake -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake ..
this flag is ignored.
To be more detailed: The line of flags.cmake
shows an empty C_FLAGS =
line.
But in CMakeOutput.log
I can find a line Build flags: -std=gnu99
.
I found out that a second run of cmake ..
(same with or without toolchain file specified) fixes this problem.
But why is it not set the first time i run cmake ??
EDIT: Added MNWE
CMakeLists.txt:
cmake_minimum_required(VERSION 2.6)
project(myproject)
SET(files src/main.c)
add_executable(myexec ${files})
avr.cmake:
SET(CMAKE_SYSTEM_NAME Generic)
SET(CMAKE_C_COMPILER avr-gcc)
SET(CMAKE_C_FLAGS "-std=gnu99")
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…