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

« back to all changes in this revision

Viewing changes to CMakeLists.txt

  • 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:
22
22
# GSettings schema recompilation
23
23
include (CompizGSettings)
24
24
 
 
25
# Google Test and Xorg-GTest
 
26
include (GoogleTest)
 
27
include (XorgGTest)
 
28
 
25
29
include (cmake/base.cmake)
26
30
# Check if specific function is present in library.
27
31
include (CheckFunctionExists)
137
141
 
138
142
if (COMPIZ_BUILD_TESTING)
139
143
 
140
 
    # Build Google Test and make its headers known
141
 
    find_package (GTest)
142
 
 
143
 
    if (NOT GTEST_FOUND)
144
 
 
145
 
        # Check for google test and build it locally
146
 
        set (GTEST_ROOT_DIR
147
 
             "/usr/src/gtest" # Default value, adjustable by user with e.g., ccmake
148
 
             CACHE
149
 
             PATH
150
 
             "Path to Google Test srcs"
151
 
             FORCE
152
 
        )
153
 
 
154
 
        find_path (GTEST_INCLUDE_DIR gtest/gtest.h)
155
 
 
156
 
        if (GTEST_INCLUDE_DIR)
157
 
            add_subdirectory (${GTEST_ROOT_DIR}
158
 
                             gtest)
159
 
        endif (GTEST_INCLUDE_DIR)
160
 
 
161
 
        set (GTEST_BOTH_LIBRARIES gtest gtest_main)
162
 
        set (GTEST_FOUND TRUE)
163
 
 
164
 
    endif (NOT GTEST_FOUND)
165
 
 
166
 
    find_library (GMOCK_LIBRARY gmock)
167
 
    find_library (GMOCK_MAIN_LIBRARY gmock_main)
168
 
 
169
 
    if (NOT GMOCK_LIBRARY OR NOT GMOCK_MAIN_LIBRARY OR NOT GTEST_FOUND)
170
 
 
171
 
        message ("Google Mock and Google Test not found - cannot build tests!")
 
144
    find_package (GoogleTest)
 
145
 
 
146
    if (GOOGLE_TEST_AND_MOCK_FOUND)
 
147
 
 
148
        build_google_test_locally (${CMAKE_BINARY_DIR}/__gtest)
 
149
 
 
150
        if (BUILD_XORG_GTEST)
 
151
 
 
152
            find_package (XorgGTest)
 
153
 
 
154
            set (COMPIZ_XORG_GTEST_DIR ${CMAKE_BINARY_DIR}/__xorg_gtest CACHE PATH "Path to Xorg GTest build dir" FORCE)
 
155
            set (COMPIZ_XORG_GTEST_WRAPPER ${COMPIZ_XORG_GTEST_DIR}/xorg_gtest_wrapper CACHE PATH "Path to Xorg GTest wrapper" FORCE)
 
156
 
 
157
            if (XORG_GTEST_FOUND)
 
158
 
 
159
                build_xorg_gtest_locally (${CMAKE_BINARY_DIR}/__xorg_gtest)
 
160
 
 
161
            else (XORG_GTEST_FOUND)
 
162
 
 
163
                set (BUILD_XORG_GTEST FALSE)
 
164
 
 
165
            endif (XORG_GTEST_FOUND)
 
166
 
 
167
        endif (BUILD_XORG_GTEST)
 
168
 
 
169
    else (GOOGLE_TEST_AND_MOCK_FOUND)
 
170
 
172
171
        set (COMPIZ_BUILD_TESTING OFF CACHE BOOL "" FORCE)
173
 
 
174
 
    else (NOT GMOCK_LIBRARY OR NOT GMOCK_MAIN_LIBRARY OR NOT GTEST_FOUND)
175
 
 
176
 
        include_directories (${GTEST_INCLUDE_DIRS})
177
 
 
178
 
    endif (NOT GMOCK_LIBRARY OR NOT GMOCK_MAIN_LIBRARY OR NOT GTEST_FOUND)
 
172
        set (BUILD_XORG_GTEST OFF CACHE BOOL "" FORCE)
 
173
 
 
174
    endif (GOOGLE_TEST_AND_MOCK_FOUND)
 
175
 
 
176
else (COMPIZ_BUILD_TESTING)
 
177
 
 
178
    set (BUILD_XORG_GTEST OFF CACHE BOOL "" FORCE)
179
179
 
180
180
endif (COMPIZ_BUILD_TESTING)
181
181