Skip to content

Commit

Permalink
Build with CMake (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
lostman authored and rossberg committed Jun 9, 2018
1 parent fbe8829 commit a056901
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
26 changes: 26 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
cmake_minimum_required(VERSION 3.9)
cmake_policy(SET CMP0048 NEW)
set(CMAKE_CXX_COMPILER "clang++")
set(CMAKE_C_COMPILER "clang")
project(wasm_c_api VERSION 0.0.1)

set(V8V8 ${CMAKE_SOURCE_DIR}/v8/v8)
set(V8_LIBS
-Wl,--start-group
${V8V8}/out.gn/x64.release/obj/libv8_base.a
${V8V8}/out.gn/x64.release/obj/libv8_libbase.a
${V8V8}/out.gn/x64.release/obj/libv8_external_snapshot.a
${V8V8}/out.gn/x64.release/obj/libv8_libplatform.a
${V8V8}/out.gn/x64.release/obj/libv8_libsampler.a
${V8V8}/out.gn/x64.release/obj/third_party/icu/libicuuc.a
${V8V8}/out.gn/x64.release/obj/third_party/icu/libicui18n.a
${V8V8}/out.gn/x64.release/obj/src/inspector/libinspector.a
-Wl,--end-group)

set(V8_INCLUDE
${CMAKE_SOURCE_DIR}/include
${V8V8}
${V8V8}/include)

add_subdirectory(src)
add_subdirectory(example)
11 changes: 11 additions & 0 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")

add_executable (hello hello.c)
target_include_directories(hello PRIVATE ${V8_INCLUDE})
target_link_libraries (hello ${V8_LIBS} wasm_v8 pthread)
configure_file(${V8V8}/out.gn/x64.release/natives_blob.bin
${CMAKE_CURRENT_BINARY_DIR}/natives_blob.bin
COPYONLY)
configure_file(${V8V8}/out.gn/x64.release/snapshot_blob.bin
${CMAKE_CURRENT_BINARY_DIR}/snapshot_blob.bin
COPYONLY)
5 changes: 5 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")

add_library(wasm_v8 STATIC wasm-v8-lowlevel.cc wasm-bin.cc wasm-v8.cc wasm-bin.hh wasm-v8-lowlevel.hh)
target_include_directories(wasm_v8 PRIVATE ${V8_INCLUDE} ${V8V8}/out.gn/x64.release/gen ${V8V8}/src)
target_link_libraries (wasm_v8 ${V8_LIBS})

0 comments on commit a056901

Please sign in to comment.