PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, September 12, 2022

[FIXED] How to detect sse availability in CMake

 September 12, 2022     build, cmake, cross-platform, sse     No comments   

Issue

In a CMakeLists.txt file, is there a way to detect the highest level of SSE available, and save it to CMAKE_CXX_FLAGS? In other words, I'd like to be able to write something like:

FindSSE()  # defines SSE_FLAGS
set(CMAKE_CXX_FLAGS ${SSE_FLAGS})

For example, if the platform supports up to SSE level 3, then FindSSE() would set SSE_FLAGS to -msse3.


Solution

This might be overkill, but the OptimizeForArchitecture.cmake from vc on gitorious will provide a list of optimizations based on the architecture.

You could either use that script directly or trim it down to the code you need.

A better solution would be to make a small cmake test script that uses SSE instructions and check if each variant compiles/runs.

EDIT: More specifically, there's also FindSSE.cmake in various places, although it still uses the somewhat clunky method of parsing /proc/cpuinfo



Answered By - jkerian
Answer Checked By - David Marino (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing