- Limit -msse/-msse2 to files that actually use intrinsics

- Limit SSE/SSE2 optimizations to x86 CPUs (exposed as SIMD option)

PR:	205006
This commit is contained in:
Alexey Dokuchaev 2016-01-13 13:34:07 +00:00
parent 34d65e7749
commit 39cf587841
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=406040
3 changed files with 47 additions and 14 deletions

View file

@ -3,7 +3,7 @@
PORTNAME= lensfun
PORTVERSION= 0.3.0
PORTREVISION= 1
PORTREVISION= 2
CATEGORIES= graphics
MASTER_SITES= SF/${PORTNAME}/${PORTVERSION}
@ -19,13 +19,10 @@ USE_GNOME= glib20
USE_LDCONFIG= yes
CMAKE_ARGS= -DBUILD_AUXFUN:BOOL=ON -DINSTALL_HELPER_SCRIPTS:BOOL=OFF
.if ! ${MACHINE_CPU:Msse} == "sse"
CMAKE_ARGS+= -DBUILD_FOR_SSE:BOOL=OFF
.endif
OPTIONS_DEFINE= SIMD
OPTIONS_DEFAULT= SIMD
.if ! ${MACHINE_CPU:Msse2} == "sse2"
CMAKE_ARGS+= -DBUILD_FOR_SSE2:BOOL=OFF
.endif
SIMD_CMAKE_OFF= -DBUILD_FOR_SSE:BOOL=OFF -DBUILD_FOR_SSE2:BOOL=OFF
post-patch:
@${REINPLACE_CMD} -e '/pkgconfig/s,$${LIBDIR},libdata,' \

View file

@ -1,24 +1,46 @@
--- CMakeLists.txt.orig 2014-09-30 17:37:34 UTC
+++ CMakeLists.txt
@@ -46,15 +46,11 @@ ENDIF()
@@ -28,12 +28,18 @@ IF(NOT HAVE_REGEX_H)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/libs/regex)
ENDIF()
+IF(CMAKE_SYSTEM_PROCESSOR MATCHES "[XxIi][0-9]?86|[Aa][Mm][Dd]64")
+ SET(X86_ON ON)
+else()
+ SET(X86_ON OFF)
+ENDIF()
+
# options controlling the build process
OPTION(BUILD_STATIC "Build static library" OFF)
OPTION(BUILD_TESTS "Build test programs" OFF)
OPTION(BUILD_AUXFUN "Build auxfun library (requires libpng)" OFF)
-OPTION(BUILD_FOR_SSE "Build with support for SSE" ON)
-OPTION(BUILD_FOR_SSE2 "Build with support for SSE2" ON)
+OPTION(BUILD_FOR_SSE "Build with support for SSE" ${X86_ON})
+OPTION(BUILD_FOR_SSE2 "Build with support for SSE2" ${X86_ON})
OPTION(BUILD_DOC "Build documentation with doxygen" OFF)
OPTION(INSTALL_HELPER_SCRIPTS "Install various helper scripts" ON)
@@ -46,14 +52,14 @@ ENDIF()
IF(BUILD_FOR_SSE)
SET(VECTORIZATION_SSE 1)
- IF(CMAKE_COMPILER_IS_GNUCXX)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse")
- ENDIF()
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse")
+ IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+ SET(VECTORIZATION_SSE_FLAGS "-msse")
ENDIF()
ENDIF()
IF(BUILD_FOR_SSE2)
SET(VECTORIZATION_SSE2 1)
- IF(CMAKE_COMPILER_IS_GNUCXX)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2")
- ENDIF()
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2")
+ IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+ SET(VECTORIZATION_SSE2_FLAGS "-msse2")
ENDIF()
ENDIF()
IF(WIN32)
@@ -68,6 +64,7 @@ ENDIF()
@@ -68,6 +74,7 @@ ENDIF()
# find dependencies
FIND_PACKAGE(GLIB2 REQUIRED)
INCLUDE_DIRECTORIES(${GLIB2_INCLUDE_DIRS})

View file

@ -0,0 +1,14 @@
--- libs/lensfun/CMakeLists.txt.orig 2014-09-30 17:37:34 UTC
+++ libs/lensfun/CMakeLists.txt
@@ -9,6 +9,11 @@ IF(WIN32)
LIST(APPEND LENSFUN_SRC windows/auxfun.cpp)
ENDIF()
+SET_SOURCE_FILES_PROPERTIES(mod-color-sse.cpp mod-coord-sse.cpp
+ PROPERTIES COMPILE_FLAGS "${VECTORIZATION_SSE_FLAGS}")
+SET_SOURCE_FILES_PROPERTIES(mod-color-sse2.cpp
+ PROPERTIES COMPILE_FLAGS "${VECTORIZATION_SSE2_FLAGS}")
+
IF(BUILD_STATIC)
ADD_LIBRARY(lensfun STATIC ${LENSFUN_SRC})
ELSE()