Skip to content

Commit 3cbf9ac

Browse files
authored
fix: correct option have-rules (#15)
* fix: correct option have-rules * patch pcre * support armv7 * add missing pkg-config
1 parent 6aabe07 commit 3cbf9ac

12 files changed

+344
-7
lines changed

.pre-commit-config.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
fail_fast: false
1616
exclude: |
1717
(?x)(
18-
^(.vscode/.*)
18+
^(.vscode/.*) |
19+
^(cmake/vcpkg/ports/.*)
1920
)
2021
files: '' # set '' as default
2122

CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ find_package(cmake-modules REQUIRED)
3030
include(cmake-modules/ProjectDefault)
3131

3232
find_program(cppcheck NAMES "cppcheck" "cppcheck.exe")
33-
34-
install(PROGRAMS ${cppcheck} DESTINATION ${SKBUILD_PROJECT_NAME}/Cppcheck)
33+
cmake_path(GET cppcheck PARENT_PATH cppcheck_dir)
34+
file(GLOB cppcheck_runtimes ${cppcheck_dir}/*)
35+
install(PROGRAMS ${cppcheck_runtimes}
36+
DESTINATION ${SKBUILD_PROJECT_NAME}/Cppcheck)
3537
install(DIRECTORY ${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/share/Cppcheck
3638
DESTINATION ${SKBUILD_PROJECT_NAME})

cmake/vcpkg/ports/cppcheck/portfile.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ endif()
2424

2525
vcpkg_check_features(
2626
OUT_FEATURE_OPTIONS FEATURE_OPTIONS
27-
FEATURES
27+
INVERTED_FEATURES
2828
have_rules HAVE_RULES
2929
)
3030

cmake/vcpkg/ports/cppcheck/vcpkg.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@
1616
],
1717
"features": {
1818
"have-rules": {
19-
"description": "Dependencies for testing",
20-
"supports": "!windows | !osx"
19+
"description": "To compile with rules",
20+
"dependencies": [
21+
"pcre"
22+
]
2123
}
2224
}
2325
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--- a/CMakeLists.txt 2021-06-14 10:33:38.000000000 +0200
2+
+++ b/CMakeLists.txt 2021-06-18 18:08:24.162881000 +0200
3+
@@ -934,10 +934,19 @@
4+
# Installation
5+
SET(CMAKE_INSTALL_ALWAYS 1)
6+
7+
-INSTALL(TARGETS ${targets}
8+
+foreach(target ${targets})
9+
+ INSTALL(TARGETS ${target}
10+
+ EXPORT pcre-targets
11+
RUNTIME DESTINATION bin
12+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
13+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
14+
+ target_include_directories(${target} PUBLIC $<INSTALL_INTERFACE:include>)
15+
+endforeach()
16+
+
17+
+INSTALL(EXPORT pcre-targets
18+
+ NAMESPACE unofficial::pcre::
19+
+ FILE unofficial-pcre-targets.cmake
20+
+ DESTINATION "share/unofficial-pcre")
21+
22+
INSTALL(FILES ${PCRE_HEADERS} ${PCREPOSIX_HEADERS} DESTINATION include)
23+
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
diff --git a/CMakeLists.txt b/CMakeLists.txt
2+
index 2c3a309..cdd480f 100644
3+
--- a/CMakeLists.txt
4+
+++ b/CMakeLists.txt
5+
@@ -94,7 +94,7 @@ FIND_PACKAGE( Editline )
6+
7+
INCLUDE(CheckIncludeFile)
8+
INCLUDE(CheckIncludeFileCXX)
9+
-INCLUDE(CheckFunctionExists)
10+
+INCLUDE(CheckSymbolExists)
11+
INCLUDE(CheckTypeSize)
12+
INCLUDE(GNUInstallDirs) # for CMAKE_INSTALL_LIBDIR
13+
14+
@@ -109,12 +109,12 @@ CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H)
15+
CHECK_INCLUDE_FILE_CXX(type_traits.h HAVE_TYPE_TRAITS_H)
16+
CHECK_INCLUDE_FILE_CXX(bits/type_traits.h HAVE_BITS_TYPE_TRAITS_H)
17+
18+
-CHECK_FUNCTION_EXISTS(bcopy HAVE_BCOPY)
19+
-CHECK_FUNCTION_EXISTS(memmove HAVE_MEMMOVE)
20+
-CHECK_FUNCTION_EXISTS(strerror HAVE_STRERROR)
21+
-CHECK_FUNCTION_EXISTS(strtoll HAVE_STRTOLL)
22+
-CHECK_FUNCTION_EXISTS(strtoq HAVE_STRTOQ)
23+
-CHECK_FUNCTION_EXISTS(_strtoi64 HAVE__STRTOI64)
24+
+CHECK_SYMBOL_EXISTS(bcopy strings.h HAVE_BCOPY)
25+
+CHECK_SYMBOL_EXISTS(memmove string.h HAVE_MEMMOVE)
26+
+CHECK_SYMBOL_EXISTS(strerror string.h HAVE_STRERROR)
27+
+CHECK_SYMBOL_EXISTS(strtoll stdlib.h HAVE_STRTOLL)
28+
+CHECK_SYMBOL_EXISTS(strtoq stdlib.h HAVE_STRTOQ)
29+
+CHECK_SYMBOL_EXISTS(_strtoi64 stdlib.h HAVE__STRTOI64)
30+
31+
CHECK_TYPE_SIZE("long long" LONG_LONG)
32+
CHECK_TYPE_SIZE("unsigned long long" UNSIGNED_LONG_LONG)
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
Index: CMakeLists.txt
2+
===================================================================
3+
--- CMakeLists.txt (revision 1767)
4+
+++ CMakeLists.txt (working copy)
5+
@@ -436,6 +436,12 @@
6+
@ONLY)
7+
ENDIF(PCRE_BUILD_PCRECPP)
8+
9+
+# Make sure to not link debug libs
10+
+# against release libs and vice versa
11+
+IF(WIN32)
12+
+ SET(CMAKE_DEBUG_POSTFIX "d")
13+
+ENDIF(WIN32)
14+
+
15+
# Generate pkg-config files
16+
SET(PACKAGE_VERSION "${PCRE_MAJOR}.${PCRE_MINOR}")
17+
SET(prefix "${CMAKE_INSTALL_PREFIX}")
18+
@@ -442,6 +448,9 @@
19+
SET(exec_prefix "\${prefix}")
20+
SET(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}")
21+
SET(includedir "\${prefix}/include")
22+
+IF(WIN32 AND (CMAKE_BUILD_TYPE MATCHES Debug))
23+
+ SET(LIB_POSTFIX ${CMAKE_DEBUG_POSTFIX})
24+
+ENDIF()
25+
IF(NOT BUILD_SHARED_LIBS)
26+
SET(PCRE_STATIC_CFLAG "-DPCRE_STATIC")
27+
ENDIF(NOT BUILD_SHARED_LIBS)
28+
@@ -659,11 +668,6 @@
29+
ENDIF(MSVC)
30+
31+
SET(CMAKE_INCLUDE_CURRENT_DIR 1)
32+
-# needed to make sure to not link debug libs
33+
-# against release libs and vice versa
34+
-IF(WIN32)
35+
- SET(CMAKE_DEBUG_POSTFIX "d")
36+
-ENDIF(WIN32)
37+
38+
SET(targets)
39+
40+
Index: configure.ac
41+
===================================================================
42+
--- configure.ac (revision 1767)
43+
+++ configure.ac (working copy)
44+
@@ -1044,6 +1044,9 @@
45+
AM_CONDITIONAL([WITH_GCOV],[test "x$enable_coverage" = "xyes"])
46+
47+
# Produce these files, in addition to config.h.
48+
+# LIB_POSTFIX is used by CMakeLists.txt for Windows debug builds.
49+
+# Pass empty LIB_POSTFIX to *.pc files and pcre-config here.
50+
+AC_SUBST(LIB_POSTFIX)
51+
AC_CONFIG_FILES(
52+
Makefile
53+
libpcre.pc
54+
Index: libpcre.pc.in
55+
===================================================================
56+
--- libpcre.pc.in (revision 1767)
57+
+++ libpcre.pc.in (working copy)
58+
@@ -8,6 +8,6 @@
59+
Name: libpcre
60+
Description: PCRE - Perl compatible regular expressions C library with 8 bit character support
61+
Version: @PACKAGE_VERSION@
62+
-Libs: -L${libdir} -lpcre
63+
+Libs: -L${libdir} -lpcre@LIB_POSTFIX@
64+
Libs.private: @PTHREAD_CFLAGS@ @PTHREAD_LIBS@
65+
Cflags: -I${includedir} @PCRE_STATIC_CFLAG@
66+
Index: libpcre16.pc.in
67+
===================================================================
68+
--- libpcre16.pc.in (revision 1767)
69+
+++ libpcre16.pc.in (working copy)
70+
@@ -8,6 +8,6 @@
71+
Name: libpcre16
72+
Description: PCRE - Perl compatible regular expressions C library with 16 bit character support
73+
Version: @PACKAGE_VERSION@
74+
-Libs: -L${libdir} -lpcre16
75+
+Libs: -L${libdir} -lpcre16@LIB_POSTFIX@
76+
Libs.private: @PTHREAD_CFLAGS@ @PTHREAD_LIBS@
77+
Cflags: -I${includedir} @PCRE_STATIC_CFLAG@
78+
Index: libpcre32.pc.in
79+
===================================================================
80+
--- libpcre32.pc.in (revision 1767)
81+
+++ libpcre32.pc.in (working copy)
82+
@@ -8,6 +8,6 @@
83+
Name: libpcre32
84+
Description: PCRE - Perl compatible regular expressions C library with 32 bit character support
85+
Version: @PACKAGE_VERSION@
86+
-Libs: -L${libdir} -lpcre32
87+
+Libs: -L${libdir} -lpcre32@LIB_POSTFIX@
88+
Libs.private: @PTHREAD_CFLAGS@ @PTHREAD_LIBS@
89+
Cflags: -I${includedir} @PCRE_STATIC_CFLAG@
90+
Index: libpcrecpp.pc.in
91+
===================================================================
92+
--- libpcrecpp.pc.in (revision 1767)
93+
+++ libpcrecpp.pc.in (working copy)
94+
@@ -8,5 +8,5 @@
95+
Name: libpcrecpp
96+
Description: PCRECPP - C++ wrapper for PCRE
97+
Version: @PACKAGE_VERSION@
98+
-Libs: -L${libdir} -lpcre -lpcrecpp
99+
+Libs: -L${libdir} -lpcre@LIB_POSTFIX@ -lpcrecpp@LIB_POSTFIX@
100+
Cflags: -I${includedir} @PCRE_STATIC_CFLAG@
101+
Index: libpcreposix.pc.in
102+
===================================================================
103+
--- libpcreposix.pc.in (revision 1767)
104+
+++ libpcreposix.pc.in (working copy)
105+
@@ -8,6 +8,6 @@
106+
Name: libpcreposix
107+
Description: PCREPosix - Posix compatible interface to libpcre
108+
Version: @PACKAGE_VERSION@
109+
-Libs: -L${libdir} -lpcreposix
110+
+Libs: -L${libdir} -lpcreposix@LIB_POSTFIX@
111+
Cflags: -I${includedir} @PCRE_STATIC_CFLAG@
112+
Requires.private: libpcre
113+
Index: pcre-config.in
114+
===================================================================
115+
--- pcre-config.in (revision 1767)
116+
+++ pcre-config.in (working copy)
117+
@@ -91,7 +91,7 @@
118+
;;
119+
--libs-posix)
120+
if test @enable_pcre8@ = yes ; then
121+
- echo $libS$libR -lpcreposix -lpcre
122+
+ echo $libS$libR -lpcreposix@LIB_POSTFIX@ -lpcre@LIB_POSTFIX@
123+
else
124+
echo "${usage}" 1>&2
125+
fi
126+
@@ -98,7 +98,7 @@
127+
;;
128+
--libs)
129+
if test @enable_pcre8@ = yes ; then
130+
- echo $libS$libR -lpcre
131+
+ echo $libS$libR -lpcre@LIB_POSTFIX@
132+
else
133+
echo "${usage}" 1>&2
134+
fi
135+
@@ -105,7 +105,7 @@
136+
;;
137+
--libs16)
138+
if test @enable_pcre16@ = yes ; then
139+
- echo $libS$libR -lpcre16
140+
+ echo $libS$libR -lpcre16@LIB_POSTFIX@
141+
else
142+
echo "${usage}" 1>&2
143+
fi
144+
@@ -112,7 +112,7 @@
145+
;;
146+
--libs32)
147+
if test @enable_pcre32@ = yes ; then
148+
- echo $libS$libR -lpcre32
149+
+ echo $libS$libR -lpcre32@LIB_POSTFIX@
150+
else
151+
echo "${usage}" 1>&2
152+
fi
153+
@@ -119,7 +119,7 @@
154+
;;
155+
--libs-cpp)
156+
if test @enable_cpp@ = yes ; then
157+
- echo $libS$libR -lpcrecpp -lpcre
158+
+ echo $libS$libR -lpcrecpp@LIB_POSTFIX@ -lpcre@LIB_POSTFIX@
159+
else
160+
echo "${usage}" 1>&2
161+
fi
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--- a/CMakeLists.txt 2021-06-14 10:33:38.000000000 +0200
2+
+++ b/CMakeLists.txt 2021-06-18 17:59:59.155148900 +0200
3+
@@ -77,7 +77,6 @@
4+
# CMP0026 to avoid warnings for the use of LOCATION in GET_TARGET_PROPERTY.
5+
6+
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.5)
7+
-CMAKE_POLICY(SET CMP0026 OLD)
8+
9+
# For FindReadline.cmake. This was changed to allow setting CMAKE_MODULE_PATH
10+
# on the command line.
11+
@@ -199,6 +198,7 @@
12+
ENDIF(MINGW)
13+
14+
IF(MSVC)
15+
+ add_definitions(/wd4703 /wd4146 /wd4308)
16+
OPTION(PCRE_STATIC_RUNTIME
17+
"ON=Compile against the static runtime (/MT)."
18+
OFF)

cmake/vcpkg/ports/pcre/portfile.cmake

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
set(PCRE_VERSION 8.45)
2+
set(EXPECTED_SHA 71f246c0abbf356222933ad1604cab87a1a2a3cd8054a0b9d6deb25e0735ce9f40f923d14cbd21f32fdac7283794270afcb0f221ad24662ac35934fcb73675cd)
3+
set(PATCHES
4+
# Fix CMake Deprecation Warning concerning OLD behavior for policy CMP0026
5+
# Suppress MSVC compiler warnings C4703, C4146, C4308, which fixes errors
6+
# under x64-uwp and arm-uwp
7+
pcre-8.45_suppress_cmake_and_compiler_warnings-errors.patch
8+
# Modified for 8.45 from https://bugs.exim.org/show_bug.cgi?id=2600
9+
pcre-8.45_fix_postfix_for_debug_Windows_builds.patch
10+
export-cmake-targets.patch
11+
pcre-8.4.5_fix_check_function_exists_for_arm-androi_builds.patch)
12+
13+
vcpkg_from_sourceforge(
14+
OUT_SOURCE_PATH SOURCE_PATH
15+
REPO pcre/pcre
16+
REF ${PCRE_VERSION}
17+
FILENAME "pcre-${PCRE_VERSION}.zip"
18+
SHA512 ${EXPECTED_SHA}
19+
PATCHES ${PATCHES}
20+
)
21+
22+
set(IS_PCRE_SUPPORT_JIT YES)
23+
if(VCPKG_TARGET_ARCHITECTURE MATCHES "(loongarch|^s390|^arm)")
24+
set(IS_PCRE_SUPPORT_JIT NO)
25+
endif()
26+
27+
vcpkg_cmake_configure(
28+
SOURCE_PATH ${SOURCE_PATH}
29+
OPTIONS
30+
-DPCRE_BUILD_TESTS=NO
31+
-DPCRE_BUILD_PCREGREP=NO
32+
-DPCRE_BUILD_PCRE32=YES
33+
-DPCRE_BUILD_PCRE16=YES
34+
-DPCRE_BUILD_PCRE8=YES
35+
-DPCRE_SUPPORT_JIT=${IS_PCRE_SUPPORT_JIT}
36+
-DPCRE_SUPPORT_UTF=YES
37+
-DPCRE_SUPPORT_UNICODE_PROPERTIES=YES
38+
# optional dependencies for PCREGREP
39+
-DPCRE_SUPPORT_LIBBZ2=OFF
40+
-DPCRE_SUPPORT_LIBZ=OFF
41+
-DPCRE_SUPPORT_LIBEDIT=OFF
42+
-DPCRE_SUPPORT_LIBREADLINE=OFF
43+
# OPTIONS -DUSE_THIS_IN_ALL_BUILDS=1 -DUSE_THIS_TOO=2
44+
# OPTIONS_RELEASE -DOPTIMIZE=1
45+
# OPTIONS_DEBUG -DDEBUGGABLE=1
46+
)
47+
48+
vcpkg_cmake_install()
49+
50+
vcpkg_cmake_config_fixup(PACKAGE_NAME "unofficial-${PORT}" CONFIG_PATH "share/unofficial-${PORT}")
51+
52+
foreach(FILE "${CURRENT_PACKAGES_DIR}/include/pcre.h" "${CURRENT_PACKAGES_DIR}/include/pcreposix.h")
53+
file(READ ${FILE} PCRE_H)
54+
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
55+
string(REPLACE "defined(PCRE_STATIC)" "1" PCRE_H "${PCRE_H}")
56+
else()
57+
string(REPLACE "defined(PCRE_STATIC)" "0" PCRE_H "${PCRE_H}")
58+
endif()
59+
file(WRITE ${FILE} "${PCRE_H}")
60+
endforeach()
61+
62+
vcpkg_fixup_pkgconfig()
63+
64+
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
65+
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")
66+
67+
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/man")
68+
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/man")
69+
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/share/doc")
70+
71+
file(REMOVE "${CURRENT_PACKAGES_DIR}/bin/pcre-config" "${CURRENT_PACKAGES_DIR}/debug/bin/pcre-config")
72+
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static" OR NOT VCPKG_TARGET_IS_WINDOWS)
73+
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin")
74+
endif()
75+
76+
vcpkg_copy_pdbs()
77+
configure_file("${CMAKE_CURRENT_LIST_DIR}/unofficial-pcre-config.cmake" "${CURRENT_PACKAGES_DIR}/share/unofficial-pcre/unofficial-pcre-config.cmake" @ONLY)
78+
79+
file(INSTALL "${SOURCE_PATH}/COPYING" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include("${CMAKE_CURRENT_LIST_DIR}/unofficial-pcre-targets.cmake")

0 commit comments

Comments
 (0)