~brandontschaefer/compiz/lp.1075207-raring-super-p-patch

« back to all changes in this revision

Viewing changes to cmake/FindGoogleTest.cmake

  • Committer: Tarmac
  • Author(s): Sam Spilsbury
  • Date: 2013-02-19 14:44:27 UTC
  • mfrom: (3554.6.19 compiz.fix_1120009)
  • Revision ID: tarmac-20130219144427-2xzi2f9b4ap9b2r0
Enable xorg-gtest tests by default and build in CI.

This change also refactors a number of parts of the code to find and build the tests. It puts the logic to find Google Test and Xorg GTest in their own cmake files, and also splits the find logic with the build logic. Finally, it makes the xorg-gtest variables available to all subdirectories and not just the ones under tests/.

This change also refreshes some distro patches. A new option was added to not auto-load the ccp plugin, and also modifies one of the tests depending on a modified setting value.

(LP: #1120009). Fixes: https://bugs.launchpad.net/bugs/1120009.

Approved by Sam Spilsbury, Andrea Azzarone.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Find Google Test and Google Mock, either with pkg-config or by
 
2
# searching the system install paths. This sets:
 
3
#
 
4
# GOOGLE_TEST_AND_MOCK_FOUND
 
5
# GTEST_INCLUDE_DIR
 
6
# GTEST_ROOT_DIR
 
7
# GMOCK_LIBRARY
 
8
# GMOCK_MAIN_LIBRARY
 
9
 
 
10
find_package (GTest)
 
11
 
 
12
if (NOT GTEST_FOUND)
 
13
 
 
14
    # Check for google test and build it locally
 
15
    set (GTEST_ROOT_DIR
 
16
         "/usr/src/gtest" # Default value, adjustable by user with e.g., ccmake
 
17
         CACHE
 
18
         PATH
 
19
         "Path to Google Test srcs"
 
20
         FORCE)
 
21
 
 
22
    find_path (GTEST_INCLUDE_DIR gtest/gtest.h)
 
23
 
 
24
    set (GTEST_BOTH_LIBRARIES gtest gtest_main)
 
25
    set (GTEST_FOUND TRUE)
 
26
    set (GTEST_LOCAL_BUILD_REQUIRED TRUE)
 
27
 
 
28
else (NOT GTEST_FOUND)
 
29
 
 
30
    set (GTEST_LOCAL_BUILD_REQUIRED FALSE)
 
31
 
 
32
endif (NOT GTEST_FOUND)
 
33
 
 
34
find_library (GMOCK_LIBRARY gmock)
 
35
find_library (GMOCK_MAIN_LIBRARY gmock_main)
 
36
 
 
37
if (NOT GMOCK_LIBRARY OR NOT GMOCK_MAIN_LIBRARY OR NOT GTEST_FOUND)
 
38
 
 
39
    message ("Google Mock and Google Test not found - cannot build tests!")
 
40
    set (GOOGLE_TEST_AND_MOCK_FOUND OFF CACHE BOOL "" FORCE)
 
41
 
 
42
else (NOT GMOCK_LIBRARY OR NOT GMOCK_MAIN_LIBRARY OR NOT GTEST_FOUND)
 
43
 
 
44
    set (GOOGLE_TEST_AND_MOCK_FOUND ON CACHE BOOL "" FORCE)
 
45
 
 
46
endif (NOT GMOCK_LIBRARY OR NOT GMOCK_MAIN_LIBRARY OR NOT GTEST_FOUND)