From 465990716b0c0c6c9ad569c80caac7b3a6df36c8 Mon Sep 17 00:00:00 2001 From: NancyLi1013 <46708020+NancyLi1013@users.noreply.github.com> Date: Sun, 7 Jul 2019 00:25:09 -0700 Subject: [PATCH] [duktape] Fix package not found by find_package. (#7170) --- ports/duktape/CONTROL | 2 +- ports/duktape/duktapeConfig.cmake | 33 +++++++++++++++++++++++++++++++ ports/duktape/portfile.cmake | 2 ++ ports/duktape/usage | 5 +++++ 4 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 ports/duktape/duktapeConfig.cmake create mode 100644 ports/duktape/usage diff --git a/ports/duktape/CONTROL b/ports/duktape/CONTROL index 0070253984..5f212d705a 100644 --- a/ports/duktape/CONTROL +++ b/ports/duktape/CONTROL @@ -1,5 +1,5 @@ Source: duktape -Version: 2.3.0 +Version: 2.3.0-1 Homepage: https://github.com/svaarala/duktape Description: Embeddable Javascript engine with a focus on portability and compact footprint. Build-Depends: diff --git a/ports/duktape/duktapeConfig.cmake b/ports/duktape/duktapeConfig.cmake new file mode 100644 index 0000000000..56d7798fd4 --- /dev/null +++ b/ports/duktape/duktapeConfig.cmake @@ -0,0 +1,33 @@ +# - Try to find duktape +# Once done this will define +# +# DUKTAPE_FOUND - system has Duktape +# DUKTAPE_INCLUDE_DIRS - the Duktape include directory +# DUKTAPE_LIBRARIES - Link these to use DUKTAPE +# DUKTAPE_DEFINITIONS - Compiler switches required for using Duktape +# + +find_package(PkgConfig QUIET) +pkg_check_modules(PC_DUK QUIET duktape libduktape) + +find_path(DUKTAPE_INCLUDE_DIR duktape.h + HINTS ${PC_DUK_INCLUDEDIR} ${PC_DUK_INCLUDE_DIRS} + PATH_SUFFIXES duktape) + +find_library(DUKTAPE_LIBRARY + NAMES duktape libduktape + HINTS ${PC_DUK_LIBDIR} ${PC_DUK_LIBRARY_DIRS}) + +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Duktape + REQUIRED_VARS DUKTAPE_LIBRARY DUKTAPE_INCLUDE_DIR) + +if (DUKTAPE_FOUND) + set (DUKTAPE_LIBRARIES ${DUKTAPE_LIBRARY}) + set (DUKTAPE_INCLUDE_DIRS ${DUKTAPE_INCLUDE_DIR} ) +endif () + +MARK_AS_ADVANCED( + DUKTAPE_INCLUDE_DIR + DUKTAPE_LIBRARY +) \ No newline at end of file diff --git a/ports/duktape/portfile.cmake b/ports/duktape/portfile.cmake index ef1476a52d..e15ca137b5 100644 --- a/ports/duktape/portfile.cmake +++ b/ports/duktape/portfile.cmake @@ -13,6 +13,8 @@ vcpkg_from_github( ) file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH}) +file(COPY ${CMAKE_CURRENT_LIST_DIR}/duktapeConfig.cmake DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT}) +file(COPY ${CMAKE_CURRENT_LIST_DIR}/usage DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT}) if(CMAKE_HOST_WIN32) set(EXECUTABLE_SUFFIX ".exe") diff --git a/ports/duktape/usage b/ports/duktape/usage new file mode 100644 index 0000000000..5870cb2bb0 --- /dev/null +++ b/ports/duktape/usage @@ -0,0 +1,5 @@ +find_package(duktape CONFIG REQUIRED) + +include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${DUKTAPE_INCLUDE_DIRS}) + +target_link_libraries(main ${DUKTAPE_LIBRARY}) \ No newline at end of file