From 9294e18637aab60453bb17b29658490fe49c96db Mon Sep 17 00:00:00 2001 From: Yang Kun <91833768+ikspress@users.noreply.github.com> Date: Sat, 22 Jun 2024 23:23:40 +0800 Subject: [PATCH 1/3] Fix packaging issues on Windows --- CMakeLists.txt | 51 +++++++++++++++++++++++----------------- cmake/FixBundle.cmake.in | 11 --------- examples/CMakeLists.txt | 13 +++------- utils/CMakeLists.txt | 13 +++------- 4 files changed, 36 insertions(+), 52 deletions(-) delete mode 100644 cmake/FixBundle.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index a8605fa4..20e23143 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,9 +66,12 @@ ENDIF(LIBNFC_CONFFILES_MODE) option (BUILD_EXAMPLES "build examples ON/OFF" ON) option (BUILD_UTILS "build utils ON/OFF" ON) - option (BUILD_DEBPKG "build debian package ON/OFF" OFF) - +if(MSVC) + option (BUILD_MANUAL "build man-pages" OFF) +else(MSVC) + option (BUILD_MANUAL "build man-pages" ON) +endif(MSVC) # Doxygen SET(builddir "${CMAKE_BINARY_DIR}") @@ -126,28 +129,39 @@ IF(MINGW) ENDIF (NOT DLLTOOL) ENDIF(MINGW) +# Set some pkg-config variables +SET(prefix ${CMAKE_INSTALL_PREFIX}) +SET(exec_prefix ${CMAKE_INSTALL_PREFIX}) +SET(PACKAGE "libnfc") IF(NOT WIN32) - # Set some pkg-config variables - SET(prefix ${CMAKE_INSTALL_PREFIX}) - SET(exec_prefix ${CMAKE_INSTALL_PREFIX}) - SET(PACKAGE "libnfc") - IF(LIBNFC_DRIVER_PN53X_USB) - SET(PKG_REQ ${PKG_REQ} "libusb") - ENDIF(LIBNFC_DRIVER_PN53X_USB) - IF(LIBNFC_DRIVER_ACR122_USB) - SET(PKG_REQ ${PKG_REQ} "libusb") - ENDIF(LIBNFC_DRIVER_ACR122_USB) + IF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") + IF(LIBNFC_DRIVER_PN53X_USB) + SET(PKG_REQ ${PKG_REQ} "libusb-0.1") + ENDIF(LIBNFC_DRIVER_PN53X_USB) + IF(LIBNFC_DRIVER_ACR122_USB) + SET(PKG_REQ ${PKG_REQ} "libusb-0.1") + ENDIF(LIBNFC_DRIVER_ACR122_USB) + ELSEIF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") + IF(LIBNFC_DRIVER_PN53X_USB) + SET(PKG_REQ ${PKG_REQ} "libusb") + ENDIF(LIBNFC_DRIVER_PN53X_USB) + IF(LIBNFC_DRIVER_ACR122_USB) + SET(PKG_REQ ${PKG_REQ} "libusb") + ENDIF(LIBNFC_DRIVER_ACR122_USB) + ENDIF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") IF(LIBNFC_DRIVER_PCSC) SET(PKG_REQ ${PKG_REQ} "libpcsclite") ENDIF(LIBNFC_DRIVER_PCSC) IF(LIBNFC_DRIVER_ACR122_PCSC) SET(PKG_REQ ${PKG_REQ} "libpcsclite") ENDIF(LIBNFC_DRIVER_ACR122_PCSC) - # CMake lists are separated by a semi colon, replace with colon - STRING(REPLACE ";" "," PKG_CONFIG_REQUIRES "${PKG_REQ}") - CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/libnfc.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libnfc.pc @ONLY) - INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libnfc.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) ENDIF(NOT WIN32) +LIST(REMOVE_DUPLICATES PKG_REQ) +LIST(SORT PKG_REQ) +# CMake lists are separated by a semi colon, replace with colon +STRING(REPLACE ";" "," PKG_CONFIG_REQUIRES "${PKG_REQ}") +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/libnfc.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libnfc.pc @ONLY) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libnfc.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) INCLUDE(LibnfcDrivers) @@ -210,20 +224,15 @@ if (NOT MSVC) set ( LIBNFC_INCLUDE_DIR ${includedir} ) set ( LIBNFC_INCLUDE_DIRS ${LIBNFC_INCLUDE_DIR} ) - list ( APPEND LIBNFC_INCLUDE_DIRS ${LIBUSB_INCLUDE_DIRS} ) set ( LIBNFC_LIBRARY nfc ) set ( LIBNFC_LIBRARIES ${LIBNFC_LIBRARY} ) - list ( APPEND LIBNFC_LIBRARIES ${LIBUSB_LIBRARIES} ) set ( LIBNFC_LIBRARY_DIRS ${libdir} ) set ( LIBNFC_ROOT_DIR ${prefix} ) set ( LIBNFC_VERSION_STRING ${VERSION} ) set ( LIBNFC_VERSION_MAJOR ${VERSION_MAJOR} ) set ( LIBNFC_VERSION_MINOR ${VERSION_MINOR} ) set ( LIBNFC_VERSION_PATCH ${VERSION_PATCH} ) - set ( LIBNFC_USE_FILE ${CMAKE_INSTALL_PREFIX}/${LIBNFC_CMAKE_CONFIG_DIR}/UseLibNFC.cmake ) - - if(CMAKE_VERSION VERSION_LESS 2.8.8) configure_file ( cmake/LibNFCConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/LibNFCConfig.cmake @ONLY ) diff --git a/cmake/FixBundle.cmake.in b/cmake/FixBundle.cmake.in deleted file mode 100644 index 6e8f843d..00000000 --- a/cmake/FixBundle.cmake.in +++ /dev/null @@ -1,11 +0,0 @@ -INCLUDE(BundleUtilities) - -# set bundle to the full path of the executable already existing in the install tree -SET(bundle "${CMAKE_INSTALL_PREFIX}/bin/nfc-list@CMAKE_EXECUTABLE_SUFFIX@") - -# set other_libs to a list of additional libs that cannot be reached by dependency analysis -SET(other_libs "") - -SET(dirs "@LIBUSB_LIBRARY_DIR@") - -fixup_bundle("${bundle}" "${other_libs}" "${dirs}") diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 01a93c9b..1e9d7515 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -41,15 +41,8 @@ FOREACH(source ${EXAMPLES-SOURCES}) INSTALL(TARGETS ${source} RUNTIME DESTINATION bin COMPONENT examples) ENDFOREACH(source) -#install required libraries -IF(WIN32) - INCLUDE(InstallRequiredSystemLibraries) - CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/cmake/FixBundle.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/FixBundle.cmake @ONLY) - INSTALL(SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/FixBundle.cmake) -ENDIF(WIN32) - -IF(NOT WIN32) +IF(BUILD_MANUAL) # Manuals for the examples FILE(GLOB manuals "${CMAKE_CURRENT_SOURCE_DIR}/*.1") - INSTALL(FILES ${manuals} DESTINATION ${SHARE_INSTALL_PREFIX}/man/man1 COMPONENT manuals) -ENDIF(NOT WIN32) + INSTALL(FILES ${manuals} DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 COMPONENT manuals) +ENDIF(BUILD_MANUAL) diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index b9c723ea..5142109f 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -55,15 +55,8 @@ FOREACH(source ${UTILS-SOURCES}) INSTALL(TARGETS ${source} RUNTIME DESTINATION bin COMPONENT utils) ENDFOREACH(source) -#install required libraries -IF(WIN32) - INCLUDE(InstallRequiredSystemLibraries) - CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/cmake/FixBundle.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/FixBundle.cmake @ONLY) - INSTALL(SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/FixBundle.cmake) -ENDIF(WIN32) - -IF(NOT WIN32) +IF(BUILD_MANUAL) # Manuals for the examples FILE(GLOB manuals "${CMAKE_CURRENT_SOURCE_DIR}/*.1") - INSTALL(FILES ${manuals} DESTINATION ${SHARE_INSTALL_PREFIX}/man/man1 COMPONENT manuals) -ENDIF(NOT WIN32) + INSTALL(FILES ${manuals} DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 COMPONENT manuals) +ENDIF(BUILD_MANUAL) From d90a86661f754c5a6c4b1c55f4f775209da3f781 Mon Sep 17 00:00:00 2001 From: Yang Kun <91833768+ikspress@users.noreply.github.com> Date: Mon, 24 Jun 2024 23:34:35 +0800 Subject: [PATCH 2/3] Use GNUInstallDirs --- CMakeLists.txt | 20 +++----------------- include/nfc/CMakeLists.txt | 2 +- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 20e23143..54813519 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,23 +78,7 @@ SET(builddir "${CMAKE_BINARY_DIR}") SET(top_srcdir "${CMAKE_SOURCE_DIR}") INCLUDE(UseDoxygen) -IF(DEFINED CMAKE_INSTALL_LIBDIR) - SET(libdir ${CMAKE_INSTALL_LIBDIR}) -ELSE(DEFINED CMAKE_INSTALL_LIBDIR) - SET(CMAKE_INSTALL_LIBDIR lib) - SET(libdir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}) -ENDIF(DEFINED CMAKE_INSTALL_LIBDIR) - -IF(DEFINED INCLUDE_INSTALL_DIR) - SET(includedir ${INCLUDE_INSTALL_DIR}) -ELSE(DEFINED INCLUDE_INSTALL_DIR) - SET(INCLUDE_INSTALL_DIR include) - SET(includedir ${CMAKE_INSTALL_PREFIX}/${INCLUDE_INSTALL_DIR}) -ENDIF(DEFINED INCLUDE_INSTALL_DIR) - -IF(NOT DEFINED SHARE_INSTALL_PREFIX) - SET(SHARE_INSTALL_PREFIX share) -ENDIF(NOT DEFINED SHARE_INSTALL_PREFIX) +INCLUDE(GNUInstallDirs) # Additonnal GCC flags IF(CMAKE_COMPILER_IS_GNUCC) @@ -132,6 +116,8 @@ ENDIF(MINGW) # Set some pkg-config variables SET(prefix ${CMAKE_INSTALL_PREFIX}) SET(exec_prefix ${CMAKE_INSTALL_PREFIX}) +SET(libdir ${CMAKE_INSTALL_LIBDIR}) +SET(includedir ${CMAKE_INSTALL_INSTALLDIR}) SET(PACKAGE "libnfc") IF(NOT WIN32) IF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") diff --git a/include/nfc/CMakeLists.txt b/include/nfc/CMakeLists.txt index c11d4794..568baa44 100644 --- a/include/nfc/CMakeLists.txt +++ b/include/nfc/CMakeLists.txt @@ -1,4 +1,4 @@ # Headers FILE(GLOB headers "${CMAKE_CURRENT_SOURCE_DIR}/*.h") -INSTALL(FILES ${headers} DESTINATION ${INCLUDE_INSTALL_DIR}/nfc COMPONENT headers) +INSTALL(FILES ${headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/nfc COMPONENT headers) From 70aab3a250d87bcc0806a297a6260cd1cf4fc8ec Mon Sep 17 00:00:00 2001 From: Yang Kun <91833768+ikspress@users.noreply.github.com> Date: Tue, 25 Jun 2024 18:03:01 +0800 Subject: [PATCH 3/3] Fix variable --- CMakeLists.txt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 54813519..aa3f79f9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,6 +78,11 @@ SET(builddir "${CMAKE_BINARY_DIR}") SET(top_srcdir "${CMAKE_SOURCE_DIR}") INCLUDE(UseDoxygen) +SET(prefix ${CMAKE_INSTALL_PREFIX}) +SET(exec_prefix ${CMAKE_INSTALL_PREFIX}) +SET(libdir ${CMAKE_INSTALL_LIBDIR}) +SET(includedir ${CMAKE_INSTALL_INSTALLDIR}) + INCLUDE(GNUInstallDirs) # Additonnal GCC flags @@ -113,11 +118,7 @@ IF(MINGW) ENDIF (NOT DLLTOOL) ENDIF(MINGW) -# Set some pkg-config variables -SET(prefix ${CMAKE_INSTALL_PREFIX}) -SET(exec_prefix ${CMAKE_INSTALL_PREFIX}) -SET(libdir ${CMAKE_INSTALL_LIBDIR}) -SET(includedir ${CMAKE_INSTALL_INSTALLDIR}) +# pkg-config SET(PACKAGE "libnfc") IF(NOT WIN32) IF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")