[duktape] Fix exported config, cleanup (#37821)

This commit is contained in:
Kai Pastor 2024-03-30 01:24:58 +01:00 committed by GitHub
parent dc5bc7995d
commit d8d4dfa294
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 68 additions and 70 deletions

View File

@ -1,24 +1,19 @@
cmake_minimum_required(VERSION 3.13)
set(duktape_MAJOR_VERSION 2)
set(duktape_MINOR_VERSION 7)
set(duktape_PATCH_VERSION 0)
set(duktape_VERSION ${duktape_MAJOR_VERSION}.${duktape_MINOR_VERSION}.${duktape_PATCH_VERSION})
option(CMAKE_VERBOSE_MAKEFILE "Create verbose makefile" OFF)
option(BUILD_SHARED_LIBS "Create duktape as a shared library" ON)
project(duktape VERSION ${duktape_VERSION})
project(duktape VERSION ${VERSION})
file(GLOB_RECURSE DUKTAPE_SOURCES "${CMAKE_CURRENT_LIST_DIR}/src/*.c")
file(GLOB_RECURSE DUKTAPE_HEADERS "${CMAKE_CURRENT_LIST_DIR}/src/*.h")
add_library(duktape ${DUKTAPE_SOURCES} ${DUKTAPE_HEADERS})
target_include_directories(duktape PRIVATE "${CMAKE_CURRENT_LIST_DIR}/src")
target_include_directories(duktape PUBLIC "$<INSTALL_INTERFACE:include>")
set_target_properties(duktape PROPERTIES PUBLIC_HEADER "${DUKTAPE_HEADERS}")
set_target_properties(duktape PROPERTIES VERSION ${duktape_VERSION})
set_target_properties(duktape PROPERTIES SOVERSION ${duktape_MAJOR_VERSION})
set_target_properties(duktape PROPERTIES SOVERSION ${duktape_VERSION_MAJOR})
if (BUILD_SHARED_LIBS)
target_compile_definitions(duktape PRIVATE -DDUK_F_DLL_BUILD)
@ -34,22 +29,28 @@ install(TARGETS duktape
)
install(EXPORT duktapeTargets
FILE duktapeTargets.cmake
NAMESPACE duktape::
DESTINATION "share/duktape"
FILE unofficial-duktape-config.cmake
NAMESPACE unofficial::duktape::
DESTINATION "share/unofficial-duktape"
)
export(PACKAGE duktape)
include(CMakePackageConfigHelpers)
write_basic_package_version_file("${PROJECT_BINARY_DIR}/duktapeConfigVersion.cmake"
write_basic_package_version_file("${PROJECT_BINARY_DIR}/unofficial-duktape-config-version.cmake"
COMPATIBILITY SameMajorVersion
)
configure_file(duktapeConfig.cmake.in "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/duktapeConfig.cmake" @ONLY)
install(FILES
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/duktapeConfig.cmake"
"${PROJECT_BINARY_DIR}/duktapeConfigVersion.cmake"
DESTINATION "share/duktape"
"${PROJECT_BINARY_DIR}/unofficial-duktape-config-version.cmake"
DESTINATION "share/unofficial-duktape"
)
set(prefix "")
set(LIBDIR "/lib")
set(VERSION "${duktape_VERSION}")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/duktape.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/duktape.pc" @ONLY)
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/duktape.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
)

View File

@ -0,0 +1,32 @@
# - 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
#
include(FindPackageHandleStandardArgs)
include(SelectLibraryConfigurations)
find_path(DUKTAPE_INCLUDE_DIR duktape.h PATHS "${CMAKE_CURRENT_LIST_DIR}/../../include" NO_DEFAULT_PATH REQUIRED)
find_library(DUKTAPE_LIBRARY_RELEASE NAMES duktape PATHS "${CMAKE_CURRENT_LIST_DIR}/../../lib" NO_DEFAULT_PATH REQUIRED)
find_library(DUKTAPE_LIBRARY_DEBUG NAMES duktape PATHS "${CMAKE_CURRENT_LIST_DIR}/../../debug/lib" NO_DEFAULT_PATH)
select_library_configurations(DUKTAPE)
find_package_handle_standard_args(duktape
REQUIRED_VARS DUKTAPE_LIBRARY DUKTAPE_INCLUDE_DIR)
if(DUKTAPE_FOUND)
set(DUKTAPE_INCLUDE_DIRS "${DUKTAPE_INCLUDE_DIR}")
set(DUKTAPE_LIBRARIES "${DUKTAPE_LIBRARY}")
set(DUKTAPE_DEFINITIONS "")
endif ()
mark_as_advanced(
DUKTAPE_INCLUDE_DIR
DUKTAPE_LIBRARY_RELEASE
DUKTAPE_LIBRARY_DEBUG
)

View File

@ -1,33 +0,0 @@
# - 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
)

View File

@ -11,31 +11,27 @@ vcpkg_extract_source_archive(
)
file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/duktapeConfig.cmake.in" DESTINATION "${SOURCE_PATH}")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
set(DUK_CONFIG_H_PATH "${SOURCE_PATH}/src/duk_config.h")
file(READ "${DUK_CONFIG_H_PATH}" CONTENT)
string(REPLACE "#undef DUK_F_DLL_BUILD" "#define DUK_F_DLL_BUILD" CONTENT "${CONTENT}")
file(WRITE "${DUK_CONFIG_H_PATH}" "${CONTENT}")
if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic")
vcpkg_replace_string("${SOURCE_PATH}/src/duk_config.h" "#undef DUK_F_DLL_BUILD" "#define DUK_F_DLL_BUILD")
else()
set(DUK_CONFIG_H_PATH "${SOURCE_PATH}/src/duk_config.h")
file(READ "${DUK_CONFIG_H_PATH}" CONTENT)
string(REPLACE "#define DUK_F_DLL_BUILD" "#undef DUK_F_DLL_BUILD" CONTENT "${CONTENT}")
file(WRITE "${DUK_CONFIG_H_PATH}" "${CONTENT}")
vcpkg_replace_string("${SOURCE_PATH}/src/duk_config.h" "#define DUK_F_DLL_BUILD" "#undef DUK_F_DLL_BUILD")
endif()
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-DVERSION=${VERSION}
)
vcpkg_cmake_install()
vcpkg_copy_pdbs()
vcpkg_fixup_pkgconfig()
vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-duktape)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
vcpkg_cmake_config_fixup()
vcpkg_copy_pdbs()
# Legacy package based on find commands, not on exported config.
file(COPY "${CURRENT_PORT_DIR}/duktapeConfig.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
file(INSTALL "${SOURCE_PATH}/LICENSE.txt" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE.txt")

View File

@ -1,5 +0,0 @@
find_package(duktape CONFIG REQUIRED)
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${DUKTAPE_INCLUDE_DIRS})
target_link_libraries(main ${DUKTAPE_LIBRARY})

View File

@ -1,8 +1,10 @@
{
"name": "duktape",
"version": "2.7.0",
"port-version": 1,
"description": "Embeddable Javascript engine with a focus on portability and compact footprint.",
"homepage": "https://github.com/svaarala/duktape",
"license": "MIT",
"dependencies": [
{
"name": "vcpkg-cmake",

View File

@ -2354,7 +2354,7 @@
},
"duktape": {
"baseline": "2.7.0",
"port-version": 0
"port-version": 1
},
"dumb": {
"baseline": "2.0.3",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "7d6b443cbf02c4f5ceaffc02d83335a7aa1fc8be",
"version": "2.7.0",
"port-version": 1
},
{
"git-tree": "dddb2510d64d70d7c0cb632039123a1721857e72",
"version": "2.7.0",