Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 34caf89a70
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 86 lines (68 sloc) 2.508 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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
#
# Checkout v8
# ===========

if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/v8/.svn")

    if( ${SVN_EXECUTABLE-NOTFOUND} )
        message(FATAL_ERROR "svn is necessary to checkout" )
    endif()

    set(V8_SVN_COMMAND
        ${Subversion_SVN_EXECUTABLE}
        co http://v8.googlecode.com/svn/tags/3.2.4
        ${CMAKE_CURRENT_SOURCE_DIR}/v8
    )
        
    message("Checking out v8 3.2.4: ${V8_SVN_COMMAND}")
    execute_process(
        COMMAND ${V8_SVN_COMMAND}
    )
    
endif()


# Prepare options for v8 scons build
# ==================================

if(NOT ${CMAKE_BUILD_TYPE} EQUAL "")
    string(TOLOWER ${CMAKE_BUILD_TYPE} v8mode)
else()
    set(v8mode "release")
endif()

if(${v8mode} STREQUAL "debug")
    if(WIN32)
        list(APPEND _V8_LIBS ${CMAKE_CURRENT_SOURCE_DIR}/v8/v8.lib)
        set(V8_DLL ${CMAKE_CURRENT_SOURCE_DIR}/v8/v8_g.dll)
    elseif(UNIX)
        list(APPEND _V8_LIBS -lv8)
        set(V8_DLL ${CMAKE_CURRENT_SOURCE_DIR}/v8/libv8.so)
    else()
        message(FATAL_ERROR "Not yet implemented: what is the output of v8 build under posix?")
    endif()
elseif(${v8mode} STREQUAL "release")
    if(WIN32)
        list(APPEND _V8_LIBS ${CMAKE_CURRENT_SOURCE_DIR}/v8/v8.lib)
        set(V8_DLL ${CMAKE_CURRENT_SOURCE_DIR}/v8/v8.dll)
    elseif(UNIX)
        list(APPEND _V8_LIBS -lv8)
        set(V8_DLL ${CMAKE_CURRENT_SOURCE_DIR}/v8/libv8.so)
    else()
        message(FATAL_ERROR "Not yet implemented: what is the output of v8 build under posix?")
    endif()
else()
    message(FATAL_ERROR "Illegal build mode for v8: ${v8mode}")
endif()

list(APPEND SCONS_ARGS mode=${v8mode} library=shared)

if(MSVC90)
    list(APPEND SCONS_ARGS env="PATH:%PATH%,INCLUDE:%INCLUDE%,LIB:%LIB%")
endif()

if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/BUILD_V8)
    file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/BUILD_V8 "Blaaa")
endif()

add_custom_command(
    OUTPUT ${V8_DLL}
    COMMAND ${Scons_EXECUTABLE} ${SCONS_ARGS} verbose=on
    DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/v8/ChangeLog
    #COMMENT "Building v8 using scons: ${Scons_EXECUTABLE} ${SCONS_ARGS} mode=${v8mode} verbose=on"
    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/v8
)

add_custom_target(v8 ALL DEPENDS ${V8_DLL})

set_target_properties(v8
        PROPERTIES FOLDER third_party
)

add_custom_command(TARGET v8 POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${V8_DLL} ${PROJECT_BINARY_DIR}/bin/)

set (V8_LIBS ${_V8_LIBS} CACHE INTERNAL "" FORCE)
set (V8_DIR ${CMAKE_CURRENT_SOURCE_DIR}/v8 CACHE INTERNAL "" FORCE)
Something went wrong with that request. Please try again.