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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:39:09+00:00 2026-05-25T10:39:09+00:00

I have a numeric vector implementation in C; the whole implementation is based on

  • 0

I have a numeric vector implementation in C; the whole implementation is based on TYPE and then i do s/TYPE/double/g to get an implementation for double and s/TYPE/int/ to get an implementation for int. Up until now I have based the filtering on a tiny sed script which is referenced with an add_custom_command() from the CMakeLists.txt file. That has worked fine on linux, but when trying to generate a Visual Studio solution it fails (in Visual Studio).

Since the process I am performing (search-replace in a file and store the output as a new file) is so simple I thought maybe this could be achieved with builtin CMake commands?

Joakim

  • 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-25T10:39:09+00:00Added an answer on May 25, 2026 at 10:39 am

    In pure cmake you have at least 3 ways to go:

    1) configure_file command

    • is useful for simple replaces, when you only need to substitute some placeholders within the template file based on current project configuration;
    • cmake will automatically generate dependency on template file and will regenerate your file on template changes.

    2) It is possible to use FILE READ or FILE STRINGS and FILE WRITE commands to make any transformation during the cmake configure step.

    • any custom transformation is possible

    But

    • harder to maintain;
    • worth cmake performance;
    • no automatic monitoring for template file changes.

    3) If it absolutely necessary to generate this file during the build, then you can use cmake in process script mode (cmake -P) with add_custom_command:

    add_custom_command(OUTPUT vector.c
                       COMMAND $(CMAKE_COMMAND) -DTEMPLATE:STRING=vector.template -P genscript.cmake
                       DEPENDS vector.template genscript.cmake)
    

    Where genscript.cmake is helper script you need to write. It should generate vector.c with 1) or 2) approach listened above.

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

Sidebar

Related Questions

I have the following template declaration: template <typename T> void IterTable(int& rIdx, std::vector<double>& rVarVector,
I have a numeric vector, it contains patches of elements that are repeating, something
I have a numeric matrix with 25 columns and 23 rows, and a vector
I have a numeric vector, let's say something like: x <- rep(1:6, 300) What
Right now I have a vector std::vector<char> myVector(4) containing any combination of a set
I have a numeric textbox in C# .NET which is nothing more than a
I have a list of numeric values. I may normalize the values if needed.
I have 2 fields in the database month (numeric) and year (numeric) and I
I have a table on SQL2000 with a numeric column and I need the
I have a Python function that takes a numeric argument that must be an

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.