Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8245949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:20:59+00:00 2026-06-07T22:20:59+00:00

I use cmake for cross compiling. In my toolchain file there is a line

  • 0

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")
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T22:21:01+00:00Added an answer on June 7, 2026 at 10:21 pm

    I’ve found a temporary solution by replacing the line

    SET(CMAKE_C_FLAGS "-std=gnu99")
    

    by

    SET(CMAKE_C_FLAGS "-std=gnu99" CACHE STRING "" FORCE)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently trying to use CMake for cross-compiling. However, CMake seems to ignore the
Is there a variable I can use in cmake to make it act like
When using clang++, how can I make CMake use the -std=c++0x flag when compiling,
I use a cmake generated makefile to compile a c++ file that depends on
I use CMake to generate a Visual Studio 2010 project and solution file. Actually
Question: Can CMake generate build scripts that do not, in any way, use CMake?
I want to setup a custom toolchain with CMake. I've set the compiler but
I am trying to use CMake and I need to add an environment variable
Introduction: I am trying to use CMake to obtain cross platform compilation scripts (for
I want to set a CMake variable differently for debug and release builds. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.