From 877b237f6f22fdc098051f550c7b9dcf26afe3ec Mon Sep 17 00:00:00 2001 From: devel71 Date: Fri, 25 Nov 2016 11:40:29 +0100 Subject: [PATCH] initial commit to qca branch --- ports/qca/0001-fix-path-for-vcpkg.patch | 54 ++++++++++++++ ports/qca/CONTROL | 3 + ports/qca/portfile.cmake | 97 +++++++++++++++++++++++++ ports/qca/qca_load_qtenv.cmake | 40 ++++++++++ 4 files changed, 194 insertions(+) create mode 100644 ports/qca/0001-fix-path-for-vcpkg.patch create mode 100644 ports/qca/CONTROL create mode 100644 ports/qca/portfile.cmake create mode 100644 ports/qca/qca_load_qtenv.cmake diff --git a/ports/qca/0001-fix-path-for-vcpkg.patch b/ports/qca/0001-fix-path-for-vcpkg.patch new file mode 100644 index 0000000000..b48fee18f9 --- /dev/null +++ b/ports/qca/0001-fix-path-for-vcpkg.patch @@ -0,0 +1,54 @@ +From bab44a6614d4a540af56860432bcc0d6bdf420c9 Mon Sep 17 00:00:00 2001 +From: devel +Date: Wed, 23 Nov 2016 16:54:44 +0100 +Subject: [PATCH] fix path for vcpkg + +--- + CMakeLists.txt | 16 ++++++++-------- + 1 file changed, 8 insertions(+), 8 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 605621b..a8c3774 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -277,7 +277,7 @@ if(DEVELOPER_MODE) + # To prefer plugins from build tree when run qca from build tree + file(WRITE ${CMAKE_BINARY_DIR}/bin/qt.conf + "[Paths] +-Plugins=${CMAKE_BINARY_DIR}/lib/${QCA_LIB_NAME} ++Plugins=${CMAKE_BINARY_DIR}/bin/${QCA_LIB_NAME} + ") + endif() + +@@ -401,10 +401,10 @@ endif(DOXYGEN_FOUND) + include(CMakePackageConfigHelpers) + configure_package_config_file( + "${CMAKE_CURRENT_SOURCE_DIR}/QcaConfig.cmake.in" +- "${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/${QCA_CONFIG_NAME_BASE}/${QCA_CONFIG_NAME_BASE}Config.cmake" +- INSTALL_DESTINATION ${QCA_LIBRARY_INSTALL_DIR}/cmake/${QCA_CONFIG_NAME_BASE} ++ "${CMAKE_CURRENT_BINARY_DIR}/share/cmake/${QCA_CONFIG_NAME_BASE}/${QCA_CONFIG_NAME_BASE}Config.cmake" ++ INSTALL_DESTINATION ${CMAKE_BINARY_DIR}/share/cmake/${QCA_CONFIG_NAME_BASE} + ) +-write_basic_config_version_file("${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/${QCA_CONFIG_NAME_BASE}/${QCA_CONFIG_NAME_BASE}ConfigVersion.cmake" VERSION ${QCA_LIB_VERSION_STRING} COMPATIBILITY AnyNewerVersion) ++write_basic_config_version_file("${CMAKE_BINARY_DIR}/share/cmake/${QCA_CONFIG_NAME_BASE}/${QCA_CONFIG_NAME_BASE}ConfigVersion.cmake" VERSION ${QCA_LIB_VERSION_STRING} COMPATIBILITY AnyNewerVersion) + + if(NOT DEVELOPER_MODE) + +@@ -472,10 +472,10 @@ if(NOT DEVELOPER_MODE) + endif() + endif() + +- install(EXPORT ${QCA_CONFIG_NAME_BASE}Targets DESTINATION ${QCA_LIBRARY_INSTALL_DIR}/cmake/${QCA_CONFIG_NAME_BASE} FILE ${QCA_CONFIG_NAME_BASE}Targets.cmake) ++ install(EXPORT ${QCA_CONFIG_NAME_BASE}Targets DESTINATION ${QCA_PREFIX_INSTALL_DIR}/share/cmake/${QCA_CONFIG_NAME_BASE} FILE ${QCA_CONFIG_NAME_BASE}Targets.cmake) + install(FILES +- "${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/${QCA_CONFIG_NAME_BASE}/${QCA_CONFIG_NAME_BASE}Config.cmake" +- "${CMAKE_CURRENT_BINARY_DIR}/lib/cmake/${QCA_CONFIG_NAME_BASE}/${QCA_CONFIG_NAME_BASE}ConfigVersion.cmake" +- DESTINATION ${QCA_LIBRARY_INSTALL_DIR}/cmake/${QCA_CONFIG_NAME_BASE} ++ "${CMAKE_CURRENT_BINARY_DIR}/share/cmake/${QCA_CONFIG_NAME_BASE}/${QCA_CONFIG_NAME_BASE}Config.cmake" ++ "${CMAKE_CURRENT_BINARY_DIR}/share/cmake/${QCA_CONFIG_NAME_BASE}/${QCA_CONFIG_NAME_BASE}ConfigVersion.cmake" ++ DESTINATION ${QCA_PREFIX_INSTALL_DIR}/share/cmake/${QCA_CONFIG_NAME_BASE} + ) + endif() +-- +2.9.2.windows.1 + diff --git a/ports/qca/CONTROL b/ports/qca/CONTROL new file mode 100644 index 0000000000..84465481a1 --- /dev/null +++ b/ports/qca/CONTROL @@ -0,0 +1,3 @@ +Source: qca +Version: 2.2.0 +Description: Qt Cryptographic Api (QCA) diff --git a/ports/qca/portfile.cmake b/ports/qca/portfile.cmake new file mode 100644 index 0000000000..cc391b517e --- /dev/null +++ b/ports/qca/portfile.cmake @@ -0,0 +1,97 @@ +# For now only x[64|86]-windows triplet and dynamic linking is supported +# + +if (VCPKG_LIBRARY_LINKAGE STREQUAL static) + message(STATUS "Warning: Static building not supported yet. Building dynamic.") + set(VCPKG_LIBRARY_LINKAGE dynamic) +endif() + +include(vcpkg_common_functions) +include(${CMAKE_CURRENT_LIST_DIR}/qca_load_qtenv.cmake) + +find_program(GIT git) + +# Set git variables to qca version 2.2.0 commit +set(GIT_URL "git://anongit.kde.org/qca.git") +set(GIT_REF "19ec49f89a0a560590ec733c549b92e199792837") # Commit + +# Prepare source dir +if(NOT EXISTS "${DOWNLOADS}/qca.git") + message(STATUS "Cloning") + vcpkg_execute_required_process( + COMMAND ${GIT} clone --bare ${GIT_URL} ${DOWNLOADS}/qca.git + WORKING_DIRECTORY ${DOWNLOADS} + LOGNAME clone + ) +endif() +message(STATUS "Cloning done") + +if(NOT EXISTS "${CURRENT_BUILDTREES_DIR}/src/.git") + message(STATUS "Adding worktree") + file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}) + vcpkg_execute_required_process( + COMMAND ${GIT} worktree add -f --detach ${CURRENT_BUILDTREES_DIR}/src ${GIT_REF} + WORKING_DIRECTORY ${DOWNLOADS}/qca.git + LOGNAME worktree + ) +endif() +message(STATUS "Adding worktree done") + +set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/) + +# Apply the patch to install 'crypto' and 'cmake targets' folder +vcpkg_apply_patches( + SOURCE_PATH ${SOURCE_PATH} + PATCHES ${CMAKE_CURRENT_LIST_DIR}/0001-fix-path-for-vcpkg.patch +) + +vcpkg_configure_cmake( + SOURCE_PATH ${SOURCE_PATH} + CURRENT_PACKAGES_DIR ${CURRENT_PACKAGES_DIR} + OPTIONS + #-DSOURCE=${SOURCE_PATH} + -DBUILD_SHARED_LIBS=ON + -DUSE_RELATIVE_PATHS=ON + -DQT4_BUILD=OFF + -DBUILD_TESTS=OFF + -DBUILD_TOOLS=OFF + -DQCA_SUFFIX=qt5 + OPTIONS_DEBUG + -DQCA_PLUGINS_INSTALL_DIR=${CURRENT_PACKAGES_DIR}/debug/bin/Qca-qt5 + OPTIONS_RELEASE + -DQCA_PLUGINS_INSTALL_DIR=${CURRENT_PACKAGES_DIR}/bin/Qca-qt5 +) + +vcpkg_install_cmake() + +message(STATUS "Patching files") + +file(RENAME + ${CURRENT_PACKAGES_DIR}/debug/share/cmake/Qca-qt5/Qca-qt5Targets-debug.cmake + ${CURRENT_PACKAGES_DIR}/share/cmake/Qca-qt5/Qca-qt5Targets-debug.cmake +) + +set(T_DEBUG ${CURRENT_PACKAGES_DIR}/share/cmake/Qca-qt5/Qca-qt5Targets-debug.cmake) +set(T_TARGETS ${CURRENT_PACKAGES_DIR}/share/cmake/Qca-qt5/Qca-qt5Targets.cmake) + +file(READ ${T_DEBUG} QCA_DEBUG_CONFIG) +string(REPLACE "\${_IMPORT_PREFIX}" "\${_IMPORT_PREFIX}/debug" QCA_DEBUG_CONFIG "${QCA_DEBUG_CONFIG}") +file(WRITE ${T_DEBUG} "${QCA_DEBUG_CONFIG}") + +file(READ ${T_TARGETS} QCA_TARGET_CONFIG) +string(REPLACE "packages/qca_" "installed/" QCA_TARGET_CONFIG "${QCA_TARGET_CONFIG}") +file(WRITE ${T_TARGETS} "${QCA_TARGET_CONFIG}") + +# Remove unneeded dirs +file(REMOVE_RECURSE + ${CURRENT_BUILDTREES_DIR}/share/man + ${CURRENT_PACKAGES_DIR}/share/man + ${CURRENT_PACKAGES_DIR}/debug/include + ${CURRENT_PACKAGES_DIR}/debug/share +) + +message(STATUS "Patching files done") + +# Handle copyright +file(COPY ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/qca) +file(RENAME ${CURRENT_PACKAGES_DIR}/share/qca/COPYING ${CURRENT_PACKAGES_DIR}/share/qca/copyright) diff --git a/ports/qca/qca_load_qtenv.cmake b/ports/qca/qca_load_qtenv.cmake new file mode 100644 index 0000000000..ee2eb96967 --- /dev/null +++ b/ports/qca/qca_load_qtenv.cmake @@ -0,0 +1,40 @@ +# TODO: Better way to find Qt5 dir +# + +set(_QT5_FOUND FALSE) + +# Already available? +find_package(Qt5Core QUIET) +if(Qt5Core_FOUND) + message(STATUS "Qt5 found by CMake. Version: " ${Qt5Core_VERSION}) + set(_QT5_FOUND TRUE) + return() + +elseif(NOT Qt5Core_FOUND) + # Try to find Qt in the Windows Registry (just msvc2015 and msvc2015_64 for now) + if(${TRIPLET_SYSTEM_ARCH} STREQUAL "x86") + set(_QTKEY "HKEY_CURRENT_USER\\SOFTWARE\\Digia\\Versions\\msvc2015") + elseif(${TRIPLET_SYSTEM_ARCH} STREQUAL "x64") + set(_QTKEY "HKEY_CURRENT_USER\\SOFTWARE\\Digia\\Versions\\msvc2015_64") + endif() + get_filename_component(_QTPATH "[${_QTKEY};InstallDir]" ABSOLUTE) + if(NOT ${_QTPATH} STREQUAL "/registry") # Path should be ok + message(STATUS "Qt found in the registry: ${_QTPATH}") + set(QT5 ${_QTPATH}) + set(_QT5_FOUND TRUE) + endif() +endif(Qt5Core_FOUND) + +if((NOT _QT5_FOUND) AND (NOT DEFINED $ENV{QT5})) + message(STATUS " ") + message(STATUS "QT5 not found.") + message(STATUS "Please set the path to the Qt5 ${TRIPLET_SYSTEM_ARCH} toolchain dir for this session with f. e.:") + message(STATUS " \$env:QT5 = \"path\\to\\Qt\\msvc[_64]\"") + message(FATAL_ERROR "") +elseif(_QT5_FOUND AND (${TARGET_TRIPLET} STREQUAL "x64-windows" OR ${TARGET_TRIPLET} STREQUAL "x86-windows")) + #message(STATUS "Using Qt5: ${QT5}") + #set(ENV{QTDIR} ${QT5}) + set(ENV{PATH} "${QT5}/bin;$ENV{PATH}") +else() + message(FATAL_ERROR "Target triplet: ${TARGET_TRIPLET} not supported yet.") +endif()