-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
57 lines (43 loc) · 1.51 KB
/
CMakeLists.txt
File metadata and controls
57 lines (43 loc) · 1.51 KB
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
cmake_minimum_required(VERSION 3.14)
project(gtest)
# V8 requires at least C++20
set(CMAKE_CXX_STANDARD 20)
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
enable_testing()
include_directories(${CMAKE_SOURCE_DIR}/../../vendor/v8/include/)
add_executable(
c_v8_tests
c_v8_tests.cc
)
target_link_libraries(
c_v8_tests
GTest::gtest_main
)
string(TOLOWER ${CMAKE_SYSTEM_NAME} system_name)
string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} system_arch)
set(vendor_arch "${system_arch}-${system_name}")
if(${system_name} STREQUAL "linux")
try_compile(is_glibc ${CMAKE_BINARY_DIR}/check_glibc ${CMAKE_SOURCE_DIR}/check_glibc.c)
if(NOT is_glibc)
# assume non-glibc is musl-libc
string(APPEND vendor_arch "-musl")
endif()
endif()
if(APPLE)
find_library(CoreFoundation CoreFoundation)
endif()
message(STATUS "Detected vendor architecture directory: ${vendor_arch}")
# TODO?: Detect and support ruby-arch builds?
target_link_libraries(c_v8_tests ${CMAKE_SOURCE_DIR}/../../vendor/v8/${vendor_arch}/libv8/obj/libv8_monolith.a)
# This has to be after the v8 monolith for some build setups.
target_link_libraries(c_v8_tests dl)
target_link_libraries(c_v8_tests $<$<PLATFORM_ID:Darwin>:${CoreFoundation}>)
include(GoogleTest)
gtest_discover_tests(c_v8_tests)