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 3431918
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T07:23:07+00:00 2026-05-18T07:23:07+00:00

In my project I have a schema file and utility that I wrote to

  • 0

In my project I have a “schema” file and utility that I wrote to generate a header file.
I’m using cmake and out of source build to build the application.

Currently I have to regenerate the header file by hand then build the application.

Then I came up with this CMakeLists.txt statements, but they generate the header in the build directory instead of in the source directory.

configure_file( generator.pl generator COPYONLY )
configure_file( schema.txt.in schema.txt COPYONLY )
add_custom_command(
    OUTPUT generated.h
    COMMAND ./generator schema.txt generated.h
    DEPENDS mib_schema.txt.in generator.pl
    COMMENT "Regenerating header file..."
)

Is it possible to generate the header in the source directory?

edit (to reflect the answer):

The file can be reached directly by fully qualifying its path with either

${CMAKE_CURRENT_SOURCE_DIR}

or:

${CMAKE_CURRENT_BINARY_DIR}

So, to generate the header in my source dir, the previous excerpt from CMakeLists.txt becomes:

add_custom_command(
    OUTPUT generated.h
    COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/generator.pl ${CMAKE_CURRENT_SOURCE_DIR}/schema.txt.in ${CMAKE_CURRENT_SOURCE_DIR}/generated.h
    DEPENDS mib_schema.txt.in generator.pl
    COMMENT "Regenerating header file..."
)

which is actually simpler.
Thanks

–to

  • 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-18T07:23:08+00:00Added an answer on May 18, 2026 at 7:23 am

    I think that generated header are well placed in the binary directory, since you might want to create to build directories with the same source and different configurations resulting in different header generated.

    You might want to include the build directory to your project:

    include_directories(${CMAKE_CURRENT_BINARY_DIR})
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Doctrine 1.2 in my project. The schema.yml file contains: Campaign: tableName:
In visual studio, I have an asp.net 3.5 project that is using MS Enterprise
I have a table representing values of source file metrics across project revisions, like
I have an application that works with XML file. It works great if the
I have a project that I am working on and I can't figure out
I have an ASP.NET project that also uses a SQL MDF File. My target
I have a project that is build with Maven, and ends up creating a
I have a shared properties file shared.properties.proj <Project xmlns=http://schemas.microsoft.com/developer/msbuild/2003> <PropertyGroup> <SharedAssemblySearch>$(MSBuildProjectDirectory)\..\Shared Assemblies</SharedAssemblySearch> <ParentDir>..</ParentDir> <SharedAssemblySearch
I want to connect my log4j.xml with log4j.xsd (xml schema). Project don't have any
I have project asp.net with namespace test and I'm using resources (files Resource.resx and

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.