Browse files

modify build system to auto-detect eigen3, and fallback to eigen2

  • Loading branch information...
1 parent 10c7607 commit c4d68588a6f2f39ab60055a56fbc59b87ecee2e2 @donbright donbright committed Aug 19, 2012
Showing with 123 additions and 148 deletions.
  1. +1 −3 common.pri
  2. +75 −0 eigen.pri
  3. +0 −44 eigen2.pri
  4. +0 −43 eigen3.pri
  5. +1 −6 openscad.pro
  6. +11 −8 scripts/linux-build-dependencies.sh
  7. +2 −2 src/linalg.h
  8. +33 −42 tests/CMakeLists.txt
View
4 common.pri
@@ -10,7 +10,5 @@ include(cgal.pri)
include(opencsg.pri)
include(glew.pri)
include(boost.pri)
-
-CONFIG(eigen2) { include(eigen2.pri) }
-CONFIG(eigen3) { include(eigen3.pri) }
+include(eigen.pri)
View
75 eigen.pri
@@ -0,0 +1,75 @@
+# Detect eigen3 + eigen2, then use this priority list to determine
+# which eigen to use:
+#
+# Priority
+# 3. EIGEN3DIR / EIGEN2DIR if set
+# 1. OPENSCAD_LIBRARIES eigen3
+# 2. OPENSCAD_LIBRARIES eigen2
+# 4. system's standard include paths for eigen3
+# 5. system's standard include paths for eigen2
+
+eigen {
+
+# read environment variables
+OPENSCAD_LIBRARIES_DIR = $$(OPENSCAD_LIBRARIES)
+EIGEN2_DIR = $$(EIGEN2DIR)
+EIGEN3_DIR = $$(EIGEN3DIR)
+
+CONFIG(mingw-cross-env) {
+ EIGEN_INCLUDEPATH = mingw-cross-env/include/eigen2
+}
+
+# Optionally specify location of Eigen3 using the
+# OPENSCAD_LIBRARIES env. variable
+!isEmpty(OPENSCAD_LIBRARIES_DIR) {
+ isEmpty(EIGEN_INCLUDEPATH) {
+ exists($$OPENSCAD_LIBRARIES_DIR/include/eigen3) {
+ EIGEN_INCLUDEPATH = $$OPENSCAD_LIBRARIES_DIR/include/eigen3
+ }
+ }
+ isEmpty(EIGEN_INCLUDEPATH) {
+ exists($$OPENSCAD_LIBRARIES_DIR/include/eigen2) {
+ EIGEN_INCLUDEPATH = $$OPENSCAD_LIBRARIES_DIR/include/eigen2
+ }
+ }
+}
+
+
+# Optionally specify location of Eigen using the
+# EIGEN3DIR env. variable
+!isEmpty(EIGEN3_DIR) {
+ EIGEN_INCLUDEPATH = $$EIGEN3_DIR
+ message("EIGEN3 location: $$EIGEN3_INCLUDEPATH")
+}
+
+# Optionally specify location of Eigen using the
+# EIGEN2DIR env. variable
+!isEmpty(EIGEN2_DIR) {
+ EIGEN_INCLUDEPATH = $$EIGEN2_DIR
+ message("EIGEN2 location: $$EIGEN2_INCLUDEPATH")
+}
+
+isEmpty(EIGEN_INCLUDEPATH) {
+ freebsd-g++: EIGEN_INCLUDEPATH = /usr/local/include/eigen3
+ macx: EIGEN_INCLUDEPATH = /opt/local/include/eigen3
+ linux*|hurd*: EIGEN_INCLUDEPATH = /usr/include/eigen3
+ netbsd*: EIGEN_INCLUDEPATH = /usr/pkg/include/eigen3
+ !exists($$EIGEN_INCLUDEPATH) {
+ freebsd-g++: EIGEN_INCLUDEPATH = /usr/local/include/eigen2
+ macx: EIGEN_INCLUDEPATH = /opt/local/include/eigen2
+ linux*|hurd*: EIGEN_INCLUDEPATH = /usr/include/eigen2
+ netbsd*: EIGEN_INCLUDEPATH = /usr/pkg/include/eigen2
+ }
+}
+
+# disable Eigen SIMD optimizations for platforms where it breaks compilation
+!macx {
+ !freebsd-g++ {
+ QMAKE_CXXFLAGS += -DEIGEN_DONT_ALIGN
+ }
+}
+
+# EIGEN being under 'include/eigen[2-3]' needs special prepending
+QMAKE_INCDIR_QT = $$EIGEN_INCLUDEPATH $$QMAKE_INCDIR_QT
+
+} # eigen
View
44 eigen2.pri
@@ -1,44 +0,0 @@
-eigen2 {
-message("hi 2")
- CONFIG(mingw-cross-env) {
- EIGEN2_INCLUDEPATH = mingw-cross-env/include/eigen2
- }
-
- # Optionally specify location of Eigen2 using the
- # OPENSCAD_LIBRARIES env. variable
- isEmpty(EIGEN2_INCLUDEPATH) {
- OPENSCAD_LIBRARIES_DIR = $$(OPENSCAD_LIBRARIES)
- !isEmpty(OPENSCAD_LIBRARIES_DIR) {
- exists($$OPENSCAD_LIBRARIES_DIR/include/eigen2) {
- EIGEN2_INCLUDEPATH = $$OPENSCAD_LIBRARIES_DIR/include/eigen2
- }
- }
- }
-
- # Optionally specify location of Eigen2 using the
- # EIGEN2DIR env. variable
- isEmpty(EIGEN2_INCLUDEPATH) {
- EIGEN2_DIR = $$(EIGEN2DIR)
- !isEmpty(EIGEN2_DIR) {
- EIGEN2_INCLUDEPATH = $$EIGEN2_DIR
- message("EIGEN2 location: $$EIGEN2_INCLUDEPATH")
- }
- }
-
- isEmpty(EIGEN2_INCLUDEPATH) {
- freebsd-g++: EIGEN2_INCLUDEPATH = /usr/local/include/eigen2
- macx: EIGEN2_INCLUDEPATH = /opt/local/include/eigen2
- linux*|hurd*: EIGEN2_INCLUDEPATH = /usr/include/eigen2
- netbsd*: EIGEN2_INCLUDEPATH = /usr/pkg/include/eigen2
- }
-
- # eigen2 being under 'include/eigen2' needs special prepending
- QMAKE_INCDIR_QT = $$EIGEN2_INCLUDEPATH $$QMAKE_INCDIR_QT
-
- # disable Eigen SIMD optimizations for platforms where it breaks compilation
- !macx {
- !freebsd-g++ {
- QMAKE_CXXFLAGS += -DEIGEN_DONT_ALIGN
- }
- }
-}
View
43 eigen3.pri
@@ -1,43 +0,0 @@
-eigen3 {
- CONFIG(mingw-cross-env) {
- EIGEN3_INCLUDEPATH = mingw-cross-env/include/eigen3
- }
-
- # Optionally specify location of Eigen3 using the
- # OPENSCAD_LIBRARIES env. variable
- isEmpty(EIGEN3_INCLUDEPATH) {
- OPENSCAD_LIBRARIES_DIR = $$(OPENSCAD_LIBRARIES)
- !isEmpty(OPENSCAD_LIBRARIES_DIR) {
- exists($$OPENSCAD_LIBRARIES_DIR/include/eigen3) {
- EIGEN3_INCLUDEPATH = $$OPENSCAD_LIBRARIES_DIR/include/eigen3
- }
- }
- }
-
- # Optionally specify location of Eigen3 using the
- # EIGEN3DIR env. variable
- isEmpty(EIGEN3_INCLUDEPATH) {
- EIGEN3_DIR = $$(EIGEN3DIR)
- !isEmpty(EIGEN3_DIR) {
- EIGEN3_INCLUDEPATH = $$EIGEN3_DIR
- message("EIGEN3 location: $$EIGEN3_INCLUDEPATH")
- }
- }
-
- isEmpty(EIGEN3_INCLUDEPATH) {
- freebsd-g++: EIGEN3_INCLUDEPATH = /usr/local/include/eigen3
- macx: EIGEN3_INCLUDEPATH = /opt/local/include/eigen3
- linux*|hurd*: EIGEN3_INCLUDEPATH = /usr/include/eigen3
- netbsd*: EIGEN3_INCLUDEPATH = /usr/pkg/include/eigen3
- }
-
- # EIGEN3 being under 'include/eigen3' needs special prepending
- QMAKE_INCDIR_QT = $$EIGEN3_INCLUDEPATH $$QMAKE_INCDIR_QT
-
- # disable Eigen SIMD optimizations for platforms where it breaks compilation
- !macx {
- !freebsd-g++ {
- QMAKE_CXXFLAGS += -DEIGEN_DONT_ALIGN
- }
- }
-}
View
7 openscad.pro
@@ -124,12 +124,7 @@ macx:CONFIG += mdi
CONFIG += cgal
CONFIG += opencsg
CONFIG += boost
-#macx {
-unix {
- CONFIG += eigen3
-} else {
- CONFIG += eigen2
-}
+CONFIG += eigen
#Uncomment the following line to enable QCodeEdit
#CONFIG += qcodeedit
View
19 scripts/linux-build-dependencies.sh
@@ -246,17 +246,20 @@ build_eigen()
echo "Building eigen" $version "..."
cd $BASEDIR/src
rm -rf eigen-$version
- ## Directory name for v2.0.17
- rm -rf eigen-eigen-b23437e61a07
- rm -rf eigen-eigen-43d9075b23ef # 3.1.1
+ EIGENDIR="none"
+ if [ $version = "2.0.17" ]; then EIGENDIR=eigen-eigen-b23437e61a07; fi
+ if [ $version = "3.1.1" ]; then EIGENDIR=eigen-eigen-43d9075b23ef; fi
+ if [ $EIGENDIR = "none" ]; then
+ echo Unknown eigen version. Please edit script.
+ exit 1
+ fi
+ rm -rf ./$EIGENDIR
if [ ! -f eigen-$version.tar.bz2 ]; then
curl -LO http://bitbucket.org/eigen/eigen/get/$version.tar.bz2
mv $version.tar.bz2 eigen-$version.tar.bz2
fi
tar xjf eigen-$version.tar.bz2
- ## File name for v2.0.17
- ln -s eigen-eigen-b23437e61a07 eigen-$version
- ln -s eigen-eigen-43d9075b23ef eigen-$version # 3.1.1
+ ln -s ./$EIGENDIR eigen-$version
cd eigen-$version
mkdir build
cd build
@@ -323,8 +326,8 @@ fi
# edit version numbers here as needed.
#
-build_eigen 2.0.17
-#build_eigen 3.1.1
+#build_eigen 2.0.17
+build_eigen 3.1.1
#build_gmp 5.0.5
#build_mpfr 3.1.1
#build_boost 1.47.0
View
4 src/linalg.h
@@ -12,10 +12,10 @@ typedef Eigen::AlignedBox<double, 3> BoundingBox;
using Eigen::Matrix3f;
using Eigen::Matrix3d;
using Eigen::Matrix4d;
-#if EIGEN_WORLD_VERSION>=3
+#if EIGEN_WORLD_VERSION >= 3
#define Transform3d Eigen::Affine3d
#else
-using Eigen::Transform3d
+using Eigen::Transform3d;
#endif
BoundingBox operator*(const Transform3d &m, const BoundingBox &box);
View
75 tests/CMakeLists.txt
@@ -159,15 +159,43 @@ set(CMAKE_INCLUDE_DIRECTORIES_BEFORE OFF)
# Eigen
+# First try to find Eigen3. If it's not there, fallback to Eigen2
-set( EIGEN_VERSION 3 )
-if( ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" )
- set( EIGEN_VERSION 3 )
+# Eigen3
+
+if (NOT $ENV{EIGEN3DIR} STREQUAL "")
+ set(EIGEN3_DIR "$ENV{EIGEN3DIR}")
+elseif (NOT $ENV{OPENSCAD_LIBRARIES} STREQUAL "")
+ set(EIGEN3_DIR "$ENV{OPENSCAD_LIBRARIES}")
endif()
+if (NOT EIGEN3_INCLUDE_DIR)
+ if (EIGEN3_DIR)
+ set(EIGEN3_FIND_HINTS "${EIGEN3_DIR}/include/eigen3")
+ endif()
+ if (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
+ set(EIGEN3_FIND_PATHS /usr/local/include/eigen3)
+ elseif (${CMAKE_SYSTEM_NAME} MATCHES "NetBSD")
+ set(EIGEN3_FIND_PATHS /usr/pkg/include/eigen3)
+ else()
+ set(EIGEN3_FIND_PATHS /opt/local/include/eigen3 /usr/include/eigen3)
+ endif()
+ find_path(EIGEN3_INCLUDE_DIR
+ Eigen/Core
+ HINTS ${EIGEN3_FIND_HINTS}
+ PATHS ${EIGEN3_FIND_PATHS})
+ if (NOT EIGEN3_INCLUDE_DIR)
+ message(STATUS "Eigen3 not found, will attempt to find Eigen2")
+ else()
+ message(STATUS "Eigen3 found in " ${EIGEN3_INCLUDE_DIR})
+ inclusion(EIGEN3_DIR EIGEN3_INCLUDE_DIR)
+ endif()
+endif()
+
+
# Eigen2
-if( ${EIGEN_VERSION} EQUAL 2)
+if (NOT EIGEN3_INCLUDE_DIR)
# Turn off Eigen SIMD optimization
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
@@ -205,44 +233,7 @@ if (NOT EIGEN2_INCLUDE_DIR)
endif()
inclusion(EIGEN2_DIR EIGEN2_INCLUDE_DIR)
-endif() # EIGEN_VERSION 2
-
-
-# Eigen3
-
-if( ${EIGEN_VERSION} EQUAL 3)
-
-if (NOT $ENV{EIGEN3DIR} STREQUAL "")
- set(EIGEN3_DIR "$ENV{EIGEN3DIR}")
-elseif (NOT $ENV{OPENSCAD_LIBRARIES} STREQUAL "")
- set(EIGEN3_DIR "$ENV{OPENSCAD_LIBRARIES}")
-endif()
-
-if (NOT EIGEN3_INCLUDE_DIR)
- if (EIGEN3_DIR)
- set(EIGEN3_FIND_HINTS "${EIGEN3_DIR}/include/eigen3")
- endif()
- if (${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
- set(EIGEN3_FIND_PATHS /usr/local/include/eigen3)
- elseif (${CMAKE_SYSTEM_NAME} MATCHES "NetBSD")
- set(EIGEN3_FIND_PATHS /usr/pkg/include/eigen3)
- else()
- set(EIGEN3_FIND_PATHS /opt/local/include/eigen3 /usr/include/eigen3)
- endif()
- find_path(EIGEN3_INCLUDE_DIR
- Eigen/Core
- HINTS ${EIGEN3_FIND_HINTS}
- PATHS ${EIGEN3_FIND_PATHS})
- if (NOT EIGEN3_INCLUDE_DIR)
- message(FATAL_ERROR "Eigen3 not found")
- else()
- message(STATUS "Eigen3 found in " ${EIGEN3_INCLUDE_DIR})
- endif()
-endif()
-inclusion(EIGEN3_DIR EIGEN3_INCLUDE_DIR)
-
-endif() # EIGEN_VERSION 3
-
+endif() # if (NOT EIGEN3_INCLUDE_DIR)
# OpenCSG
if (NOT $ENV{OPENCSGDIR} STREQUAL "")

0 comments on commit c4d6858

Please sign in to comment.