5

I´m trying to compile some C++ code with cmake and make that uses the include <emmintrin.h> and get the following make error:

 #error "SSE2 instruction set not enabled"

I have an Intel Celeron Dual Core processor with a Linux (Mint) system (Kernel 3.5).

According to Wikipedia the Celeron Dual Core is capable to execute SSE2 instructions and the sse2 flag is set according to /proc/cpuinfo. But the author of this question mentions a limited SSE support of the Intel Celeron.

I've already tried to use the SSE compiler options in my CMakeLists.txt:

set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} "-msse -msse2 -msse3")

..but nothing changed. cmake . works fine but make gives the error message above.

Do I have to change the settings in CMakeLists.txt or does the Celeron Dual Core simply not (fully) support SSE2?

Community
  • 1
  • 1
Suzana
  • 4,251
  • 2
  • 28
  • 52
  • Did you check your BIOS settings? http://www.techarp.com/showfreebog.aspx?lang=0&bogno=259 – Arun May 07 '13 at 02:11
  • Yes, my BIOS has no settings for enabling or disabling SSE. – Suzana May 07 '13 at 02:25
  • cmake and make doesn't map one-to-one. If you are using generated makefile for make, pls make sure it has got those SSE2 flags in. – Arun May 07 '13 at 02:38
  • 2
    Did you try `set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse -msse2 -msse3")` (note the position of the quotation marks) or `set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse -msse2 -msse3")`? – Fraser May 07 '13 at 02:40
  • 1
    `set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse -msse2 -msse3")` works! Thank you! Do you have any idea why? And please post your comment as answer so I can accept it... – Suzana May 07 '13 at 03:02
  • You are including a wrong file! See my [answer](http://stackoverflow.com/questions/9144545/sse-instruction-set-not-enabled/23839884#23839884) in similar topic! – TrueY May 23 '14 at 23:57

1 Answers1

6

You need to call

set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} "-msse -msse2 -msse3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse -msse2 -msse3")

The CMAKE_C_FLAGS are applied to C files, and from your post's C++ tag, I guess you're compiling C++ files, hence the need to change CMAKE_CXX_FLAGS instead.

As for the positioning of the quotation marks; in your original version, you were setting CMAKE_C_FLAGS to contain 2 separate entries, the first being the starting value of CMAKE_C_FLAGS and the second being the string "-msse -msse2 -msse3".

CMake holds lists like this as semi-colon separated entries. In the case of CMAKE_<lang>_FLAGS, invariably they are a single value comprised of a string containing all the required flags.

Fraser
  • 74,704
  • 20
  • 238
  • 215
  • This save my day. thank you so much. (try to build bwa on hadoop). – Jirapong May 31 '13 at 04:45
  • Is there a portable way to do this?? Especially in modern CMake, like target based where you're not supposed to be manipulating the global CXX flags. This seems like the wrong way to do it now days. – johnb003 Jun 19 '18 at 18:31