Skip to content

Commit

Permalink
[libredwg] Add new port (#30005)
Browse files Browse the repository at this point in the history
  • Loading branch information
msclock committed Mar 20, 2023
1 parent 66372e8 commit 4e57712
Show file tree
Hide file tree
Showing 8 changed files with 190 additions and 0 deletions.
17 changes: 17 additions & 0 deletions ports/libredwg/fix_arm64_build.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8906fed..e953b76 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,8 +11,11 @@ if(MSVC)
set(redwg libredwg)
# Disable some overly strict MSVC warnings.
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -wd4244 -wd4800 -wd4805 -wd4101 -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS")
-else()
+ else()
set(redwg redwg)
+ endif()
+if(MSVC AND CMAKE_SYSTEM_PROCESSOR STREQUAL "ARM64")
+ add_compile_options(/Gy)
endif()

if (EXISTS ".version")
27 changes: 27 additions & 0 deletions ports/libredwg/fix_dependency.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8263f23..8906fed 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -201,7 +201,8 @@ target_include_directories(${redwg} PRIVATE
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
target_include_directories(${redwg} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)
-
+find_path(JSMN_INCLUDE_DIRS "jsmn.h")
+target_include_directories(${redwg} PRIVATE ${JSMN_INCLUDE_DIRS})
link_libraries(${redwg} ${LIBS} ${CMAKE_THREAD_LIBS_INIT})

if(NOT LIBREDWG_LIBONLY)
diff --git a/src/in_json.c b/src/in_json.c
index d66f1ab..724505b 100644
--- a/src/in_json.c
+++ b/src/in_json.c
@@ -51,7 +51,7 @@ static unsigned int loglevel;
// In strict mode an object or array can't become a key
// In strict mode primitives are: numbers and booleans
#undef JSMN_STRICT
-#include "../jsmn/jsmn.h"
+#include "jsmn.h"

typedef struct jsmntokens
{
51 changes: 51 additions & 0 deletions ports/libredwg/fix_install.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f0e04be..8263f23 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -196,10 +196,11 @@ if (BUILD_SHARED_LIBS)
target_compile_definitions(${redwg} PUBLIC DLL_EXPORT;ENABLE_SHARED)
endif()
target_include_directories(${redwg} PRIVATE
- ${CMAKE_CURRENT_SOURCE_DIR}/src
- ${CMAKE_CURRENT_BINARY_DIR}/src)
+ PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/src>
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
target_include_directories(${redwg} PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}/include)
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>)

link_libraries(${redwg} ${LIBS} ${CMAKE_THREAD_LIBS_INIT})

@@ -309,7 +310,7 @@ add_custom_target(
COMMAND etags --language=c++ *.c *.h
DEPENDS ${SRCS}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
-
+if(0)
if(MSVC)
install(TARGETS ${redwg} RUNTIME PUBLIC_HEADER
DESTINATION libredwg-${PACKAGE_VERSION})
@@ -331,7 +332,21 @@ else()
endif()
endif()
install(TARGETS RUNTIME)
-
+endif()
+include(GNUInstallDirs)
+install(
+ TARGETS ${redwg}
+ EXPORT libredwg-core
+ COMPONENT libredwg
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ PUBLIC_HEADER DESTINATION include/libredwg)
+if(NOT LIBREDWG_LIBONLY)
+ install(TARGETS ${executables_TARGETS}
+ DESTINATION "${CMAKE_INSTALL_BINDIR}")
+endif()
+install(EXPORT libredwg-core FILE unofficial-libredwg-config.cmake NAMESPACE unofficial::libredwg:: DESTINATION share/unofficial-libredwg)
if(WIN32)
add_custom_target(dist
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/README README
55 changes: 55 additions & 0 deletions ports/libredwg/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO LibreDWG/libredwg
REF ${VERSION}
SHA512 8696289ea7ff542bd48d4e1f0e959b95574a7741ba0c80238ad31aff28f1861f0c00dfb1dc78e998b043a4300ff976ba324f5a41195f799f9d31e2b5be288bc7
HEAD_REF master
PATCHES
fix_install.patch
fix_dependency.patch
fix_arm64_build.patch
)

# If generate dwg manipulation tools
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
INVERTED_FEATURES
tools LIBREDWG_LIBONLY
)

# libredwg will read the version
file(WRITE "${SOURCE_PATH}/.version" ${VERSION})

# Fix https://github.com/LibreDWG/libredwg/issues/652#issuecomment-1454035167
if(APPLE)
vcpkg_replace_string("${SOURCE_PATH}/src/common.h"
[[defined(COMMON_TEST_C)]]
[[1]]
)
vcpkg_replace_string("${SOURCE_PATH}/src/common.c"
[[defined(COMMON_TEST_C)]]
[[1]]
)
endif()

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
${FEATURE_OPTIONS}
-DBUILD_TESTING=OFF
)

vcpkg_cmake_install()
vcpkg_copy_pdbs()
vcpkg_fixup_pkgconfig()

vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-libredwg CONFIG_PATH share/unofficial-libredwg)

if("tools" IN_LIST FEATURES)
vcpkg_copy_tools(TOOL_NAMES dwg2dxf dwg2SVG dwgbmp dwggrep dwglayers dwgread dwgrewrite dwgwrite dxf2dwg AUTO_CLEAN)
vcpkg_copy_tool_dependencies("${CURRENT_PACKAGES_DIR}/tools/libredwg")
endif()

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include" "${CURRENT_PACKAGES_DIR}/debug/share")

file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/COPYING")
4 changes: 4 additions & 0 deletions ports/libredwg/usage
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
libredwg provides CMake targets:

find_package(unofficial-libredwg CONFIG REQUIRED)
target_link_libraries(main unofficial::libredwg::libredwg)
23 changes: 23 additions & 0 deletions ports/libredwg/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "libredwg",
"version": "0.12.5.5178",
"description": "GNU LibreDWG is a free C library to handle DWG files. It aims to be a free replacement for the OpenDWG libraries. DWG is the native file format of AutoCAD.",
"homepage": "https://www.gnu.org/software/libredwg/",
"license": "GPL-3.0",
"dependencies": [
"jsmn",
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
],
"features": {
"tools": {
"description": "Build dwg/dxf manipulation command-line tools"
}
}
}
4 changes: 4 additions & 0 deletions versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -4344,6 +4344,10 @@
"baseline": "2.0.2",
"port-version": 0
},
"libredwg": {
"baseline": "0.12.5.5178",
"port-version": 0
},
"libressl": {
"baseline": "3.6.2",
"port-version": 0
Expand Down
9 changes: 9 additions & 0 deletions versions/l-/libredwg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"versions": [
{
"git-tree": "aa161067eef7398933b726e81cd4824733a9c9a6",
"version": "0.12.5.5178",
"port-version": 0
}
]
}

0 comments on commit 4e57712

Please sign in to comment.