Hello.

I'm using Debian GNU/Linux sid.
When i'm trying to build enblend after running cmake with 
*-DENABLE_SSE2:BOOL=ON*, it fails:

$ make
[  3%] Generating signature.h
Possible precedence issue with control flow operator at /home/lebedevri/src/
enblend/enblend.hg/src/DefaultSig.pm line 137.
Scanning dependencies of target enblend
[  7%] Building CXX object src/CMakeFiles/enblend.dir/filenameparse.cc.o
/home/lebedevri/src/enblend/enblend.hg/src/filenameparse.cc:1:0: error: CPU 
you selected does not support x86-64 instruction set
src/CMakeFiles/enblend.dir/build.make:60: recipe for target 
'src/CMakeFiles/enblend.dir/filenameparse.cc.o' failed
make[2]: *** [src/CMakeFiles/enblend.dir/filenameparse.cc.o] Error 1
CMakeFiles/Makefile2:81: recipe for target 'src/CMakeFiles/enblend.dir/all' 
failed
make[1]: *** [src/CMakeFiles/enblend.dir/all] Error 2
Makefile:137: recipe for target 'all' failed
make: *** [all] Error 2
This happens with GCC-4.9 and GCC-4.6 (and others too, probably).

Attached patch fixes issue for me by replacing hardcoded *-mtune=pentium4 *in 
CMAKE_CXX_FLAGS_RELEASE
by *-march=native* or *-mtune=native* or *-mtune=generic* depending on 
which one is working.

*Note*: it might be a good idea to set CXXFLAGS to *-mtune=generic* when 
doing build for release (for redistribution of binaries), but i have not 
found anything about this in CMakeLists.txt

If there is anything wrong with my patch, i am ready to fix it.

Thanks!

-- 
A list of frequently asked questions is available at: 
http://wiki.panotools.org/Hugin_FAQ
--- 
You received this message because you are subscribed to the Google Groups 
"hugin and other free panoramic software" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/hugin-ptx/cd1e3018-8e6d-456c-95d4-d408bfb869ac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
# HG changeset patch
# User Roman Lebedev <[email protected]>
# Date 1411505016 -14400
#      Wed Sep 24 00:43:36 2014 +0400
# Node ID c83d6adcebce5ca056aaf63495c98c2d87ca121b
# Parent  95c7e90f2be8f46446fce9c534075e19e2dd5387
CMakeLists.txt: replace hardcoded -mtune=pentium4 with -march=native or -mtune=native or -mtune=generic

This fixes enblend build for me (on Debian GNU/Linux sid), after running cmake with -DENABLE_SSE2:BOOL=ON

diff -r 95c7e90f2be8 -r c83d6adcebce CMakeLists.txt
--- a/CMakeLists.txt	Sun Sep 14 14:52:55 2014 +0200
+++ b/CMakeLists.txt	Wed Sep 24 00:43:36 2014 +0400
@@ -45,6 +45,7 @@
   set(SYSTEM_LIB_DIRS /usr/lib /usr/local/lib)
 endif()
 
+include(CheckCXXCompilerFlag)
 include(HuginMacros)
 include(FindLibraryForCPU)
 
@@ -316,7 +317,21 @@
 
 IF(ENABLE_SSE2)
   IF(CMAKE_COMPILER_IS_GNUCXX)
-    set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -msse2 -mtune=pentium4")
+    MESSAGE("-- Checking for -march=native support")
+    CHECK_CXX_COMPILER_FLAG("-march=native" MARCHNATIVE)
+    if (MARCHNATIVE)
+      set(MARCH "-march=native")
+    else()
+      MESSAGE("-- Checking for -mtune=native support")
+      CHECK_CXX_COMPILER_FLAG("-mtune=native" MTUNENATIVE)
+      if (MTUNENATIVE)
+        set(MARCH "-mtune=native")
+      else()
+        set(MARCH "-mtune=generic")
+      endif()
+    endif()
+
+    set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -msse2 ${MARCH}")
   ELSEIF(MSVC)
     set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /arch:SSE2")
   ENDIF(CMAKE_COMPILER_IS_GNUCXX)

Reply via email to