[Win] Remove -DUCHAR_TYPE=wchar_t stopgap and learn to live with char16_t.
[WebKit-https.git] / Source / cmake / OptionsJSCOnly.cmake
1 find_package(Threads REQUIRED)
2
3 if (MSVC)
4     include(OptionsMSVC)
5 endif ()
6
7 add_definitions(-DBUILDING_JSCONLY__)
8
9 set(PROJECT_VERSION_MAJOR 1)
10 set(PROJECT_VERSION_MINOR 0)
11 set(PROJECT_VERSION_MICRO 0)
12 set(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_MICRO})
13
14 WEBKIT_OPTION_BEGIN()
15 WEBKIT_OPTION_DEFINE(ENABLE_STATIC_JSC "Whether to build JavaScriptCore as a static library." PUBLIC OFF)
16 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_REMOTE_INSPECTOR PRIVATE OFF)
17 if (WIN32)
18     # FIXME: Enable FTL on Windows. https://bugs.webkit.org/show_bug.cgi?id=145366
19     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_FTL_JIT PRIVATE OFF)
20     # FIXME: Port bmalloc to Windows. https://bugs.webkit.org/show_bug.cgi?id=143310
21     WEBKIT_OPTION_DEFAULT_PORT_VALUE(USE_SYSTEM_MALLOC PRIVATE ON)
22 endif ()
23
24 WEBKIT_OPTION_END()
25
26 set(ALL_EVENT_LOOP_TYPES
27     GLib
28     Generic
29 )
30
31 set(DEFAULT_EVENT_LOOP_TYPE "Generic")
32
33 set(EVENT_LOOP_TYPE ${DEFAULT_EVENT_LOOP_TYPE} CACHE STRING "Implementation of event loop to be used in JavaScriptCore (one of ${ALL_EVENT_LOOP_TYPES})")
34
35 set(ENABLE_WEBCORE OFF)
36 set(ENABLE_WEBKIT_LEGACY OFF)
37 set(ENABLE_WEBKIT OFF)
38
39 if (WIN32)
40     set(ENABLE_API_TESTS OFF)
41 else ()
42     set(ENABLE_API_TESTS ON)
43 endif ()
44
45 if (WTF_CPU_ARM OR WTF_CPU_MIPS)
46     SET_AND_EXPOSE_TO_BUILD(USE_CAPSTONE TRUE)
47 endif ()
48
49 # FIXME: JSCOnly on WIN32 seems to only work with fully static build
50 # https://bugs.webkit.org/show_bug.cgi?id=172862
51 if (NOT ENABLE_STATIC_JSC AND NOT WIN32)
52     set(JavaScriptCore_LIBRARY_TYPE SHARED)
53 endif ()
54
55 if (WIN32)
56     add_definitions(-DNOMINMAX)
57     add_definitions(-D_WINDOWS -DWINVER=0x601 -D_WIN32_WINNT=0x601)
58     add_definitions(-DUNICODE -D_UNICODE)
59
60     if (NOT WEBKIT_LIBRARIES_DIR)
61         if (DEFINED ENV{WEBKIT_LIBRARIES})
62             set(WEBKIT_LIBRARIES_DIR "$ENV{WEBKIT_LIBRARIES}")
63         else ()
64             set(WEBKIT_LIBRARIES_DIR "${CMAKE_SOURCE_DIR}/WebKitLibraries/win")
65         endif ()
66     endif ()
67
68     set(CMAKE_PREFIX_PATH ${WEBKIT_LIBRARIES_DIR})
69
70     if (WTF_CPU_X86_64)
71         set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS OFF)
72         set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS ON)
73
74         set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib64)
75         set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib64)
76         set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin64)
77     endif ()
78
79     set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}")
80     set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}")
81     set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
82     set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
83     set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
84     set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
85 endif ()
86
87 string(TOLOWER ${EVENT_LOOP_TYPE} LOWERCASE_EVENT_LOOP_TYPE)
88 if (LOWERCASE_EVENT_LOOP_TYPE STREQUAL "glib")
89     find_package(GLIB 2.36 REQUIRED COMPONENTS gio gobject)
90     SET_AND_EXPOSE_TO_BUILD(USE_GLIB 1)
91     SET_AND_EXPOSE_TO_BUILD(USE_GLIB_EVENT_LOOP 1)
92     SET_AND_EXPOSE_TO_BUILD(WTF_DEFAULT_EVENT_LOOP 0)
93 else ()
94     SET_AND_EXPOSE_TO_BUILD(USE_GENERIC_EVENT_LOOP 1)
95     SET_AND_EXPOSE_TO_BUILD(WTF_DEFAULT_EVENT_LOOP 0)
96 endif ()
97
98 if (NOT APPLE)
99     find_package(ICU REQUIRED)
100 else ()
101     add_definitions(-DU_DISABLE_RENAMING=1 -DU_SHOW_CPLUSPLUS_API=0)
102     set(ICU_LIBRARIES libicucore.dylib)
103 endif ()