bf11e1340cf43afa1fd634f7f191d5f310ca9263
[WebKit.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 set(ENABLE_WEBINSPECTORUI OFF)
39
40 if (WIN32)
41     set(ENABLE_API_TESTS OFF)
42 else ()
43     set(ENABLE_API_TESTS ON)
44 endif ()
45
46 if (WTF_CPU_ARM OR WTF_CPU_MIPS)
47     SET_AND_EXPOSE_TO_BUILD(USE_CAPSTONE TRUE)
48 endif ()
49
50 # FIXME: JSCOnly on WIN32 seems to only work with fully static build
51 # https://bugs.webkit.org/show_bug.cgi?id=172862
52 if (NOT ENABLE_STATIC_JSC AND NOT WIN32)
53     set(JavaScriptCore_LIBRARY_TYPE SHARED)
54 endif ()
55
56 if (WIN32)
57     add_definitions(-DNOMINMAX)
58     add_definitions(-D_WINDOWS -DWINVER=0x601 -D_WIN32_WINNT=0x601)
59     add_definitions(-DUNICODE -D_UNICODE)
60
61     if (NOT WEBKIT_LIBRARIES_DIR)
62         if (DEFINED ENV{WEBKIT_LIBRARIES})
63             set(WEBKIT_LIBRARIES_DIR "$ENV{WEBKIT_LIBRARIES}")
64         else ()
65             set(WEBKIT_LIBRARIES_DIR "${CMAKE_SOURCE_DIR}/WebKitLibraries/win")
66         endif ()
67     endif ()
68
69     set(CMAKE_PREFIX_PATH ${WEBKIT_LIBRARIES_DIR})
70
71     if (WTF_CPU_X86_64)
72         set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS OFF)
73         set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS ON)
74
75         set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib64)
76         set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib64)
77         set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin64)
78     endif ()
79
80     set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}")
81     set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}")
82     set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
83     set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
84     set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
85     set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
86 endif ()
87
88 string(TOLOWER ${EVENT_LOOP_TYPE} LOWERCASE_EVENT_LOOP_TYPE)
89 if (LOWERCASE_EVENT_LOOP_TYPE STREQUAL "glib")
90     find_package(GLIB 2.36 REQUIRED COMPONENTS gio gobject)
91     SET_AND_EXPOSE_TO_BUILD(USE_GLIB 1)
92     SET_AND_EXPOSE_TO_BUILD(USE_GLIB_EVENT_LOOP 1)
93     SET_AND_EXPOSE_TO_BUILD(WTF_DEFAULT_EVENT_LOOP 0)
94 else ()
95     SET_AND_EXPOSE_TO_BUILD(USE_GENERIC_EVENT_LOOP 1)
96     SET_AND_EXPOSE_TO_BUILD(WTF_DEFAULT_EVENT_LOOP 0)
97 endif ()
98
99 find_package(ICU 60.2 REQUIRED COMPONENTS data i18n uc)
100 if (APPLE)
101     add_definitions(-DU_DISABLE_RENAMING=1)
102 endif ()