Commit Graph

14 Commits

Author SHA1 Message Date
Alex Stewart 8b32e258cc Fix failed if() condition expansion if gflags is not found.
- If a CMake-ified version of gflags is not detected, then
  gflags_LIBRARIES is not set and the TARGET condition within a
  multiconditional if() statement prevents configuration.

Change-Id: Ia92e97523d7a1478ab36539726b9540d7cfee5d0
2015-08-09 15:42:39 +01:00
Alex Stewart cc8d47aabb Update all CMake to lowercase function name style.
- Updated to new CMake style where function names are all lowercase,
  this will be backwards compatible as CMake function names are
  case insensitive.
- Updated using Emacs' M-x unscreamify-cmake-buffer.

Change-Id: If7219816f560270e59212813aeb021353a64a0e2
2015-08-09 15:18:42 +01:00
Alex Stewart 16ecd40523 Fix bug in gflags' <= 2.1.2 exported CMake configuration.
- gflags <= 2.1.2 has a bug in its exported gflags-config.cmake:
  https://github.com/gflags/gflags/issues/110 whereby it sets
  gflags_LIBRARIES to a non-existent 'gflags' target.
- This causes linker errors if gflags is installed in a non-standard
  location (as otherwise CMake resolves gflags to -lgflags which
  links if gflags is installed somewhere on the current path).
- We now check for this case, and search for the correct gflags imported
  target and update gflags_LIBRARIES to reference it if found, otherwise
  proceed on to the original manual search to try to find gflags.

Change-Id: Iceccc3ee53c7c2010e41cc45255f966e7b13d526
2015-08-08 17:32:31 +01:00
Alex Stewart 7b4fb69dad Cleanup FindGflags & use installed gflags CMake config if present.
- Split out gflags namespace detection methods:
  check_cxx_source_compiles() & regex, into separate functions.
- Use installed/exported gflags CMake configuration (present for
  versions >= 2.1) if available, unless user expresses a preference not
  to, or specifies search directories, in which case fall back to manual
  search for components.
-- Prefer installed gflags CMake configurations over exported gflags
   build directories on all OSs.
- Remove custom version of check_cxx_source_compiles() that attempted
  to force the build type of the test project.  This only worked for
  NMake on Windows, not MSVC as msbuild ignored our attempts to force
  the build type.  Now we always use the regex method on Windows if
  we cannot find an installed gflags CMake configuration which works
  even on MSVC by bypassing msbuild.
- Add default search paths for gflags on Windows.

Change-Id: I083b267d97a7a5838a1314f3d41a61ae48d5a2d7
2015-07-15 22:12:44 +00:00
Alex Stewart 58ee9f7d9b Handle possible presence of library prefixes in MSVC.
- On MSVC, a Ceres dependency such as glog, may be named glog.lib, or
  libglog.lib.  By default, CMake assumes no prefix for libraries on
  MSVC when using find_library(), thus find_library(glog) would fail
  if glog was named libglog.lib.
- This patch caches & updates CMAKE_FIND_LIBRARY_PREFIXES in all of
  Ceres' find_package scripts to include lib & "" (no prefix) on MSVC
  and then returns CMAKE_FIND_LIBRARY_PREFIXES to its original state
  before returning.

Change-Id: Ic82799e3b786cfb7228a51183bc189578b072bbe
2015-03-31 00:47:44 +00:00
Alex Stewart b611bdea11 Fix missing gflags shlwapi dependency on MinGW.
- Reported by Simeon (s1m3mu3@gmail.com) on Ceres mailing list.

Change-Id: If23491128fb6320d9b643eb3d5db7d9e67ffcf0b
2015-03-24 18:21:07 +00:00
Alex Stewart 5a21b8b1e9 Add thread dependency & fix namespace detection on Windows for gflags.
- Add missing gflags threading dependency.
- Also add optional gflags Shlwapi dependency on Windows.
- Add check_cxx_source_compiles() with CMAKE_BUILD_TYPE to fix
  namespace test builds on Windows with NMake generators.
- Add namespace regex on gflags.h when check_cxx_source_compiles()
  fails on Windows using Visual Studio generator.

Change-Id: I6570c566e5a29c665d621a54935c16d16bac7117
2015-03-21 17:55:19 +00:00
Keir Mierle 7492b0d8de Update copyright headers with new year and URL
Since Ceres is moving to using GitHub for issues, and the Google
Code URL in the current copyright header will soon become invalid,
update all the headers.

Change-Id: I1fce70375d1bcf098591f07b4d8f01a5c1e0789c
2015-03-18 05:43:23 +00:00
Alex Stewart cbe694505e Autodetect gflags namespace.
- At version 2.1, gflags changed from using the google namespace, to
  using gflags by default.  However, it can be configured at build time
  to be something else (which would be google for legacy compatibility
  unless you were evil).
- Ceres previously assumed that gflags was in the google namespace.
- Now, FindGFlags.cmake extracts the namespace when gflags.h is found
  and saves it in GFLAGS_NAMESPACE.
- When building the tests and examples that require gflags,
  CERES_GFLAGS_NAMESPACE is defined to be the detected namespace, and
  all tests/examples now use CERES_GFLAGS_NAMESPACE:: instead of
  google:: when calling gflags functions.

Change-Id: Ia333df7a7e2f08ba9f26bbd339c3a785b88f04c4
2014-11-27 09:56:37 +00:00
Alex Stewart 4d0e626b55 Fixing gflags HINTS variable names (adding missing “_DIR”).
- The HINTS variables for gflags were incorrectly used as
  GFLAGS_[INCLUDE/LIBRARY]_HINTS when they should have been
  GFLAGS_[INCLUDE/LIBRARY]_DIR_HINTS as per the docs.
- Also removing a completed TODO in the main CMakeLists.
- Updating method of extracting current directory in CeresConfig.cmake
  to avoid use of CMAKE_CURRENT_LIST_DIR, which was not present in
  CMake =< v2.8.3.

Change-Id: I42ae696e3b785febe48688d912f0f343e8947cb0
2013-11-15 14:51:21 +00:00
Alex Stewart 69bd65ff43 Downgrading warning messages when optional deps are not found.
- Now when find_package() is called for a dependency without the
  REQUIRED or QUIET qualifiers, we emit no priority (above STATUS, but
  below WARNING) messages and continue.

Change-Id: I8cdeda7a8f6c91d45fb7f24fb366244c6c9b66e1
2013-11-04 23:01:14 +00:00
Alex Stewart 6fed9fe0de Fix FindPackage scripts to emit warnings, not errors if not found.
- Previously we used message priority: SEND_ERROR when a package was
  not found and find_package() was called without QUIET or REQUIRED,
  which emits an error message, and prevents generation, but continues
  configuration.
- The fact SEND_ERROR induces an error message was confusing for users
  as it implies that something bad has happened and they cannot
  continue, when in fact we were disabling the option in question
  and were thus able to continue, all they had to do was re-configure.

- This commit also reorders the search lists for includes/libraries
  so that we always search user installed locations (e.g. /usr/local)
  before system installed locations.  Thus we will now always prefer
  a user install to a system install if both are available, which is
  likely to be the users desired intention.

Change-Id: Ide84919f27d3373f31282f70c685720cd77a6723
2013-11-04 19:08:17 +00:00
Alex Stewart 21e7c0fcc7 Adding option for static/shared CRT in MSVC & Windows fixes.
- MSVC users can now choose whether to use the static or shared
  C-Run Time (CRT) libraries explicitly.
- FindPackage() scripts now check that the lowercase libraries match
  the expected library names, as Windows uses CamelCase for some
  library names (other OSs don't).

Change-Id: Icbba5e9bf80181a5437e5009bdda1c12934bc6f3
2013-10-19 14:25:07 +01:00
Alex Stewart 78cc2c4719 Cleaning up exported CeresConfig.cmake.
- Adding FindPackage scripts for all of Ceres dependencies.
- Moving depend.cmake contents to CeresConfig.cmake and cleaning up
  search for Ceres & required dependencies, no longer push Ceres
  options into client.
- Fixing uninstall to remove ceres include root directory.
- Fixing main CMakeLists to install miniglog header if enabled.
- Making miniglog library shared/static with Ceres library.

Change-Id: If926bebd11720230c5136597ccba672394ed9777
2013-10-17 19:13:08 +00:00