|
| 1 | +# Based on https://raw.githubusercontent.com/nicehash/cpp-ethereum/master/cmake/Findv8.cmake |
| 2 | +# |
| 3 | +# Find v8 |
| 4 | +# |
| 5 | +# Find the v8 includes and library |
| 6 | +# |
| 7 | +# if you nee to add a custom library search path, do it via via CMAKE_PREFIX_PATH |
| 8 | +# |
| 9 | +# This module defines |
| 10 | +# V8_INCLUDE_DIRS, where to find header, etc. |
| 11 | +# V8_LIBRARIES, the libraries needed to use v8. |
| 12 | +# V8_FOUND, If false, do not try to use v8. |
| 13 | + |
| 14 | +# only look in default directories |
| 15 | +find_path(V8_INCLUDE_DIR NAMES v8.h PATHS /usr/include/v8 DOC "v8 include dir") |
| 16 | + |
| 17 | +find_library(V8_LIBRARY NAMES v8 PATHS /usr/lib DOC "v8 library") |
| 18 | + |
| 19 | +set(V8_INCLUDE_DIRS ${V8_INCLUDE_DIR}) |
| 20 | +set(V8_LIBRARIES ${V8_LIBRARY}) |
| 21 | + |
| 22 | +# debug library on windows |
| 23 | +# same naming convention as in qt (appending debug library with d) |
| 24 | +# boost is using the same "hack" as us with "optimized" and "debug" |
| 25 | +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") |
| 26 | + find_library(V8_LIBRARY NAMES v8_base DOC "v8 base library") |
| 27 | + |
| 28 | + find_library( |
| 29 | + V8_NO_SNAPSHOT_LIBRARY |
| 30 | + NAMES v8_nosnapshot |
| 31 | + DOC "v8 nosnapshot library" |
| 32 | + ) |
| 33 | + |
| 34 | + set(V8_LIBRARIES ${V8_LIBRARY} ${V8_NO_SNAPSHOT_LIBRARY}) |
| 35 | + |
| 36 | + find_library(V8_LIBRARY_DEBUG NAMES v8_based DOC "v8 base library") |
| 37 | + |
| 38 | + find_library( |
| 39 | + V8_NO_SNAPSHOT_LIBRARY_DEBUG |
| 40 | + NAMES v8_nosnapshotd |
| 41 | + DOC "v8 nosnapshot library" |
| 42 | + ) |
| 43 | + |
| 44 | + set(V8_LIBRARIES |
| 45 | + "ws2_32" |
| 46 | + "winmm" |
| 47 | + optimized |
| 48 | + ${V8_LIBRARIES} |
| 49 | + debug |
| 50 | + ${V8_LIBRARY_DEBUG} |
| 51 | + ${V8_NO_SNAPSHOT_LIBRARY_DEBUG} |
| 52 | + ) |
| 53 | +endif() |
| 54 | + |
| 55 | +# handle the QUIETLY and REQUIRED arguments and set V8_FOUND to TRUE |
| 56 | +# if all listed variables are TRUE, hide their existence from configuration view |
| 57 | +include(FindPackageHandleStandardArgs) |
| 58 | +find_package_handle_standard_args(V8 DEFAULT_MSG V8_INCLUDE_DIR V8_LIBRARY) |
| 59 | +mark_as_advanced(V8_INCLUDE_DIR V8_LIBRARY) |
| 60 | + |
| 61 | +if(V8_FOUND) |
| 62 | + if(NOT TARGET V8::V8) |
| 63 | + add_library(V8::V8 SHARED IMPORTED) |
| 64 | + |
| 65 | + set_target_properties( |
| 66 | + V8::V8 |
| 67 | + PROPERTIES |
| 68 | + INTERFACE_INCLUDE_DIRECTORIES "${V8_INCLUDE_DIR}" |
| 69 | + IMPORTED_LOCATION "${V8_LIBRARY}" |
| 70 | + ) |
| 71 | + endif() |
| 72 | +endif() |
0 commit comments