2020-11-12 01:50:36 +08:00
include ( CMakeFindDependencyMacro )
find_dependency ( ICU REQUIRED COMPONENTS in uc dt )
find_dependency ( ZLIB REQUIRED )
if ( UNIX )
2021-04-27 01:28:21 +08:00
find_package ( PkgConfig REQUIRED )
pkg_check_modules ( GLIB2 glib-2.0 gobject-2.0 gmodule-2.0 gio-2.0 IMPORTED_TARGET )
2020-11-12 01:50:36 +08:00
set ( V8_IMPORTED_LINK_INTERFACE_LIBRARIES
2021-04-27 01:28:21 +08:00
" I C U : : i n ; I C U : : u c ; I C U : : d t ; Z L I B : : Z L I B " )
2020-11-12 01:50:36 +08:00
elseif ( WIN32 )
set ( V8_IMPORTED_LINK_INTERFACE_LIBRARIES
2021-04-27 01:28:21 +08:00
" W i n m m ; D b g H e l p ; Z L I B : : Z L I B ; P k g C o n f i g : : G L I B 2 ; I C U : : i n ; I C U : : u c ; I C U : : d t " )
2020-11-12 01:50:36 +08:00
endif ( )
get_filename_component ( _IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH )
get_filename_component ( _IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH )
get_filename_component ( _IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH )
if ( _IMPORT_PREFIX STREQUAL "/" )
set ( _IMPORT_PREFIX "" )
endif ( )
include ( SelectLibraryConfigurations )
find_path ( V8_INCLUDE_DIR NAMES v8.h PATH_SUFFIXES include )
if ( EXISTS "${_IMPORT_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}v8_monolith${CMAKE_STATIC_LIBRARY_SUFFIX}" )
set ( V8_LIBRARY_RELEASE "${_IMPORT_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}v8_monolith${CMAKE_STATIC_LIBRARY_SUFFIX}" CACHE FILEPATH "Release version of the V8 library location" )
endif ( )
if ( EXISTS "${_IMPORT_PREFIX}/debug/lib/${CMAKE_STATIC_LIBRARY_PREFIX}v8_monolith${CMAKE_STATIC_LIBRARY_SUFFIX}" )
set ( V8_LIBRARY_DEBUG "${_IMPORT_PREFIX}/debug/lib/${CMAKE_STATIC_LIBRARY_PREFIX}v8_monolith${CMAKE_STATIC_LIBRARY_SUFFIX}" CACHE FILEPATH "Debug version of the V8 library location" )
endif ( )
select_library_configurations ( V8 )
mark_as_advanced ( V8_INCLUDE_DIR )
if ( V8_INCLUDE_DIR AND EXISTS "${V8_INCLUDE_DIR}/v8-version.h" )
file ( STRINGS "${V8_INCLUDE_DIR}/v8-version.h" V8_MAJOR_VERSION REGEX "^#define V8_MAJOR_VERSION [0-9]+.*$" )
string ( REGEX REPLACE "^#define V8_MAJOR_VERSION ([0-9]+).*$" "\\1" V8_MAJOR_VERSION "${V8_MAJOR_VERSION}" )
file ( STRINGS "${V8_INCLUDE_DIR}/v8-version.h" V8_MINOR_VERSION REGEX "^#define V8_MINOR_VERSION [0-9]+.*$" )
string ( REGEX REPLACE "^#define V8_MINOR_VERSION ([0-9]+).*$" "\\1" V8_MINOR_VERSION "${V8_MINOR_VERSION}" )
file ( STRINGS "${V8_INCLUDE_DIR}/v8-version.h" V8_BUILD_NUMBER REGEX "^#define V8_BUILD_NUMBER [0-9]+.*$" )
string ( REGEX REPLACE "^#define V8_BUILD_NUMBER ([0-9]+).*$" "\\1" V8_BUILD_NUMBER "${V8_BUILD_NUMBER}" )
file ( STRINGS "${V8_INCLUDE_DIR}/v8-version.h" V8_PATCH_LEVEL REGEX "^#define V8_PATCH_LEVEL [0-9]+.*$" )
string ( REGEX REPLACE "^#define V8_PATCH_LEVEL ([0-9]+).*$" "\\1" V8_PATCH_LEVEL "${V8_PATCH_LEVEL}" )
set ( V8_VERSION_STRING "${V8_MAJOR_VERSION}.${V8_MINOR_VERSION}.${V8_BUILD_NUMBER}.${V8_PATCH_LEVEL}" )
endif ( )
if ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set ( V8_COMPILE_DEFINITIONS "V8_COMPRESS_POINTERS;V8_31BIT_SMIS_ON_64BIT_ARCH" )
else ( )
set ( V8_COMPILE_DEFINITIONS " " )
endif ( )
mark_as_advanced ( V8_COMPILE_DEFINITIONS )
include ( FindPackageHandleStandardArgs )
FIND_PACKAGE_HANDLE_STANDARD_ARGS ( V8 REQUIRED_VARS V8_LIBRARY V8_INCLUDE_DIR V8_COMPILE_DEFINITIONS
V E R S I O N _ V A R V 8 _ V E R S I O N _ S T R I N G )
set ( V8_LIBRARIES ${ V8_LIBRARY } )
mark_as_advanced ( V8_LIBRARIES )
if ( NOT TARGET V8::V8 )
add_library ( V8::V8 STATIC IMPORTED )
set_target_properties ( V8::V8 PROPERTIES
I N T E R F A C E _ I N C L U D E _ D I R E C T O R I E S " $ { V 8 _ I N C L U D E _ D I R } "
I N T E R F A C E _ C O M P I L E _ D E F I N I T I O N S " $ { V 8 _ C O M P I L E _ D E F I N I T I O N S } " )
if ( MSVC )
set_target_properties ( V8::V8 PROPERTIES
I N T E R F A C E _ C O M P I L E _ O P T I O N S " / M T $ < $ < C O N F I G : D e b u g > : d > " )
endif ( )
if ( V8_LIBRARY_RELEASE )
set_property ( TARGET V8::V8 APPEND PROPERTY
I M P O R T E D _ C O N F I G U R A T I O N S R E L E A S E )
set_target_properties ( V8::V8 PROPERTIES
I M P O R T E D _ L O C A T I O N _ R E L E A S E " $ { V 8 _ L I B R A R Y _ R E L E A S E } "
I M P O R T E D _ L I N K _ I N T E R F A C E _ L I B R A R I E S _ R E L E A S E
" $ { V 8 _ I M P O R T E D _ L I N K _ I N T E R F A C E _ L I B R A R I E S } " )
endif ( )
if ( V8_LIBRARY_DEBUG )
set_property ( TARGET V8::V8 APPEND PROPERTY
I M P O R T E D _ C O N F I G U R A T I O N S D E B U G )
set_target_properties ( V8::V8 PROPERTIES
I M P O R T E D _ L O C A T I O N _ D E B U G " $ { V 8 _ L I B R A R Y _ D E B U G } "
I M P O R T E D _ L I N K _ I N T E R F A C E _ L I B R A R I E S _ D E B U G
" $ { V 8 _ I M P O R T E D _ L I N K _ I N T E R F A C E _ L I B R A R I E S } " )
endif ( )
if ( NOT V8_LIBRARY_RELEASE AND NOT V8_LIBRARY_DEBUG )
set_property ( TARGET V8::V8 APPEND PROPERTY
I M P O R T E D _ L O C A T I O N " $ { V 8 _ L I B R A R Y } "
I M P O R T E D _ L I N K _ I N T E R F A C E _ L I B R A R I E S
" $ { V 8 _ I M P O R T E D _ L I N K _ I N T E R F A C E _ L I B R A R I E S } " )
endif ( )
endif ( )