summaryrefslogtreecommitdiff
path: root/Modules/FindGTest.cmake
diff options
context:
space:
mode:
authorPhilip Lowman <philip@yhbt.com>2009-08-16 22:12:04 -0400
committerPhilip Lowman <philip@yhbt.com>2009-08-16 22:12:04 -0400
commitc577608958f32fdf6e046be95d5ab3d92b49d815 (patch)
tree0726d969b90f754f6f0b4e974e7a9b740b94bde5 /Modules/FindGTest.cmake
parent47796c5cb96192530b7ffadcd4bef1cdc4edb876 (diff)
downloadcmake-c577608958f32fdf6e046be95d5ab3d92b49d815.tar.gz
A find module for the Google C++ Testing Framework
Diffstat (limited to 'Modules/FindGTest.cmake')
-rw-r--r--Modules/FindGTest.cmake69
1 files changed, 69 insertions, 0 deletions
diff --git a/Modules/FindGTest.cmake b/Modules/FindGTest.cmake
new file mode 100644
index 0000000000..30e67d349a
--- /dev/null
+++ b/Modules/FindGTest.cmake
@@ -0,0 +1,69 @@
+# Locate the Google C++ Testing Framework.
+#
+# Defines the following variables:
+#
+# GTEST_FOUND - Found the Google Testing framework
+# GTEST_INCLUDE_DIRS - Include directories
+# GTEST_LIBRARIES - The GTest library
+# GTEST_MAIN_LIBRARIES - The GTest library for automatic main()
+#
+# Accepts the following CMake/Environment variables as input:
+#
+# GTEST_ROOT - The root directory of the gtest install prefix
+#
+
+# Copyright (c) 2009, Philip Lowman <philip@yhbt.com>
+#
+# Redistribution AND use is allowed according to the terms of the New
+# BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+find_path(GTEST_INCLUDE_DIR gtest/gtest.h
+ HINTS
+ $ENV{GTEST_ROOT}/include
+ ${GTEST_ROOT}/include
+)
+
+function(_gtest_find_library _name _library)
+ find_library(${_name} ${_library}
+ HINTS
+ $ENV{GTEST_ROOT}
+ ${GTEST_ROOT}
+ PATH_SUFFIXES lib64 lib
+ )
+endfunction()
+
+_gtest_find_library(GTEST_LIBRARY gtest)
+_gtest_find_library(GTEST_LIBRARY_DEBUG gtestd)
+_gtest_find_library(GTEST_MAIN_LIBRARY gtest_main)
+_gtest_find_library(GTEST_MAIN_LIBRARY_DEBUG gtest_maind)
+
+mark_as_advanced(GTEST_INCLUDE_DIR)
+mark_as_advanced(GTEST_LIBRARY)
+mark_as_advanced(GTEST_LIBRARY_DEBUG)
+mark_as_advanced(GTEST_MAIN_LIBRARY)
+mark_as_advanced(GTEST_MAIN_LIBRARY_DEBUG)
+
+include(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTEST DEFAULT_MSG GTEST_INCLUDE_DIR GTEST_LIBRARY GTEST_MAIN_LIBRARY)
+
+set(GTEST_INCLUDE_DIRS ${GTEST_INCLUDE_DIR})
+
+# Have *_LIBRARIES contain debug/release keywords if DEBUG library is available
+
+if(GTEST_LIBRARY AND GTEST_LIBRARY_DEBUG)
+ set(GTEST_LIBRARIES
+ optimized ${GTEST_LIBRARY}
+ debug ${GTEST_LIBRARY_DEBUG})
+else()
+ set(GTEST_LIBRARIES ${GTEST_LIBRARY})
+endif()
+
+if(GTEST_MAIN_LIBRARY AND GTEST_MAIN_LIBRARY_DEBUG)
+ set(GTEST_MAIN_LIBRARIES
+ optimized ${GTEST_MAIN_LIBRARY}
+ debug ${GTEST_MAIN_LIBRARY_DEBUG})
+else()
+ set(GTEST_MAIN_LIBRARIES ${GTEST_MAIN_LIBRARY})
+endif()
+