Skip to content

Commit

Permalink
fix: correct option have-rules (#15)
Browse files Browse the repository at this point in the history
* fix: correct option have-rules
* patch pcre
* support armv7
* add missing pkg-config
  • Loading branch information
msclock authored Nov 30, 2024
1 parent 6aabe07 commit 3cbf9ac
Show file tree
Hide file tree
Showing 12 changed files with 344 additions and 7 deletions.
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
fail_fast: false
exclude: |
(?x)(
^(.vscode/.*)
^(.vscode/.*) |
^(cmake/vcpkg/ports/.*)
)
files: '' # set '' as default

Expand Down
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ find_package(cmake-modules REQUIRED)
include(cmake-modules/ProjectDefault)

find_program(cppcheck NAMES "cppcheck" "cppcheck.exe")

install(PROGRAMS ${cppcheck} DESTINATION ${SKBUILD_PROJECT_NAME}/Cppcheck)
cmake_path(GET cppcheck PARENT_PATH cppcheck_dir)
file(GLOB cppcheck_runtimes ${cppcheck_dir}/*)
install(PROGRAMS ${cppcheck_runtimes}
DESTINATION ${SKBUILD_PROJECT_NAME}/Cppcheck)
install(DIRECTORY ${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/share/Cppcheck
DESTINATION ${SKBUILD_PROJECT_NAME})
2 changes: 1 addition & 1 deletion cmake/vcpkg/ports/cppcheck/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ endif()

vcpkg_check_features(
OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
INVERTED_FEATURES
have_rules HAVE_RULES
)

Expand Down
6 changes: 4 additions & 2 deletions cmake/vcpkg/ports/cppcheck/vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
],
"features": {
"have-rules": {
"description": "Dependencies for testing",
"supports": "!windows | !osx"
"description": "To compile with rules",
"dependencies": [
"pcre"
]
}
}
}
23 changes: 23 additions & 0 deletions cmake/vcpkg/ports/pcre/export-cmake-targets.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
--- a/CMakeLists.txt 2021-06-14 10:33:38.000000000 +0200
+++ b/CMakeLists.txt 2021-06-18 18:08:24.162881000 +0200
@@ -934,10 +934,19 @@
# Installation
SET(CMAKE_INSTALL_ALWAYS 1)

-INSTALL(TARGETS ${targets}
+foreach(target ${targets})
+ INSTALL(TARGETS ${target}
+ EXPORT pcre-targets
RUNTIME DESTINATION bin
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ target_include_directories(${target} PUBLIC $<INSTALL_INTERFACE:include>)
+endforeach()
+
+INSTALL(EXPORT pcre-targets
+ NAMESPACE unofficial::pcre::
+ FILE unofficial-pcre-targets.cmake
+ DESTINATION "share/unofficial-pcre")

INSTALL(FILES ${PCRE_HEADERS} ${PCREPOSIX_HEADERS} DESTINATION include)

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2c3a309..cdd480f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -94,7 +94,7 @@ FIND_PACKAGE( Editline )

INCLUDE(CheckIncludeFile)
INCLUDE(CheckIncludeFileCXX)
-INCLUDE(CheckFunctionExists)
+INCLUDE(CheckSymbolExists)
INCLUDE(CheckTypeSize)
INCLUDE(GNUInstallDirs) # for CMAKE_INSTALL_LIBDIR

@@ -109,12 +109,12 @@ CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H)
CHECK_INCLUDE_FILE_CXX(type_traits.h HAVE_TYPE_TRAITS_H)
CHECK_INCLUDE_FILE_CXX(bits/type_traits.h HAVE_BITS_TYPE_TRAITS_H)

-CHECK_FUNCTION_EXISTS(bcopy HAVE_BCOPY)
-CHECK_FUNCTION_EXISTS(memmove HAVE_MEMMOVE)
-CHECK_FUNCTION_EXISTS(strerror HAVE_STRERROR)
-CHECK_FUNCTION_EXISTS(strtoll HAVE_STRTOLL)
-CHECK_FUNCTION_EXISTS(strtoq HAVE_STRTOQ)
-CHECK_FUNCTION_EXISTS(_strtoi64 HAVE__STRTOI64)
+CHECK_SYMBOL_EXISTS(bcopy strings.h HAVE_BCOPY)
+CHECK_SYMBOL_EXISTS(memmove string.h HAVE_MEMMOVE)
+CHECK_SYMBOL_EXISTS(strerror string.h HAVE_STRERROR)
+CHECK_SYMBOL_EXISTS(strtoll stdlib.h HAVE_STRTOLL)
+CHECK_SYMBOL_EXISTS(strtoq stdlib.h HAVE_STRTOQ)
+CHECK_SYMBOL_EXISTS(_strtoi64 stdlib.h HAVE__STRTOI64)

CHECK_TYPE_SIZE("long long" LONG_LONG)
CHECK_TYPE_SIZE("unsigned long long" UNSIGNED_LONG_LONG)
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt (revision 1767)
+++ CMakeLists.txt (working copy)
@@ -436,6 +436,12 @@
@ONLY)
ENDIF(PCRE_BUILD_PCRECPP)

+# Make sure to not link debug libs
+# against release libs and vice versa
+IF(WIN32)
+ SET(CMAKE_DEBUG_POSTFIX "d")
+ENDIF(WIN32)
+
# Generate pkg-config files
SET(PACKAGE_VERSION "${PCRE_MAJOR}.${PCRE_MINOR}")
SET(prefix "${CMAKE_INSTALL_PREFIX}")
@@ -442,6 +448,9 @@
SET(exec_prefix "\${prefix}")
SET(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}")
SET(includedir "\${prefix}/include")
+IF(WIN32 AND (CMAKE_BUILD_TYPE MATCHES Debug))
+ SET(LIB_POSTFIX ${CMAKE_DEBUG_POSTFIX})
+ENDIF()
IF(NOT BUILD_SHARED_LIBS)
SET(PCRE_STATIC_CFLAG "-DPCRE_STATIC")
ENDIF(NOT BUILD_SHARED_LIBS)
@@ -659,11 +668,6 @@
ENDIF(MSVC)

SET(CMAKE_INCLUDE_CURRENT_DIR 1)
-# needed to make sure to not link debug libs
-# against release libs and vice versa
-IF(WIN32)
- SET(CMAKE_DEBUG_POSTFIX "d")
-ENDIF(WIN32)

SET(targets)

Index: configure.ac
===================================================================
--- configure.ac (revision 1767)
+++ configure.ac (working copy)
@@ -1044,6 +1044,9 @@
AM_CONDITIONAL([WITH_GCOV],[test "x$enable_coverage" = "xyes"])

# Produce these files, in addition to config.h.
+# LIB_POSTFIX is used by CMakeLists.txt for Windows debug builds.
+# Pass empty LIB_POSTFIX to *.pc files and pcre-config here.
+AC_SUBST(LIB_POSTFIX)
AC_CONFIG_FILES(
Makefile
libpcre.pc
Index: libpcre.pc.in
===================================================================
--- libpcre.pc.in (revision 1767)
+++ libpcre.pc.in (working copy)
@@ -8,6 +8,6 @@
Name: libpcre
Description: PCRE - Perl compatible regular expressions C library with 8 bit character support
Version: @PACKAGE_VERSION@
-Libs: -L${libdir} -lpcre
+Libs: -L${libdir} -lpcre@LIB_POSTFIX@
Libs.private: @PTHREAD_CFLAGS@ @PTHREAD_LIBS@
Cflags: -I${includedir} @PCRE_STATIC_CFLAG@
Index: libpcre16.pc.in
===================================================================
--- libpcre16.pc.in (revision 1767)
+++ libpcre16.pc.in (working copy)
@@ -8,6 +8,6 @@
Name: libpcre16
Description: PCRE - Perl compatible regular expressions C library with 16 bit character support
Version: @PACKAGE_VERSION@
-Libs: -L${libdir} -lpcre16
+Libs: -L${libdir} -lpcre16@LIB_POSTFIX@
Libs.private: @PTHREAD_CFLAGS@ @PTHREAD_LIBS@
Cflags: -I${includedir} @PCRE_STATIC_CFLAG@
Index: libpcre32.pc.in
===================================================================
--- libpcre32.pc.in (revision 1767)
+++ libpcre32.pc.in (working copy)
@@ -8,6 +8,6 @@
Name: libpcre32
Description: PCRE - Perl compatible regular expressions C library with 32 bit character support
Version: @PACKAGE_VERSION@
-Libs: -L${libdir} -lpcre32
+Libs: -L${libdir} -lpcre32@LIB_POSTFIX@
Libs.private: @PTHREAD_CFLAGS@ @PTHREAD_LIBS@
Cflags: -I${includedir} @PCRE_STATIC_CFLAG@
Index: libpcrecpp.pc.in
===================================================================
--- libpcrecpp.pc.in (revision 1767)
+++ libpcrecpp.pc.in (working copy)
@@ -8,5 +8,5 @@
Name: libpcrecpp
Description: PCRECPP - C++ wrapper for PCRE
Version: @PACKAGE_VERSION@
-Libs: -L${libdir} -lpcre -lpcrecpp
+Libs: -L${libdir} -lpcre@LIB_POSTFIX@ -lpcrecpp@LIB_POSTFIX@
Cflags: -I${includedir} @PCRE_STATIC_CFLAG@
Index: libpcreposix.pc.in
===================================================================
--- libpcreposix.pc.in (revision 1767)
+++ libpcreposix.pc.in (working copy)
@@ -8,6 +8,6 @@
Name: libpcreposix
Description: PCREPosix - Posix compatible interface to libpcre
Version: @PACKAGE_VERSION@
-Libs: -L${libdir} -lpcreposix
+Libs: -L${libdir} -lpcreposix@LIB_POSTFIX@
Cflags: -I${includedir} @PCRE_STATIC_CFLAG@
Requires.private: libpcre
Index: pcre-config.in
===================================================================
--- pcre-config.in (revision 1767)
+++ pcre-config.in (working copy)
@@ -91,7 +91,7 @@
;;
--libs-posix)
if test @enable_pcre8@ = yes ; then
- echo $libS$libR -lpcreposix -lpcre
+ echo $libS$libR -lpcreposix@LIB_POSTFIX@ -lpcre@LIB_POSTFIX@
else
echo "${usage}" 1>&2
fi
@@ -98,7 +98,7 @@
;;
--libs)
if test @enable_pcre8@ = yes ; then
- echo $libS$libR -lpcre
+ echo $libS$libR -lpcre@LIB_POSTFIX@
else
echo "${usage}" 1>&2
fi
@@ -105,7 +105,7 @@
;;
--libs16)
if test @enable_pcre16@ = yes ; then
- echo $libS$libR -lpcre16
+ echo $libS$libR -lpcre16@LIB_POSTFIX@
else
echo "${usage}" 1>&2
fi
@@ -112,7 +112,7 @@
;;
--libs32)
if test @enable_pcre32@ = yes ; then
- echo $libS$libR -lpcre32
+ echo $libS$libR -lpcre32@LIB_POSTFIX@
else
echo "${usage}" 1>&2
fi
@@ -119,7 +119,7 @@
;;
--libs-cpp)
if test @enable_cpp@ = yes ; then
- echo $libS$libR -lpcrecpp -lpcre
+ echo $libS$libR -lpcrecpp@LIB_POSTFIX@ -lpcre@LIB_POSTFIX@
else
echo "${usage}" 1>&2
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
--- a/CMakeLists.txt 2021-06-14 10:33:38.000000000 +0200
+++ b/CMakeLists.txt 2021-06-18 17:59:59.155148900 +0200
@@ -77,7 +77,6 @@
# CMP0026 to avoid warnings for the use of LOCATION in GET_TARGET_PROPERTY.

CMAKE_MINIMUM_REQUIRED(VERSION 2.8.5)
-CMAKE_POLICY(SET CMP0026 OLD)

# For FindReadline.cmake. This was changed to allow setting CMAKE_MODULE_PATH
# on the command line.
@@ -199,6 +198,7 @@
ENDIF(MINGW)

IF(MSVC)
+ add_definitions(/wd4703 /wd4146 /wd4308)
OPTION(PCRE_STATIC_RUNTIME
"ON=Compile against the static runtime (/MT)."
OFF)
79 changes: 79 additions & 0 deletions cmake/vcpkg/ports/pcre/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
set(PCRE_VERSION 8.45)
set(EXPECTED_SHA 71f246c0abbf356222933ad1604cab87a1a2a3cd8054a0b9d6deb25e0735ce9f40f923d14cbd21f32fdac7283794270afcb0f221ad24662ac35934fcb73675cd)
set(PATCHES
# Fix CMake Deprecation Warning concerning OLD behavior for policy CMP0026
# Suppress MSVC compiler warnings C4703, C4146, C4308, which fixes errors
# under x64-uwp and arm-uwp
pcre-8.45_suppress_cmake_and_compiler_warnings-errors.patch
# Modified for 8.45 from https://bugs.exim.org/show_bug.cgi?id=2600
pcre-8.45_fix_postfix_for_debug_Windows_builds.patch
export-cmake-targets.patch
pcre-8.4.5_fix_check_function_exists_for_arm-androi_builds.patch)

vcpkg_from_sourceforge(
OUT_SOURCE_PATH SOURCE_PATH
REPO pcre/pcre
REF ${PCRE_VERSION}
FILENAME "pcre-${PCRE_VERSION}.zip"
SHA512 ${EXPECTED_SHA}
PATCHES ${PATCHES}
)

set(IS_PCRE_SUPPORT_JIT YES)
if(VCPKG_TARGET_ARCHITECTURE MATCHES "(loongarch|^s390|^arm)")
set(IS_PCRE_SUPPORT_JIT NO)
endif()

vcpkg_cmake_configure(
SOURCE_PATH ${SOURCE_PATH}
OPTIONS
-DPCRE_BUILD_TESTS=NO
-DPCRE_BUILD_PCREGREP=NO
-DPCRE_BUILD_PCRE32=YES
-DPCRE_BUILD_PCRE16=YES
-DPCRE_BUILD_PCRE8=YES
-DPCRE_SUPPORT_JIT=${IS_PCRE_SUPPORT_JIT}
-DPCRE_SUPPORT_UTF=YES
-DPCRE_SUPPORT_UNICODE_PROPERTIES=YES
# optional dependencies for PCREGREP
-DPCRE_SUPPORT_LIBBZ2=OFF
-DPCRE_SUPPORT_LIBZ=OFF
-DPCRE_SUPPORT_LIBEDIT=OFF
-DPCRE_SUPPORT_LIBREADLINE=OFF
# OPTIONS -DUSE_THIS_IN_ALL_BUILDS=1 -DUSE_THIS_TOO=2
# OPTIONS_RELEASE -DOPTIMIZE=1
# OPTIONS_DEBUG -DDEBUGGABLE=1
)

vcpkg_cmake_install()

vcpkg_cmake_config_fixup(PACKAGE_NAME "unofficial-${PORT}" CONFIG_PATH "share/unofficial-${PORT}")

foreach(FILE "${CURRENT_PACKAGES_DIR}/include/pcre.h" "${CURRENT_PACKAGES_DIR}/include/pcreposix.h")
file(READ ${FILE} PCRE_H)
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
string(REPLACE "defined(PCRE_STATIC)" "1" PCRE_H "${PCRE_H}")
else()
string(REPLACE "defined(PCRE_STATIC)" "0" PCRE_H "${PCRE_H}")
endif()
file(WRITE ${FILE} "${PCRE_H}")
endforeach()

vcpkg_fixup_pkgconfig()

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

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

file(REMOVE "${CURRENT_PACKAGES_DIR}/bin/pcre-config" "${CURRENT_PACKAGES_DIR}/debug/bin/pcre-config")
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static" OR NOT VCPKG_TARGET_IS_WINDOWS)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin")
endif()

vcpkg_copy_pdbs()
configure_file("${CMAKE_CURRENT_LIST_DIR}/unofficial-pcre-config.cmake" "${CURRENT_PACKAGES_DIR}/share/unofficial-pcre/unofficial-pcre-config.cmake" @ONLY)

file(INSTALL "${SOURCE_PATH}/COPYING" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
1 change: 1 addition & 0 deletions cmake/vcpkg/ports/pcre/unofficial-pcre-config.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include("${CMAKE_CURRENT_LIST_DIR}/unofficial-pcre-targets.cmake")
18 changes: 18 additions & 0 deletions cmake/vcpkg/ports/pcre/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "pcre",
"version": "8.45",
"port-version": 6,
"description": "Perl Compatible Regular Expressions",
"homepage": "https://www.pcre.org/",
"license": null,
"dependencies": [
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
]
}
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ test-skip = ["*-win_arm64", "*-macosx_universal2:arm64"]
[tool.cibuildwheel.linux]
before-build =[
'yum install zip -y || apk add zip || true',
'apt update && apt install zip -y || true',
'apt update && apt install zip pkg-config -y || true',
'pip install cmake ninja',
'cmake --version', 'git --version', 'ninja --version',
]
Expand Down

0 comments on commit 3cbf9ac

Please sign in to comment.