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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:58:10+00:00 2026-05-20T00:58:10+00:00

So I have a library I’m working on that has, or will have, optimised

  • 0

So I have a library I’m working on that has, or will have, optimised assembly per architecture of the cpu. We’re talking about optimising for nehalem, or core2, or k8 or whatever.

Anyway, I’ve been experimenting with build systems recently and have managed to set up the following with CMake:

add_executable(arch/cpuid_x86 arch/cpuid_x86.c)
execute_process(COMMAND ${PROJECT_BINARY_DIR}/arch/cpuid_x86 
    OUTPUT_VARIABLE PROJECT_CPUID OUTPUT_STRIP_TRAILING_WHITESPACE)

This does what you think it does. cpuid_x86.c is a little c program with some inline assembly to call the cpuid instruction. It deduces the architecture string from the integer result of said instruction, writing that to stdout.

Now, the above works, I can then use that output directly in a header file, or I assume to construct filenames, which is the idea.

However, I’m new to cmake, and I just feel like this is a bit of a hack. Perhaps it isn’t, so my question is am I using cmake the right way here? Am I stumbling onto unforeseen problems anywhere?

  • 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-20T00:58:11+00:00Added an answer on May 20, 2026 at 12:58 am

    You are probably better off using try_run, which will compile and run the code for you. Be aware that you’re introducing issues when cross-compiling, unless you’re happy to fall back to generic x86 code (or force the person building your code to manually set cache variables). This will let you store the name of the subarchitecture in a CMake variable, which you can then substitute into a header with something like configure_file.

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

Sidebar

Related Questions

I have this library in CI that retrieves my latest twitter updates. It has
I have a library A, that I develop. When I deploy it on a
I have a library that I would like to license and distribute. I know
Whenever I have a library that use across different websites/ applications I've always just
I have library code that uses ICSharpCode.SharpZipLib under the hood to make it easy
i have library that is licensed under zlib/libpng and i what to use it
Alright, I have library I wrote in C that reads a file and provides
I have a library that is meant to be used by many websites. The
I have a library project that contains some samples in a subfolder. The library
Does the task parallel library have anything that would be considered a replacement or

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.