Incorporate RHEL build fixes from Brian Pitts

CMake build fixed so that versioned shared libraries are installed
(along with .so symlinks)

Change-Id: Ibbaea9d37d17754cb8c3cd36fc17d015ca7d2a57
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 06031ec..b89d55a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -113,7 +113,9 @@
 LIST(APPEND CMAKE_LIBRARY_PATH /opt/local/lib)
 LIST(APPEND CMAKE_LIBRARY_PATH /opt/local/lib/ufsparse) # Mac OS X
 LIST(APPEND CMAKE_LIBRARY_PATH /usr/lib)
+LIST(APPEND CMAKE_LIBRARY_PATH /usr/lib/atlas)
 LIST(APPEND CMAKE_LIBRARY_PATH /usr/lib/suitesparse) # Ubuntu
+LIST(APPEND CMAKE_LIBRARY_PATH /usr/lib64/atlas)
 LIST(APPEND CMAKE_LIBRARY_PATH /usr/local/homebrew/lib) # Mac OS X
 LIST(APPEND CMAKE_LIBRARY_PATH /usr/local/lib)
 LIST(APPEND CMAKE_LIBRARY_PATH /usr/local/lib/suitesparse)
diff --git a/internal/ceres/CMakeLists.txt b/internal/ceres/CMakeLists.txt
index 7562f5c..610e816 100644
--- a/internal/ceres/CMakeLists.txt
+++ b/internal/ceres/CMakeLists.txt
@@ -193,6 +193,10 @@
     ${CERES_INTERNAL_SCHUR_FILES})
 
 ADD_LIBRARY(ceres ${CERES_LIBRARY_SOURCE})
+SET_TARGET_PROPERTIES(ceres PROPERTIES
+  VERSION ${CERES_VERSION}
+  SOVERSION ${CERES_VERSION_MAJOR}
+)
 TARGET_LINK_LIBRARIES(ceres ${CERES_LIBRARY_DEPENDENCIES})
 
 INSTALL(TARGETS ceres
diff --git a/scripts/ceres-solver.spec b/scripts/ceres-solver.spec
index 8709b51..b3b6f0f 100644
--- a/scripts/ceres-solver.spec
+++ b/scripts/ceres-solver.spec
@@ -3,13 +3,13 @@
 # Release candidate versions are messy. Give them a release of
 # e.g. "0.1.0%{?dist}" for RC1 (and remember to adjust the Source0
 # URL). Non-RC releases go back to incrementing integers starting at 1.
-Release:        "0.3.0%{?dist}"
+Release:        0.3.0%{?dist}
 Summary:        A non-linear least squares minimizer
 
 Group:          Development/Libraries
 License:        BSD
 URL:            http://code.google.com/p/ceres-solver/
-Source0:        http://%{name}.googlecode.com/files/%{name}-%{version}rc2.tar.gz
+Source0:        http://%{name}.googlecode.com/files/%{name}-%{version}rc3.tar.gz
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
 %if (0%{?rhel} == 06)
@@ -18,7 +18,13 @@
 BuildRequires:  cmake
 %endif
 BuildRequires:  eigen3-devel
-BuildRequires:  suitesparse-devel
+# suitesparse <= 3.4.0-7 ships without *.hpp C++ headers
+# https://bugzilla.redhat.com/show_bug.cgi?id=1001869
+BuildRequires:  suitesparse-devel > 3.4.0-7
+# If the suitesparse package was built with TBB then we need TBB too
+%ifarch %{ix86} x86_64 ia64
+BuildRequires:  tbb-devel
+%endif
 # Use atlas for BLAS and LAPACK
 BuildRequires:  atlas-devel
 BuildRequires:  gflags-devel
@@ -65,12 +71,10 @@
 # packages because it breaks the build since release 1.5.0rc1
 %define optflags ""
 %if (0%{?rhel} == 06)
-%{cmake28} .. \
+%{cmake28} ..
 %else
-%{cmake} .. \
+%{cmake} ..
 %endif
-    -DBLAS_LIB:FILEPATH=%{_libdir}/atlas/libatlas.so \
-    -DLAPACK_LIB:FILEPATH=%{_libdir}/atlas/liblapack.so
 make %{?_smp_mflags}
 
 
@@ -80,6 +84,9 @@
 make install DESTDIR=$RPM_BUILD_ROOT
 find $RPM_BUILD_ROOT -name '*.la' -delete
 
+# Make the subdirectory in /usr/share match the name of this package
+mv $RPM_BUILD_ROOT%{_datadir}/{Ceres,%{name}}
+
 
 %clean
 rm -rf $RPM_BUILD_ROOT
@@ -92,22 +99,24 @@
 
 %files
 %defattr(-,root,root,-)
-%doc
+%doc README LICENSE
 %{_libdir}/*.so.*
 
 %files devel
 %defattr(-,root,root,-)
-%doc
 %{_includedir}/*
 %{_libdir}/*.so
-%{_libdir}/*.a
+%{_datadir}/%{name}/*.cmake
 
 
 %changelog
-* Mon August 26 2013 Sameer Agarwal <sameeragarwal@google.com> - 1.7.0-3
+* Thu Aug 29 2013 Taylor Braun-Jones <taylor@braun-jones.org> - 1.7.0-0.3.0
 - Bump version
 
-* Mon July 18 2013 Sameer Agarwal <sameeragarwal@google.com> - 1.7.0-0
+* Mon Aug 26 2013 Sameer Agarwal <sameeragarwal@google.com> - 1.7.0-0.2.0
+- Bump version
+
+* Mon Jul 18 2013 Sameer Agarwal <sameeragarwal@google.com> - 1.7.0-0.1.0
 - Bump version
 
 * Mon Apr 29 2013 Sameer Agarwal <sameeragarwal@google.com> - 1.6.0-1