~ubuntu-branches/ubuntu/trusty/compiz/trusty

« back to all changes in this revision

Viewing changes to cmake/GoogleTest.cmake

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release
  • Date: 2013-08-22 06:58:07 UTC
  • mto: This revision was merged to the branch mainline in revision 3352.
  • Revision ID: package-import@ubuntu.com-20130822065807-17nlzez0d30y09so
Tags: upstream-0.9.10+13.10.20130822
ImportĀ upstreamĀ versionĀ 0.9.10+13.10.20130822

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# GoogleTest.cmake
2
 
# build_google_test_locally (dir) takes a subdirectory
3
 
# and builds Google Test in there locally if required
4
 
 
5
 
function (build_google_test_locally build_directory)
6
 
 
7
 
    if (GOOGLE_TEST_AND_MOCK_FOUND)
8
 
 
9
 
        if (GTEST_LOCAL_BUILD_REQUIRED)
10
 
 
11
 
            add_subdirectory (${GTEST_ROOT_DIR}
12
 
                              ${build_directory})
13
 
 
14
 
        endif (GTEST_LOCAL_BUILD_REQUIRED)
15
 
 
16
 
        include_directories (${GTEST_INCLUDE_DIRS})
17
 
 
18
 
    endif (GOOGLE_TEST_AND_MOCK_FOUND)
19
 
 
20
 
endfunction ()
 
1
find_package (Threads REQUIRED)
 
2
 
 
3
# Find the the Google Mock include directory
 
4
# by searching the system-wide include directory
 
5
# paths
 
6
find_path (GMOCK_INCLUDE_DIR
 
7
           gmock/gmock.h)
 
8
 
 
9
if (GMOCK_INCLUDE_DIR)
 
10
    set (GMOCK_INCLUDE_BASE "include/")
 
11
    string (LENGTH ${GMOCK_INCLUDE_BASE} GMOCK_INCLUDE_BASE_LENGTH)
 
12
    string (LENGTH ${GMOCK_INCLUDE_DIR} GMOCK_INCLUDE_DIR_LENGTH)
 
13
 
 
14
    math (EXPR
 
15
          GMOCK_INCLUDE_PREFIX_LENGTH
 
16
          "${GMOCK_INCLUDE_DIR_LENGTH} - ${GMOCK_INCLUDE_BASE_LENGTH}")
 
17
    string (SUBSTRING
 
18
            ${GMOCK_INCLUDE_DIR}
 
19
            0
 
20
            ${GMOCK_INCLUDE_PREFIX_LENGTH}
 
21
            GMOCK_INCLUDE_PREFIX)
 
22
 
 
23
    set (GMOCK_SRC_DIR ${GMOCK_INCLUDE_PREFIX}/src/gmock CACHE PATH "Path to Google Mock Sources")
 
24
    set (GMOCK_INCLUDE_DIR ${GMOCK_INCLUDE_DIR} CACHE PATH "Path to Google Mock Headers")
 
25
    set (GTEST_INCLUDE_DIR ${GMOCK_SRC_DIR}/gtest/include CACHE PATH "Path to Google Test Headers")
 
26
 
 
27
    set (GMOCK_LIBRARY "gmock" CACHE STRING "Name of the Google Mock library")
 
28
    set (GMOCK_MAIN_LIBRARY "gmock_main" CACHE STIRNG "Name of the Google Mock main () library")
 
29
    set (GTEST_BOTH_LIBRARIES ${CMAKE_THREAD_LIBS_INIT} gtest gtest_main)
 
30
 
 
31
endif (GMOCK_INCLUDE_DIR)
 
32
 
 
33
if (NOT GTEST_BOTH_LIBRARIES)
 
34
 
 
35
    set (GTEST_FOUND FALSE)
 
36
 
 
37
else (NOT GTEST_BOTH_LIBRARIES)
 
38
 
 
39
    set (GTEST_FOUND TRUE)
 
40
 
 
41
endif (NOT GTEST_BOTH_LIBRARIES)
 
42
 
 
43
if (NOT GMOCK_LIBRARY OR NOT GMOCK_MAIN_LIBRARY OR NOT GTEST_FOUND)
 
44
 
 
45
    message ("Google Mock and Google Test not found - cannot build tests!")
 
46
    set (GOOGLE_TEST_AND_MOCK_FOUND FALSE)
 
47
 
 
48
else (NOT GMOCK_LIBRARY OR NOT GMOCK_MAIN_LIBRARY OR NOT GTEST_FOUND)
 
49
 
 
50
    set (GOOGLE_TEST_AND_MOCK_FOUND TRUE)
 
51
 
 
52
    add_definitions(-DGTEST_USE_OWN_TR1_TUPLE=0)
 
53
    add_subdirectory (${GMOCK_SRC_DIR} ${CMAKE_BINARY_DIR}/__gmock)
 
54
    include_directories (${GMOCK_INCLUDE_DIR}
 
55
                         ${GTEST_INCLUDE_DIR})
 
56
 
 
57
 
 
58
endif (NOT GMOCK_LIBRARY OR NOT GMOCK_MAIN_LIBRARY OR NOT GTEST_FOUND)