7962e01b18895a80aefae7146ada265a1c3c3ed7
[WebKit.git] / Source / cmake / OptionsAppleWin.cmake
1 # The static runtime is required for AppleWin due to WebKitSystemInterface.lib
2 # being compiled with a static runtime.
3 set(MSVC_STATIC_RUNTIME ON)
4
5 if (DEFINED ENV{AppleApplicationSupportSDK})
6     file(TO_CMAKE_PATH "$ENV{AppleApplicationSupportSDK}/AppleInternal" WEBKIT_LIBRARIES_DIR)
7     set(WEBKIT_LIBRARIES_INCLUDE_DIR "${WEBKIT_LIBRARIES_DIR}/include")
8     include_directories(${WEBKIT_LIBRARIES_INCLUDE_DIR})
9     set(APPLE_BUILD 1)
10 endif ()
11
12 if (NOT WEBKIT_LIBRARIES_DIR)
13     if (DEFINED ENV{WEBKIT_LIBRARIES})
14         file(TO_CMAKE_PATH "$ENV{WEBKIT_LIBRARIES}" WEBKIT_LIBRARIES_DIR)
15     else ()
16         file(TO_CMAKE_PATH "${CMAKE_SOURCE_DIR}/WebKitLibraries/win" WEBKIT_LIBRARIES_DIR)
17     endif ()
18 endif ()
19
20 set(WTF_PLATFORM_APPLE_WIN ON)
21
22 include(OptionsWin)
23
24 set(ENABLE_WEBCORE ON)
25
26 SET_AND_EXPOSE_TO_BUILD(USE_CF ON)
27 SET_AND_EXPOSE_TO_BUILD(USE_CFURLCONNECTION ON)
28
29 set(SQLite3_NAMES SQLite3${DEBUG_SUFFIX})
30
31 find_package(ICU REQUIRED COMPONENTS data i18n uc)
32 find_package(LibXml2 REQUIRED)
33 find_package(LibXslt REQUIRED)
34 find_package(SQLite3 REQUIRED)
35 find_package(ZLIB REQUIRED)
36
37 # Libraries where find_package does not work
38 set(COREFOUNDATION_LIBRARY CoreFoundation${DEBUG_SUFFIX})
39
40 # Uncomment the following line to try the Direct2D backend.
41 # set(USE_DIRECT2D 1)
42
43 if (${USE_DIRECT2D})
44     SET_AND_EXPOSE_TO_BUILD(USE_DIRECT2D ON)
45 else ()
46     SET_AND_EXPOSE_TO_BUILD(USE_CA ON)
47     SET_AND_EXPOSE_TO_BUILD(USE_CG ON)
48
49     set(CMAKE_REQUIRED_INCLUDES ${WEBKIT_LIBRARIES_INCLUDE_DIR})
50     set(CMAKE_REQUIRED_LIBRARIES
51         "${WEBKIT_LIBRARIES_LINK_DIR}/CoreFoundation${DEBUG_SUFFIX}.lib"
52         "${WEBKIT_LIBRARIES_LINK_DIR}/AVFoundationCF${DEBUG_SUFFIX}.lib"
53         "${WEBKIT_LIBRARIES_LINK_DIR}/QuartzCore${DEBUG_SUFFIX}.lib"
54         "${WEBKIT_LIBRARIES_LINK_DIR}/libdispatch${DEBUG_SUFFIX}.lib"
55     )
56
57     WEBKIT_CHECK_HAVE_INCLUDE(HAVE_AVCF AVFoundationCF/AVCFBase.h)
58
59     if (HAVE_AVCF)
60          SET_AND_EXPOSE_TO_BUILD(USE_AVFOUNDATION ON)
61     endif ()
62
63     WEBKIT_CHECK_HAVE_SYMBOL(HAVE_AVCF_LEGIBLE_OUTPUT AVCFPlayerItemLegibleOutputSetCallbacks "TargetConditionals.h;dispatch/dispatch.h;AVFoundationCF/AVFoundationCF.h;AVFoundationCF/AVCFPlayerItemLegibleOutput.h")
64     WEBKIT_CHECK_HAVE_SYMBOL(HAVE_AVFOUNDATION_LOADER_DELEGATE AVCFAssetResourceLoaderSetCallbacks "TargetConditionals.h;dispatch/dispatch.h;AVFoundationCF/AVFoundationCF.h")
65     WEBKIT_CHECK_HAVE_SYMBOL(HAVE_AVCFURL_PLAYABLE_MIMETYPE AVCFURLAssetIsPlayableExtendedMIMEType "TargetConditionals.h;dispatch/dispatch.h;AVFoundationCF/AVFoundationCF.h")
66
67     # CMake cannot identify an enum through a symbol check so a source file is required
68     WEBKIT_CHECK_SOURCE_COMPILES(HAVE_AVCFPLAYERITEM_CALLBACK_VERSION_2 "
69     #include <AVFoundationCF/AVFoundationCF.h>
70     #include <AVFoundationCF/AVCFPlayerItemLegibleOutput.h>
71     #include <CoreFoundation/CoreFoundation.h>
72     #include <dispatch/dispatch.h>
73
74     int main() {
75         CFArrayRef types = CFArrayCreate(kCFAllocatorDefault, nullptr, 0, nullptr);
76         AVCFPlayerItemLegibleOutputRef legibleOutput = AVCFPlayerItemLegibleOutputCreateWithMediaSubtypesForNativeRepresentation(kCFAllocatorDefault, types);
77         AVCFPlayerItemLegibleOutputCallbacks callbackInfo;
78         callbackInfo.version = kAVCFPlayerItemLegibleOutput_CallbacksVersion_2;
79         dispatch_queue_t dispatchQueue = dispatch_queue_create(\"test\", DISPATCH_QUEUE_SERIAL);
80         AVCFPlayerItemLegibleOutputSetCallbacks(legibleOutput, &callbackInfo, dispatchQueue);
81     }")
82
83     if (HAVE_AVCF_LEGIBLE_OUTPUT)
84         SET_AND_EXPOSE_TO_BUILD(HAVE_AVFOUNDATION_MEDIA_SELECTION_GROUP ON)
85         SET_AND_EXPOSE_TO_BUILD(HAVE_AVFOUNDATION_LEGIBLE_OUTPUT_SUPPORT ON)
86         SET_AND_EXPOSE_TO_BUILD(HAVE_MEDIA_ACCESSIBILITY_FRAMEWORK ON)
87     endif ()
88
89     WEBKIT_CHECK_HAVE_SYMBOL(HAVE_CACFLAYER_SETCONTENTSSCALE CACFLayerSetContentsScale QuartzCore/CoreAnimationCF.h)
90 endif ()
91
92 # Warnings as errors (ignore narrowing conversions)
93 add_compile_options(/WX /Wv:18)
94
95 if (INTERNAL_BUILD)
96     set(WTF_SCRIPTS_DIR "${CMAKE_BINARY_DIR}/../include/private/WTF/Scripts")
97     set(JavaScriptCore_SCRIPTS_DIR "${CMAKE_BINARY_DIR}/../include/private/JavaScriptCore/Scripts")
98 endif ()