V8 CMakeList.txt

On working on V8, I started appreciating quick and accurate navigation features from IDE, namely CLion. CLion expects the project uses CMakeList.txt to define the project structure, but V8 uses ninja, so I have to compose CMakeList.txt myself.

I am listing what I used here. It can’t build the project successfully due to some linking errors. However, I only need the navigation feature from CLion, so it’s enough for me. The two features I used the most are “Find definition” and “Find usage”; both of them work semantically.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
cmake_minimum_required(VERSION 3.7)
project(v8)

set(CMAKE_CXX_STANDARD 11)
include_directories(.)
include_directories(./include)

add_definitions(-DDEBUG)
add_definitions(-DVERIFY_HEAP)
add_definitions(-DV8_CSA_WRITE_BARRIER)
add_definitions(-DV8_TARGET_ARCH_X64)
#add_definitions(-DV8_TARGET_ARCH_IA32)
#add_definitions(-DV8_TARGET_ARCH_MIPS)
#add_definitions(-DV8_TARGET_ARCH_MIPS64)
#add_definitions(-DV8_TARGET_ARCH_PPC)
#add_definitions(-DV8_TARGET_ARCH_S390)
#add_definitions(-DV8_TARGET_ARCH_ARM)
#add_definitions(-DV8_TARGET_ARCH_ARM64)

file(GLOB_RECURSE SOURCE_FILES src/*.cc src/*.h)

list(REMOVE_ITEM SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/builtins/builtins-intl-gen.cc)
list(REMOVE_ITEM SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/builtins/builtins-intl.cc)
list(REMOVE_ITEM SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/builtins/builtins-intl.h)
list(REMOVE_ITEM SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/char-predicates.cc)
list(REMOVE_ITEM SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/intl.cc)
list(REMOVE_ITEM SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/intl.h)
list(REMOVE_ITEM SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/objects/intl-objects.cc)
list(REMOVE_ITEM SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/objects/intl-objects.h)
list(REMOVE_ITEM SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/runtime/runtime-intl.cc)

list(REMOVE_ITEM SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/d8-windows.cc)
list(REMOVE_ITEM SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/base/win32-headers.h)

list(REMOVE_ITEM SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/setup-isolate-deserialize.cc)
list(REMOVE_ITEM SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/snapshot/natives-external.cc)
list(REMOVE_ITEM SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/snapshot/snapshot-external.cc)

list(REMOVE_ITEM SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/base/debug/stack_trace_win.cc)
list(REMOVE_ITEM SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/base/debug/stack_trace_posix.cc)
list(REMOVE_ITEM SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/base/debug/stack_trace_android.cc)
list(REMOVE_ITEM SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/base/debug/stack_trace_fushsia.cc)

list(FILTER SOURCE_FILES EXCLUDE REGEX ".*platform-aix.*")
list(FILTER SOURCE_FILES EXCLUDE REGEX ".*platform-cygwin.*")
list(FILTER SOURCE_FILES EXCLUDE REGEX ".*platform-freebsd.*")
list(FILTER SOURCE_FILES EXCLUDE REGEX ".*platform-fuchsia.*")
list(FILTER SOURCE_FILES EXCLUDE REGEX ".*platform-macos.*")
list(FILTER SOURCE_FILES EXCLUDE REGEX ".*platform-openbsd.*")
list(FILTER SOURCE_FILES EXCLUDE REGEX ".*platform-posix.*")
list(FILTER SOURCE_FILES EXCLUDE REGEX ".*platform-posix-time.*")
list(FILTER SOURCE_FILES EXCLUDE REGEX ".*platform-qnx.*")
list(FILTER SOURCE_FILES EXCLUDE REGEX ".*platform-solaris.*")
list(FILTER SOURCE_FILES EXCLUDE REGEX ".*platform-win32.*")

list(FILTER SOURCE_FILES EXCLUDE REGEX ".*arm64\\.[h|cc]*")
list(FILTER SOURCE_FILES EXCLUDE REGEX ".*arm\\.[h|cc]")
list(FILTER SOURCE_FILES EXCLUDE REGEX ".*ppc.*")
list(FILTER SOURCE_FILES EXCLUDE REGEX ".*390.*")
list(FILTER SOURCE_FILES EXCLUDE REGEX ".*mips.*")
list(FILTER SOURCE_FILES EXCLUDE REGEX ".*mips64.*")
list(FILTER SOURCE_FILES EXCLUDE REGEX ".*ia32.*")
#list(FILTER SOURCE_FILES EXCLUDE REGEX ".*x64.*")

list(FILTER SOURCE_FILES EXCLUDE REGEX ".*inspector.*")

add_executable(v8 ${SOURCE_FILES})