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

  • SEARCH
  • Home
  • 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 6741703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:45:26+00:00 2026-05-26T11:45:26+00:00

Question is similar to this question Handling header files dependencies with cmake I have

  • 0

Question is similar to this question

Handling header files dependencies with cmake

I have sample program dir having main.c main.h and CMakeLists.txt

main.h contents are

#ifndef MAIN_H
#define MAIN_H
int t=3;
int y=2;
#endif

main.c contents are

#include <main.h>
#include<stdio.h>
int main(){

  printf("%d apple",t);
}

and CMakeLists.txt

PROJECT( test )
AUX_SOURCE_DIRECTORY(. test_SRCS)
include_directories(.)
ADD_EXECUTABLE (main ${test_SRCS})

but cmake is not rebuilding main.c on modification of header file.
I want it to auto-generate header file dependency.
Is it possible using cmake ?

if not is there any other tool which can do that ?

  • 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-05-26T11:45:27+00:00Added an answer on May 26, 2026 at 11:45 am

    As mentioned in my comment, I have tried out your example and things were working fine: if main.h was modified then main.c would be recompiled.

    My installation of CMake (version 2.8.0) told me to add

    cmake_minimum_required(VERSION 2.8)
    

    to the CMakeLists.txt file, but that is all of the adjustments I needed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have asked a question similar to this in the past but this is
My question is similar to this one and I am having a similar issue,
I have a problem similar to the one found in this Question I have
This is a similar question to those that have been asked before, but still
I found this similar question here , but this is really old. Was it
This question is similar to this one How do I add options to a
This question is similar to this other one , with the difference that the
My question is similar to this MySQL question, but intended for SQL Server: Is
This question is similar to this: Asp.net Profile Across Sub-Domain I'm basically wondering if
My question is similar to this one , but I would like to replicate

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.