From 4066171ea2ea145b7464800f0808ed47c5f793bd Mon Sep 17 00:00:00 2001 From: Laurent Arnoud Date: Tue, 18 Apr 2017 00:21:07 +0200 Subject: [PATCH 1/2] Generate pkgconfig file for tidy --- CMakeLists.txt | 19 +++++++++++++++++-- build/cmake/.gitignore | 1 + build/cmake/cmake-clean.txt | 2 +- tidy.pc.cmake.in | 9 +++++++++ 4 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 tidy.pc.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 862ca31..834e8c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,8 @@ cmake_minimum_required (VERSION 2.8.7) set(LIB_NAME tidy) +set(LIBTIDY_DESCRIPTION "${LIB_NAME} - HTML syntax checker") +set(LIBTIDY_URL "http://www.html-tidy.org") project (${LIB_NAME}) @@ -371,7 +373,7 @@ else () endif () set(CPACK_PACKAGE_NAME "${LIB_NAME}") -set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${LIB_NAME} - HTML syntax checker") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${LIBTIDY_DESCRIPTION}") set(CPACK_PACKAGE_VENDOR "HTML Tidy Advocacy Community Group") set(CPACK_PACKAGE_CONTACT "maintainer@htacg.org") @@ -387,7 +389,7 @@ set(CPACK_RESOURCE_FILE_WELCOME "${CMAKE_CURRENT_SOURCE_DIR}/README/README.html" ## debian config set(CPACK_DEBIAN_PACKAGE_MAINTAINER ${CPACK_PACKAGE_CONTACT}) -set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "http://www.html-tidy.org/") +set(CPACK_DEBIAN_PACKAGE_HOMEPAGE ${LIBTIDY_URL}) #set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc") set(CPACK_DEBIAN_PACKAGE_SECTION "Libraries") set(CPACK_SOURCE_IGNORE_FILES @@ -405,4 +407,17 @@ endif () include(CPack) +# pkg-config +set(INSTALL_LIBDIR "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}" CACHE PATH "Installation directory for libraries") +set(INSTALL_INCDIR "${CMAKE_INSTALL_PREFIX}/${INCLUDE_INSTALL_DIR}" CACHE PATH "Installation directory for headers") +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/${LIB_NAME}.pc.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/${LIB_NAME}.pc" + @ONLY + ) +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/${LIB_NAME}.pc" + DESTINATION "${INSTALL_LIBDIR}/pkgconfig" + ) + # eof diff --git a/build/cmake/.gitignore b/build/cmake/.gitignore index 2539213..2b83d50 100644 --- a/build/cmake/.gitignore +++ b/build/cmake/.gitignore @@ -30,5 +30,6 @@ _CPack_Packages/* tidy libtidy* tidy1.xsl +tidy.pc *.vcproj diff --git a/build/cmake/cmake-clean.txt b/build/cmake/cmake-clean.txt index 36eb531..c57f3ae 100644 --- a/build/cmake/cmake-clean.txt +++ b/build/cmake/cmake-clean.txt @@ -27,4 +27,4 @@ libtidy.so.5.0.0 tidy.1 _CPack_Packages tidy1.xsl - +tidy.pc diff --git a/tidy.pc.cmake.in b/tidy.pc.cmake.in new file mode 100644 index 0000000..96e7262 --- /dev/null +++ b/tidy.pc.cmake.in @@ -0,0 +1,9 @@ +libdir=@INSTALL_LIBDIR@ +includedir=@INSTALL_INCDIR@ + +Name: @LIB_NAME@ +Description: @LIBTIDY_DESCRIPTION@ +URL: @LIBTIDY_URL@ +Version: @LIBTIDY_VERSION@ +Libs: -L${libdir} -l@LIB_NAME@ +Cflags: -I${includedir} From 3333ca7d6942b270048d76f9fd8729d4d2f5f21e Mon Sep 17 00:00:00 2001 From: Laurent Arnoud Date: Tue, 2 May 2017 20:28:48 +0200 Subject: [PATCH 2/2] Fix pkgconfig install path on package --- CMakeLists.txt | 6 ++---- README/BUILD.md | 8 ++++++++ tidy.pc.cmake.in | 6 ++++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 834e8c4..b459f5f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -205,7 +205,7 @@ if (NOT BIN_INSTALL_DIR) endif () if (NOT INCLUDE_INSTALL_DIR) - set(INCLUDE_INSTALL_DIR include) + set(INCLUDE_INSTALL_DIR include/${LIB_NAME}) endif () # Always build the STATIC library @@ -408,8 +408,6 @@ endif () include(CPack) # pkg-config -set(INSTALL_LIBDIR "${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR}" CACHE PATH "Installation directory for libraries") -set(INSTALL_INCDIR "${CMAKE_INSTALL_PREFIX}/${INCLUDE_INSTALL_DIR}" CACHE PATH "Installation directory for headers") configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/${LIB_NAME}.pc.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/${LIB_NAME}.pc" @@ -417,7 +415,7 @@ configure_file( ) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${LIB_NAME}.pc" - DESTINATION "${INSTALL_LIBDIR}/pkgconfig" + DESTINATION "${LIB_INSTALL_DIR}/pkgconfig" ) # eof diff --git a/README/BUILD.md b/README/BUILD.md index 6ae5bbb..e427752 100644 --- a/README/BUILD.md +++ b/README/BUILD.md @@ -40,6 +40,14 @@ If you do **not** need the tidy library built as a 'shared' (DLL) library, then See the `CMakeLists.txt` file for other CMake **options** offered. +## Build the tidy packages + + 1. `cd build/cmake` + + 2. `cmake ../.. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr` + + 3. Unix/OS X: `make package` + ## Build PHP with the tidy-html5 library Due to API changes in the PHP source, `buffio.h` needs to be renamed to `tidybuffio.h` in the file `ext/tidy/tidy.c` in PHP's source. diff --git a/tidy.pc.cmake.in b/tidy.pc.cmake.in index 96e7262..7d819f1 100644 --- a/tidy.pc.cmake.in +++ b/tidy.pc.cmake.in @@ -1,5 +1,7 @@ -libdir=@INSTALL_LIBDIR@ -includedir=@INSTALL_INCDIR@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=${prefix} +libdir=${exec_prefix}/@LIB_INSTALL_DIR@ +includedir=${prefix}/@INCLUDE_INSTALL_DIR@ Name: @LIB_NAME@ Description: @LIBTIDY_DESCRIPTION@