[CMake] Properly detect compiler flags, needed libs, and fallbacks for usage of 64...
[WebKit-https.git] / Source / cmake / OptionsJSCOnly.cmake
1 set(THREADS_PREFER_PTHREAD_FLAG ON)
2 find_package(Threads REQUIRED)
3
4 if (MSVC)
5     include(OptionsMSVC)
6 endif ()
7
8 add_definitions(-DBUILDING_JSCONLY__)
9
10 set(PROJECT_VERSION_MAJOR 1)
11 set(PROJECT_VERSION_MINOR 0)
12 set(PROJECT_VERSION_MICRO 0)
13 set(PROJECT_VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_MICRO})
14
15 WEBKIT_OPTION_BEGIN()
16 WEBKIT_OPTION_DEFINE(ENABLE_STATIC_JSC "Whether to build JavaScriptCore as a static library." PUBLIC OFF)
17 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_REMOTE_INSPECTOR PRIVATE OFF)
18 WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_INTL_PLURAL_RULES PRIVATE ON)
19 if (WIN32)
20     # FIXME: Enable FTL on Windows. https://bugs.webkit.org/show_bug.cgi?id=145366
21     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_FTL_JIT PRIVATE OFF)
22     # FIXME: Port bmalloc to Windows. https://bugs.webkit.org/show_bug.cgi?id=143310
23     WEBKIT_OPTION_DEFAULT_PORT_VALUE(USE_SYSTEM_MALLOC PRIVATE ON)
24 endif ()
25
26 WEBKIT_OPTION_END()
27
28 set(ALL_EVENT_LOOP_TYPES
29     GLib
30     Generic
31 )
32
33 set(DEFAULT_EVENT_LOOP_TYPE "Generic")
34
35 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})")
36
37 set(ENABLE_WEBCORE OFF)
38 set(ENABLE_WEBKIT_LEGACY OFF)
39 set(ENABLE_WEBKIT OFF)
40
41 if (WIN32)
42     set(ENABLE_API_TESTS OFF)
43 else ()
44     set(ENABLE_API_TESTS ON)
45 endif ()
46
47 if (WTF_CPU_ARM OR WTF_CPU_MIPS)
48     SET_AND_EXPOSE_TO_BUILD(USE_CAPSTONE TRUE)
49 endif ()
50
51 # FIXME: JSCOnly on WIN32 seems to only work with fully static build
52 # https://bugs.webkit.org/show_bug.cgi?id=172862
53 if (NOT ENABLE_STATIC_JSC AND NOT WIN32)
54     set(JavaScriptCore_LIBRARY_TYPE SHARED)
55 endif ()
56
57 if (WIN32)
58     add_definitions(-DNOMINMAX)
59     add_definitions(-D_WINDOWS -DWINVER=0x601 -D_WIN32_WINNT=0x601)
60     add_definitions(-DUNICODE -D_UNICODE)
61
62     if (NOT WEBKIT_LIBRARIES_DIR)
63         if (DEFINED ENV{WEBKIT_LIBRARIES})
64             set(WEBKIT_LIBRARIES_DIR "$ENV{WEBKIT_LIBRARIES}")
65         else ()
66             set(WEBKIT_LIBRARIES_DIR "${CMAKE_SOURCE_DIR}/WebKitLibraries/win")
67         endif ()
68     endif ()
69
70     set(CMAKE_PREFIX_PATH ${WEBKIT_LIBRARIES_DIR})
71
72     if (WTF_CPU_X86_64)
73         set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS OFF)
74         set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS ON)
75
76         set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib64)
77         set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
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 if (NOT APPLE)
100     find_package(ICU REQUIRED)
101 else ()
102     add_definitions(-DU_DISABLE_RENAMING=1 -DU_SHOW_CPLUSPLUS_API=0)
103     set(ICU_LIBRARIES libicucore.dylib)
104 endif ()