[GTK][CMake] Add support for building with Clang
[WebKit-https.git] / Tools / TestWebKitAPI / CMakeLists.txt
1 set(TESTWEBKITAPI_DIR "${TOOLS_DIR}/TestWebKitAPI")
2 set(TESTWEBKITAPI_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/TestWebKitAPI")
3
4 include_directories(${CMAKE_BINARY_DIR}
5     ${TESTWEBKITAPI_DIR}
6     ${TESTWEBKITAPI_DIR}
7     ${CMAKE_SOURCE_DIR}/Source
8     ${DERIVED_SOURCES_WEBCORE_DIR}
9     ${JAVASCRIPTCORE_DIR}
10     ${JAVASCRIPTCORE_DIR}/API
11     ${JAVASCRIPTCORE_DIR}/ForwardingHeaders
12     ${THIRDPARTY_DIR}/gtest/include
13     ${WEBCORE_DIR}/editing
14     ${WEBCORE_DIR}/platform
15     ${WEBCORE_DIR}/platform/graphics
16     ${WEBCORE_DIR}/platform/text
17     ${WEBCORE_DIR}/platform/network
18     ${WEBCORE_DIR}/platform/network/soup
19     ${WEBKIT2_DIR}/Platform/IPC
20     ${WEBKIT2_DIR}/Shared
21     ${WEBKIT2_DIR}/Shared/API/c
22     ${WEBKIT2_DIR}/Shared/Plugins
23     ${WEBKIT2_DIR}/UIProcess
24     ${WEBKIT2_DIR}/WebProcess/InjectedBundle
25     ${WEBKIT2_DIR}/WebProcess/InjectedBundle/API/c
26     ${WTF_DIR}
27 )
28
29 set(test_wtf_LIBRARIES
30     WTF
31     gtest
32 )
33
34 set(test_webcore_LIBRARIES
35     gtest
36     WTF
37     WebCore
38 )
39
40 set(test_webkit2_api_LIBRARIES
41     TestWebKitAPIBase
42     WTF
43     JavaScriptCore
44     WebKit2
45     gtest
46 )
47
48 set(TestWebKitAPI_LIBRARIES
49     WTF
50     WebKit2
51 )
52
53 WEBKIT_INCLUDE_CONFIG_FILES_IF_EXISTS()
54
55 add_library(TestWebKitAPIInjectedBundle SHARED
56     ${bundle_harness_SOURCES}
57     ${TESTWEBKITAPI_DIR}/InjectedBundleController.cpp
58     ${TESTWEBKITAPI_DIR}/InjectedBundleMain.cpp
59     ${TESTWEBKITAPI_DIR}/PlatformUtilities.cpp
60     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/CanHandleRequest_Bundle.cpp
61     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/DidAssociateFormControls_Bundle.cpp
62     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/DOMWindowExtensionBasic_Bundle.cpp
63     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/DOMWindowExtensionNoCache_Bundle.cpp
64     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/DocumentStartUserScriptAlertCrash_Bundle.cpp
65     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/GetInjectedBundleInitializationUserDataCallback_Bundle.cpp
66     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/HitTestResultNodeHandle_Bundle.cpp
67     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/InjectedBundleBasic_Bundle.cpp
68     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/InjectedBundleFrameHitTest_Bundle.cpp
69     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/InjectedBundleInitializationUserDataCallbackWins_Bundle.cpp
70     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/LoadCanceledNoServerRedirectCallback_Bundle.cpp
71     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/MouseMoveAfterCrash_Bundle.cpp
72     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/NewFirstVisuallyNonEmptyLayoutFails_Bundle.cpp
73     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/NewFirstVisuallyNonEmptyLayoutForImages_Bundle.cpp
74     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/NewFirstVisuallyNonEmptyLayoutFrames_Bundle.cpp
75     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/NewFirstVisuallyNonEmptyLayout_Bundle.cpp
76     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/ParentFrame_Bundle.cpp
77     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/ResponsivenessTimerDoesntFireEarly_Bundle.cpp
78     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/ShouldGoToBackForwardListItem_Bundle.cpp
79     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/UserMessage_Bundle.cpp
80     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/WillLoad_Bundle.cpp
81     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/WillSendSubmitEvent_Bundle.cpp
82 )
83
84 target_link_libraries(TestWebKitAPIInjectedBundle ${TestWebKitAPI_LIBRARIES})
85 add_dependencies(TestWebKitAPIInjectedBundle ${ForwardingHeadersForTestWebKitAPI_NAME})
86
87 get_property(TestWebKitAPIInjectedBundle_PATH TARGET TestWebKitAPIInjectedBundle PROPERTY LOCATION)
88
89 add_definitions(-DGTEST_LINKED_AS_SHARED_LIBRARY=1 -DGTEST_HAS_RTTI=0
90     -DTEST_WEBKIT2_RESOURCES_DIR=\"${TESTWEBKITAPI_DIR}/Tests/WebKit2\"
91     -DTEST_INJECTED_BUNDLE_PATH=\"${TestWebKitAPIInjectedBundle_PATH}\"
92 )
93
94 # FIXME: This works around compatibility problems in the old version of the third-pary
95 # googletest source code checkout. It should be removed once we upgrade to a newer version.
96 if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
97     add_definitions(-DGTEST_HAS_TR1_TUPLE=0)
98 endif ()
99
100 add_executable(TestWTF
101     ${test_main_SOURCES}
102     ${TESTWEBKITAPI_DIR}/TestsController.cpp
103     ${TESTWEBKITAPI_DIR}/Tests/WTF/AtomicString.cpp
104     ${TESTWEBKITAPI_DIR}/Tests/WTF/CString.cpp
105     ${TESTWEBKITAPI_DIR}/Tests/WTF/CheckedArithmeticOperations.cpp
106     ${TESTWEBKITAPI_DIR}/Tests/WTF/Functional.cpp
107     ${TESTWEBKITAPI_DIR}/Tests/WTF/HashMap.cpp
108     ${TESTWEBKITAPI_DIR}/Tests/WTF/IntegerToStringConversion.cpp
109     ${TESTWEBKITAPI_DIR}/Tests/WTF/ListHashSet.cpp
110     ${TESTWEBKITAPI_DIR}/Tests/WTF/MD5.cpp
111     ${TESTWEBKITAPI_DIR}/Tests/WTF/MathExtras.cpp
112     ${TESTWEBKITAPI_DIR}/Tests/WTF/MetaAllocator.cpp
113     ${TESTWEBKITAPI_DIR}/Tests/WTF/RedBlackTree.cpp
114     ${TESTWEBKITAPI_DIR}/Tests/WTF/Ref.cpp
115     ${TESTWEBKITAPI_DIR}/Tests/WTF/RefPtr.cpp
116     ${TESTWEBKITAPI_DIR}/Tests/WTF/SHA1.cpp
117     ${TESTWEBKITAPI_DIR}/Tests/WTF/SaturatedArithmeticOperations.cpp
118     ${TESTWEBKITAPI_DIR}/Tests/WTF/StringBuilder.cpp
119     ${TESTWEBKITAPI_DIR}/Tests/WTF/StringHasher.cpp
120     ${TESTWEBKITAPI_DIR}/Tests/WTF/StringImpl.cpp
121     ${TESTWEBKITAPI_DIR}/Tests/WTF/StringOperators.cpp
122     ${TESTWEBKITAPI_DIR}/Tests/WTF/TemporaryChange.cpp
123     ${TESTWEBKITAPI_DIR}/Tests/WTF/Vector.cpp
124     ${TESTWEBKITAPI_DIR}/Tests/WTF/WTFString.cpp
125 )
126
127 target_link_libraries(TestWTF ${test_wtf_LIBRARIES})
128 add_dependencies(TestWTF ${ForwardingHeadersForTestWebKitAPI_NAME} ${ForwardingNetworkHeadersForTestWebKitAPI_NAME})
129 add_test(TestWTF ${TESTWEBKITAPI_RUNTIME_OUTPUT_DIRECTORY}/WTF/TestWTF)
130 set_tests_properties(TestWTF PROPERTIES TIMEOUT 60)
131     set_target_properties(TestWTF PROPERTIES
132         RUNTIME_OUTPUT_DIRECTORY ${TESTWEBKITAPI_RUNTIME_OUTPUT_DIRECTORY}/WTF
133     )
134
135 foreach (testName ${test_webcore_BINARIES})
136     add_executable(${testName} ${test_main_SOURCES} ${TESTWEBKITAPI_DIR}/TestsController.cpp ${TESTWEBKITAPI_DIR}/Tests/WebCore/${testName}.cpp)
137     add_test(${testName} ${TESTWEBKITAPI_RUNTIME_OUTPUT_DIRECTORY}/WebCore/${testName})
138     set_tests_properties(${testName} PROPERTIES TIMEOUT 60)
139     target_link_libraries(${testName} ${test_webcore_LIBRARIES})
140     set_target_properties(${testName} PROPERTIES
141         RUNTIME_OUTPUT_DIRECTORY ${TESTWEBKITAPI_RUNTIME_OUTPUT_DIRECTORY}/WebCore
142     )
143 endforeach ()
144
145 add_library(TestWebKitAPIBase
146     ${test_main_SOURCES}
147     ${webkit2_api_harness_SOURCES}
148     ${TESTWEBKITAPI_DIR}/JavaScriptTest.cpp
149     ${TESTWEBKITAPI_DIR}/PlatformUtilities.cpp
150     ${TESTWEBKITAPI_DIR}/TestsController.cpp
151 )
152
153 add_dependencies(TestWebKitAPIBase WebKit2 ${ForwardingHeadersForTestWebKitAPI_NAME} ${ForwardingNetworkHeadersForTestWebKitAPI_NAME})
154
155 foreach (testName ${test_webkit2_api_BINARIES})
156     get_filename_component(testBaseName ${testName} NAME)
157     add_executable(${testBaseName} ${TESTWEBKITAPI_DIR}/Tests/WebKit2/${testName}.cpp)
158     add_test(${testBaseName} ${TESTWEBKITAPI_RUNTIME_OUTPUT_DIRECTORY}/WebKit2/${testBaseName})
159     set_tests_properties(${testBaseName} PROPERTIES TIMEOUT 60)
160     target_link_libraries(${testBaseName} ${test_webkit2_api_LIBRARIES})
161     set_target_properties(${testBaseName} PROPERTIES
162         RUNTIME_OUTPUT_DIRECTORY ${TESTWEBKITAPI_RUNTIME_OUTPUT_DIRECTORY}/WebKit2
163     )
164 endforeach ()
165
166 # We don't run tests that are expected to fail. We could use the WILL_FAIL
167 # property, but it reports failure when the test crashes or timeouts and would
168 # make the bot red.
169
170 foreach (testName ${test_webkit2_api_fail_BINARIES})
171     add_executable(${testName} ${TESTWEBKITAPI_DIR}/Tests/WebKit2/${testName}.cpp)
172     target_link_libraries(${testName} ${test_webkit2_api_LIBRARIES})
173     set_target_properties(${testBaseName} PROPERTIES
174         RUNTIME_OUTPUT_DIRECTORY ${TESTWEBKITAPI_RUNTIME_OUTPUT_DIRECTORY}/WebKit2
175     )
176 endforeach ()