From 422de388e4fee3b1cee6859e13d7e9def1dc817b Mon Sep 17 00:00:00 2001 From: Kevin Albertson Date: Sat, 13 Jan 2024 18:07:29 -0500 Subject: [PATCH 1/9] use relative paths for install This is intended to make the installed package relocatable. --- CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 67bd9fa..6f98dc5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,14 +55,14 @@ set_target_properties (utf8proc PROPERTIES if (UTF8PROC_INSTALL) include(GNUInstallDirs) - install(FILES utf8proc.h DESTINATION "${CMAKE_INSTALL_FULL_INCLUDEDIR}") + install(FILES utf8proc.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") install(TARGETS utf8proc - ARCHIVE DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}" - LIBRARY DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}" - RUNTIME DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}" + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" ) configure_file(libutf8proc.pc.cmakein libutf8proc.pc @ONLY) - install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libutf8proc.pc" DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig") + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libutf8proc.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") endif() if(UTF8PROC_ENABLE_TESTING) From 6e0b3975415859c31ee02a93ecaa593cf994b4ea Mon Sep 17 00:00:00 2001 From: Kevin Albertson Date: Sat, 13 Jan 2024 18:08:11 -0500 Subject: [PATCH 2/9] export and install targets --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f98dc5..61da950 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,7 +26,7 @@ add_library (utf8proc ) # expose header path, for when this is part of a larger cmake project -target_include_directories(utf8proc PUBLIC .) +target_include_directories(utf8proc PUBLIC $ $) if (BUILD_SHARED_LIBS) # Building shared library @@ -57,12 +57,16 @@ if (UTF8PROC_INSTALL) include(GNUInstallDirs) install(FILES utf8proc.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}") install(TARGETS utf8proc + EXPORT utf8proc-targets ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" ) configure_file(libutf8proc.pc.cmakein libutf8proc.pc @ONLY) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libutf8proc.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") + # Install CMake targets file. + install(EXPORT utf8proc-targets FILE utf8proc-targets.cmake DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/utf8proc" NAMESPACE utf8proc::) + endif() if(UTF8PROC_ENABLE_TESTING) From bd73cd02bbae9fa9f430ac1841a3ae10d6be0a89 Mon Sep 17 00:00:00 2001 From: Kevin Albertson Date: Sat, 13 Jan 2024 18:18:15 -0500 Subject: [PATCH 3/9] create and install package config file --- CMakeLists.txt | 11 +++++++++++ cmake/utf8proc-config.cmake.in | 5 +++++ 2 files changed, 16 insertions(+) create mode 100644 cmake/utf8proc-config.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 61da950..ff94dc2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,6 +66,17 @@ if (UTF8PROC_INSTALL) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libutf8proc.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") # Install CMake targets file. install(EXPORT utf8proc-targets FILE utf8proc-targets.cmake DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/utf8proc" NAMESPACE utf8proc::) + include (CMakePackageConfigHelpers) + configure_package_config_file( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/utf8proc-config.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/utf8proc-config.cmake" + INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/utf8proc" + NO_SET_AND_CHECK_MACRO + ) + install (FILES + "${CMAKE_CURRENT_BINARY_DIR}/utf8proc-config.cmake" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/utf8proc" + ) endif() diff --git a/cmake/utf8proc-config.cmake.in b/cmake/utf8proc-config.cmake.in new file mode 100644 index 0000000..b9149bc --- /dev/null +++ b/cmake/utf8proc-config.cmake.in @@ -0,0 +1,5 @@ +@PACKAGE_INIT@ +include("${CMAKE_CURRENT_LIST_DIR}/utf8proc-targets.cmake") +# `check_required_components` is used to ensure consumer did not erroneously request components. +# No components are currently defined. +check_required_components(utf8proc) From 4f5350bde3f8ba87d6f61fd9401033bb63937768 Mon Sep 17 00:00:00 2001 From: Kevin Albertson Date: Sat, 13 Jan 2024 18:46:34 -0500 Subject: [PATCH 4/9] install package version file --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index ff94dc2..3ba943a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,8 +73,13 @@ if (UTF8PROC_INSTALL) INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/utf8proc" NO_SET_AND_CHECK_MACRO ) + write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/utf8proc-config-version.cmake" + COMPATIBILITY AnyNewerVersion + ) install (FILES "${CMAKE_CURRENT_BINARY_DIR}/utf8proc-config.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/utf8proc-config-version.cmake" DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/utf8proc" ) From c3d388b2dd72b690dcc926c8847b46d8c697e5b6 Mon Sep 17 00:00:00 2001 From: Kevin Albertson Date: Mon, 15 Jan 2024 10:03:18 -0500 Subject: [PATCH 5/9] add `Using with CMake` instructions --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 2923e8c..14b3330 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,16 @@ cmake -S . -B build cmake --build build ``` +## Using with CMake + +A CMake Config-file package is provided. To use utf8proc in a CMake project: + +```cmake +add_executable (app app.c) +find_package (utf8proc 2.9.0 REQUIRED) +target_link_libraries (app PRIVATE utf8proc::utf8proc) +``` + ### Using other compilers The included `Makefile` supports GNU/Linux flavors and MacOS with `gcc`-like compilers; Windows users will typically use `cmake`. From 8e902deac87202eccdf4f3a9d21e0556fabcc89b Mon Sep 17 00:00:00 2001 From: Kevin Albertson Date: Fri, 7 Jun 2024 12:48:24 -0400 Subject: [PATCH 6/9] fix whitespace Co-authored-by: Sutou Kouhei --- CMakeLists.txt | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ba943a..ce85119 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,23 +66,22 @@ if (UTF8PROC_INSTALL) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libutf8proc.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") # Install CMake targets file. install(EXPORT utf8proc-targets FILE utf8proc-targets.cmake DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/utf8proc" NAMESPACE utf8proc::) - include (CMakePackageConfigHelpers) + include(CMakePackageConfigHelpers) configure_package_config_file( - "${CMAKE_CURRENT_SOURCE_DIR}/cmake/utf8proc-config.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/utf8proc-config.cmake" - INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/utf8proc" - NO_SET_AND_CHECK_MACRO + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/utf8proc-config.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/utf8proc-config.cmake" + INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/utf8proc" + NO_SET_AND_CHECK_MACRO ) write_basic_package_version_file( "${CMAKE_CURRENT_BINARY_DIR}/utf8proc-config-version.cmake" COMPATIBILITY AnyNewerVersion ) - install (FILES - "${CMAKE_CURRENT_BINARY_DIR}/utf8proc-config.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/utf8proc-config-version.cmake" - DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/utf8proc" + install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/utf8proc-config.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/utf8proc-config-version.cmake" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/utf8proc" ) - endif() if(UTF8PROC_ENABLE_TESTING) From 02388369f2388e8088dddd268c3786980091c5bc Mon Sep 17 00:00:00 2001 From: Kevin Albertson Date: Fri, 7 Jun 2024 12:56:22 -0400 Subject: [PATCH 7/9] change `AnyNewerVersion` to `SameMajorVersion` for version compatibility utf8proc appears to use SemVer. Do not consider different major versions compatible. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ce85119..b97c299 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,7 +75,7 @@ if (UTF8PROC_INSTALL) ) write_basic_package_version_file( "${CMAKE_CURRENT_BINARY_DIR}/utf8proc-config-version.cmake" - COMPATIBILITY AnyNewerVersion + COMPATIBILITY SameMajorVersion ) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/utf8proc-config.cmake" From afaa23c39e8523269c425936c27e4c61f0d509e0 Mon Sep 17 00:00:00 2001 From: Kevin Albertson Date: Fri, 7 Jun 2024 12:57:12 -0400 Subject: [PATCH 8/9] make `Using with CMake` a subsection of `Quick Start` --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 14b3330..79a6aa2 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ cmake -S . -B build cmake --build build ``` -## Using with CMake +### Using with CMake A CMake Config-file package is provided. To use utf8proc in a CMake project: From e3d29ea2ed251fee63bae20a78b23536fc27d90d Mon Sep 17 00:00:00 2001 From: Kevin Albertson Date: Fri, 7 Jun 2024 12:57:37 -0400 Subject: [PATCH 9/9] relocate `Using with CMake` --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 79a6aa2..1413871 100644 --- a/README.md +++ b/README.md @@ -42,16 +42,6 @@ cmake -S . -B build cmake --build build ``` -### Using with CMake - -A CMake Config-file package is provided. To use utf8proc in a CMake project: - -```cmake -add_executable (app app.c) -find_package (utf8proc 2.9.0 REQUIRED) -target_link_libraries (app PRIVATE utf8proc::utf8proc) -``` - ### Using other compilers The included `Makefile` supports GNU/Linux flavors and MacOS with `gcc`-like compilers; Windows users will typically use `cmake`. @@ -63,6 +53,16 @@ gmake CC=/opt/aCC/bin/aCC CFLAGS="+O2" PICFLAG="+z" C99FLAG="-Ae" WCFLAGS="+w" L ``` To run `gmake install` you will need GNU coreutils for the `install` command, and you may want to pass `prefix=/opt libdir=/opt/lib/hpux32` or similar to change the installation location. +### Using with CMake + +A CMake Config-file package is provided. To use utf8proc in a CMake project: + +```cmake +add_executable (app app.c) +find_package (utf8proc 2.9.0 REQUIRED) +target_link_libraries (app PRIVATE utf8proc::utf8proc) +``` + ## General Information The C library is found in this directory after successful compilation