Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[openssl] Fix vcpkg-cmake-wrapper.cmake #18475

Merged
merged 19 commits into from
Jul 23, 2021

Conversation

PhoebeHui
Copy link
Contributor

@PhoebeHui PhoebeHui commented Jun 16, 2021

Fixes #18408

PR #18042 added a new vcpkg-cmake-wrapper.cmake which override the origin one under windows and unix folder, so merge the changes:
openssl/vcpkg-cmake-wrapper.cmake -> openssl/vcpkg-cmake-wrapper.cmake.in
openssl/windows/vcpkg-cmake-wrapper.cmake -> openssl/vcpkg-cmake-wrapper.cmake.in
openssl/unix/vcpkg-cmake-wrapper.cmake -> openssl/vcpkg-cmake-wrapper.cmake.in

@PhoebeHui PhoebeHui added category:port-bug The issue is with a library, which is something the port should already support info:internal This PR or Issue was filed by the vcpkg team. labels Jun 16, 2021
@PhoebeHui
Copy link
Contributor Author

@SpriteOvO, could you help test this PR?

@SpriteOvO
Copy link
Contributor

SpriteOvO commented Jun 16, 2021

I fetch this PR with the following method:

message("Fetching 'vcpkg'...")
FetchContent_Declare(
    vcpkg
    GIT_REPOSITORY "https://github.com/PhoebeHui/vcpkg.git"
    GIT_TAG "4545560ec03fd5ff28b4a580c2f47e09f781d65a"
)
FetchContent_MakeAvailable(vcpkg)

# bootstrap...

# find OpenSSL...

but the compilation still failed and I got same error messages.

...\out\build\x64-Debug\libcrypto.lib(e_capi.obj) : error LNK2019: unresolved external symbol __imp_CertOpenStore referenced in function capi_list_certs 
...\out\build\x64-Debug\libcrypto.lib(e_capi.obj) : error LNK2019: unresolved external symbol __imp_CertCloseStore referenced in function capi_find_key 
...\out\build\x64-Debug\libcrypto.lib(e_capi.obj) : error LNK2019: unresolved external symbol __imp_CertEnumCertificatesInStore referenced in function capi_find_cert 
...\out\build\x64-Debug\libcrypto.lib(e_capi.obj) : error LNK2019: unresolved external symbol __imp_CertFindCertificateInStore referenced in function capi_find_cert 
...\out\build\x64-Debug\libcrypto.lib(e_capi.obj) : error LNK2019: unresolved external symbol __imp_CertDuplicateCertificateContext referenced in function capi_load_ssl_client_cert 
...\out\build\x64-Debug\libcrypto.lib(e_capi.obj) : error LNK2019: unresolved external symbol __imp_CertFreeCertificateContext referenced in function capi_dsa_free 
...\out\build\x64-Debug\libcrypto.lib(e_capi.obj) : error LNK2019: unresolved external symbol __imp_CertGetCertificateContextProperty referenced in function capi_cert_get_fname 
...\out\build\x64-Debug\xxx.exe : fatal error LNK1120: 7 unresolved externals 

@Neumann-A
Copy link
Contributor

@SpriteOvO Clean reconfigure?

@SpriteOvO
Copy link
Contributor

@SpriteOvO Clean reconfigure?

Yes, I tried twice and deleted the CMake cache both times.

@PhoebeHui
Copy link
Contributor Author

@SpriteOvO, I double confirmed the Crypt32.lib;ws2_32.lib have added to %AdditionalDependencies% in project file, so it should work, I suspect you haven't get these changes, you can check if these in installed\x64-windows-static\share\openssl\vcpkg-cmake-wrapper.cmake file maually.

@SpriteOvO
Copy link
Contributor

@PhoebeHui I checked that file and it has the same content as the latest commit in your PR branch.

I created a new project to test the master branch and your PR branch and they both work fine, the problem only occurs in the project I'm currently developing. Maybe some other stuff screwed it up, I'll do some investigating.

BTW, I got a warning warning: vcpkg appears to be in a Visual Studio prompt targeting x86 but is installing packages for x64-windows-static. Consider using --triplet x86-windows or --triplet x86-uwp. in the project I'm developing, but I always compile it in x64, could this be related to this issue?

@SpriteOvO
Copy link
Contributor

SpriteOvO commented Jun 17, 2021

The warning only appears if you are using Visual Studio 16 2019 Win64 as the generator, changing it to Ninja will remove the warning.
Link errors are not related to the warning, but I found that it is related to the third-party library asio, which is 100% reproducible if I include the <asio/ssl.hpp> header file.

I'm sorry I didn't figure out these details earlier.

CMakeLists.txt:

cmake_minimum_required(VERSION 3.20)

include(FetchContent)

project(vcpkg_issue_18408)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)

# vcpkg
#
message("Fetching 'vcpkg'...")
FetchContent_Declare(
    vcpkg
    GIT_REPOSITORY "https://github.com/PhoebeHui/vcpkg.git"
    GIT_TAG "86418e5b882e5dc59d15a39402d23193b64c94f8"
)
FetchContent_MakeAvailable(vcpkg)
message("Fetch 'vcpkg' done.")
message("Bootstrapping 'vcpkg'...")
if (MSVC)
    execute_process(
        COMMAND powershell ./bootstrap-vcpkg.bat -disableMetrics
        WORKING_DIRECTORY ${vcpkg_SOURCE_DIR}
        COMMAND_ECHO STDOUT
    )
    if (NOT EXISTS "${vcpkg_SOURCE_DIR}/vcpkg.exe")
        message(FATAL_ERROR "Bootstrap 'vcpkg' failed.")
    endif()
else()
    message(FATAL_ERROR "Need to port.")
endif()
message("Bootstrap 'vcpkg' done.")
include("${vcpkg_SOURCE_DIR}/scripts/buildsystems/vcpkg.cmake")

# OpenSSL
#
message("Installing 'OpenSSL'...")
execute_process(
    COMMAND powershell ./vcpkg.exe install openssl:x64-windows-static
    WORKING_DIRECTORY ${vcpkg_SOURCE_DIR}
    COMMAND_ECHO STDOUT
)
set(OPENSSL_ROOT_DIR PATH "${vcpkg_SOURCE_DIR}/installed/x64-windows-static")
set(OPENSSL_USE_STATIC_LIBS BOOL TRUE)
find_package(OpenSSL REQUIRED)
message("Install 'OpenSSL' done.")

# asio
#
message("Fetching 'asio'...")
FetchContent_Declare(
    asio
    GIT_REPOSITORY "https://github.com/chriskohlhoff/asio.git"
    GIT_TAG "asio-1-18-2"
)
FetchContent_MakeAvailable(asio)
message("Fetch 'asio' done.")

add_executable(
    vcpkg_issue_18408
    
    main.cpp
)

target_include_directories(
    vcpkg_issue_18408 PRIVATE

    "${asio_SOURCE_DIR}/asio/include"
)

target_link_libraries(
    vcpkg_issue_18408 PRIVATE

    OpenSSL::SSL OpenSSL::Crypto
)

main.cpp:

#include <openssl/sha.h>
#include <asio.hpp>
#include <asio/ssl.hpp>


int main()
{
    return 0;
}

@PhoebeHui
Copy link
Contributor Author

warning: vcpkg appears to be in a Visual Studio prompt targeting x86 but is installing packages for x64-windows-static

@SpriteOvO, it looks you need change your configuration to x64 in your VS project, or change to x64 visual Studio prompt.

@SpriteOvO
Copy link
Contributor

@PhoebeHui The configuration is always x64-Debug.
image

and this is the full CMake output:

1> CMake generation started for configuration: 'x64-Debug'.
1> Command line: "C:\WINDOWS\system32\cmd.exe" /c "%SYSTEMROOT%\System32\chcp.com 65001 >NUL && "D:\MICROSOFT VISUAL STUDIO\2019\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe"  -G "Visual Studio 16 2019" -A x64  -DCMAKE_CONFIGURATION_TYPES:STRING="Debug" -DCMAKE_INSTALL_PREFIX:PATH="<ProjectDir>\vcpkg_issue_18408_\out\install\x64-Debug"  "<ProjectDir>\vcpkg_issue_18408_" 2>&1"
1> Working directory: <ProjectDir>\vcpkg_issue_18408_\out\build\x64-Debug
1> [CMake] -- Selecting Windows SDK version 10.0.20348.0 to target Windows 10.0.19042.
1> [CMake] -- The C compiler identification is MSVC 19.29.30038.1
1> [CMake] -- The CXX compiler identification is MSVC 19.29.30038.1
1> [CMake] -- Detecting C compiler ABI info
1> [CMake] -- Detecting C compiler ABI info - done
1> [CMake] -- Check for working C compiler: D:/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30037/bin/Hostx64/x64/cl.exe - skipped
1> [CMake] -- Detecting C compile features
1> [CMake] -- Detecting C compile features - done
1> [CMake] -- Detecting CXX compiler ABI info
1> [CMake] -- Detecting CXX compiler ABI info - done
1> [CMake] -- Check for working CXX compiler: D:/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30037/bin/Hostx64/x64/cl.exe - skipped
1> [CMake] -- Detecting CXX compile features
1> [CMake] -- Detecting CXX compile features - done
1> [CMake] Fetching 'vcpkg'...
1> [CMake] Fetch 'vcpkg' done.
1> [CMake] Bootstrapping 'vcpkg'...
1> [CMake] 'powershell' './bootstrap-vcpkg.bat' '-disableMetrics'
1> [CMake] Downloading https://github.com/microsoft/vcpkg-tool/releases/download/2021-05-05-9f849c4c43e50d1b16186ae76681c27b0c1be9d9/vcpkg.exe -> <ProjectDir>\vcpkg_issue_18408_\out\build\x64-Debug\_deps\vcpkg-src\vcpkg.exe (using proxy: localhost:7890)
1> [CMake] Done.
1> [CMake] 
1> [CMake] Bootstrap 'vcpkg' done.
1> [CMake] Installing 'OpenSSL'...
1> [CMake] 'powershell' './vcpkg.exe' 'install' 'openssl:x64-windows-static'
1> [CMake] Computing installation plan...
1> [CMake] warning: vcpkg appears to be in a Visual Studio prompt targeting x86 but is installing packages for x64-windows-static. Consider using --triplet x86-windows or --triplet x86-uwp.
1> [CMake] The following packages will be built and installed:
1> [CMake]     openssl[core]:x64-windows-static -> 1.1.1k#6
1> [CMake] Detecting compiler hash for triplet x64-windows-static...
1> [CMake] -- Automatically setting HTTP(S)_PROXY environment variables to 127.0.0.1:7890
1> [CMake] A suitable version of powershell-core was not found (required v7.1.0). Downloading portable powershell-core v7.1.0...
1> [CMake] Downloading powershell-core...
1> [CMake]   https://github.com/PowerShell/PowerShell/releases/download/v7.1.3/PowerShell-7.1.3-win-x86.zip -> <ProjectDir>\vcpkg_issue_18408_\out\build\x64-Debug\_deps\vcpkg-src\downloads\PowerShell-7.1.3-win-x86.zip
1> [CMake] Extracting powershell-core...
1> [CMake] A suitable version of 7zip was not found (required v18.1.0). Downloading portable 7zip v18.1.0...
1> [CMake] Downloading 7zip...
1> [CMake]   https://www.nuget.org/api/v2/package/7-Zip.CommandLine/18.1.0 -> <ProjectDir>\vcpkg_issue_18408_\out\build\x64-Debug\_deps\vcpkg-src\downloads\7-zip.commandline.18.1.0.nupkg
1> [CMake] Extracting 7zip...
1> [CMake] A suitable version of nuget was not found (required v5.9.0). Downloading portable nuget v5.9.0...
1> [CMake] Downloading nuget...
1> [CMake]   https://dist.nuget.org/win-x86-commandline/v5.9.1/nuget.exe -> <ProjectDir>\vcpkg_issue_18408_\out\build\x64-Debug\_deps\vcpkg-src\downloads\d7acca2b-nuget.exe
1> [CMake] Could not locate cached archive: C:\Users\<UserName>\AppData\Local\vcpkg\archives\e7\e72c4199513659303a3669416877f34adb10bfe2.zip
1> [CMake] Starting package 1/1: openssl:x64-windows-static
1> [CMake] Building package openssl[core]:x64-windows-static...
1> [CMake] -- Downloading https://www.openssl.org/source/openssl-1.1.1k.tar.gz;https://www.openssl.org/source/old/1.1.1/openssl-1.1.1k.tar.gz -> openssl-1.1.1k.tar.gz...
1> [CMake] -- Downloading https://strawberryperl.com/download/5.30.0.1/strawberry-perl-5.30.0.1-32bit.zip -> strawberry-perl-5.30.0.1-32bit.zip...
1> [CMake] -- Extracting source <ProjectDir>/vcpkg_issue_18408_/out/build/x64-Debug/_deps/vcpkg-src/downloads/openssl-1.1.1k.tar.gz
1> [CMake] -- Using source at <ProjectDir>/vcpkg_issue_18408_/out/build/x64-Debug/_deps/vcpkg-src/buildtrees/openssl/src/openssl-1-a1ae8b796e.clean
1> [CMake] -- Downloading https://www.nasm.us/pub/nasm/releasebuilds/2.15.05/win32/nasm-2.15.05-win32.zip;https://fossies.org/windows/misc/nasm-2.15.05-win32.zip -> nasm-2.15.05-win32.zip...
1> [CMake] -- Downloading https://download.qt.io/official_releases/jom/jom_1_1_3.zip;https://mirrors.ocf.berkeley.edu/qt/official_releases/jom/jom_1_1_3.zip -> jom_1_1_3.zip...
1> [CMake] -- Copying openssl release source files...
1> [CMake] -- Copying openssl release source files... done
1> [CMake] -- Configure x64-windows-static-rel
1> [CMake] -- Configure x64-windows-static-rel done
1> [CMake] -- Build x64-windows-static-rel
1> [CMake] -- Build x64-windows-static-rel done
1> [CMake] -- Copying openssl debug source files...
1> [CMake] -- Copying openssl debug source files... done
1> [CMake] -- Configure x64-windows-static-dbg
1> [CMake] -- Configure x64-windows-static-dbg done
1> [CMake] -- Build x64-windows-static-dbg
1> [CMake] -- Build x64-windows-static-dbg done
1> [CMake] -- Installing: <ProjectDir>/vcpkg_issue_18408_/out/build/x64-Debug/_deps/vcpkg-src/packages/openssl_x64-windows-static/share/openssl/copyright
1> [CMake] -- Installing: <ProjectDir>/vcpkg_issue_18408_/out/build/x64-Debug/_deps/vcpkg-src/packages/openssl_x64-windows-static/share/openssl/usage
1> [CMake] -- Performing post-build validation
1> [CMake] -- Performing post-build validation done
1> [CMake] Stored binary cache: C:\Users\<UserName>\AppData\Local\vcpkg\archives\e7\e72c4199513659303a3669416877f34adb10bfe2.zip
1> [CMake] Building package openssl[core]:x64-windows-static... done
1> [CMake] Installing package openssl[core]:x64-windows-static...
1> [CMake] Installing package openssl[core]:x64-windows-static... done
1> [CMake] Elapsed time for package openssl:x64-windows-static: 1.596 min
1> [CMake] 
1> [CMake] Total elapsed time: 2.249 min
1> [CMake] 
1> [CMake] The package openssl is compatible with built-in CMake targets:
1> [CMake] 
1> [CMake] 
1> [CMake] 
1> [CMake]     find_package(OpenSSL REQUIRED)
1> [CMake] 
1> [CMake]     target_link_libraries(main PRIVATE OpenSSL::SSL OpenSSL::Crypto)
1> [CMake] 
1> [CMake] 
1> [CMake] -- Found OpenSSL: <ProjectDir>/vcpkg_issue_18408_/out/build/x64-Debug/_deps/vcpkg-src/installed/x64-windows-static/lib/libcrypto.lib (found version "1.1.1k")  
1> [CMake] Install 'OpenSSL' done.
1> [CMake] Fetching 'asio'...
1> [CMake] Fetch 'asio' done.
1> [CMake] -- Configuring done
1> [CMake] -- Generating done
1> [CMake] -- Build files have been written to: <ProjectDir>/vcpkg_issue_18408_/out/build/x64-Debug
1> Extracted CMake variables.
1> Extracted source files and headers.
1> Extracted code model.
1> Extracted toolchain configurations.
1> Extracted includes paths.
1> CMake generation finished.

@PhoebeHui
Copy link
Contributor Author

@SpriteOvO, this is unrelated to the changes, could you please report an issue with repro steps and full failure logs instead?

@SpriteOvO
Copy link
Contributor

@PhoebeHui Sure, I will do it later.

@JackBoosY JackBoosY added the info:reviewed Pull Request changes follow basic guidelines label Jun 18, 2021
@JackBoosY JackBoosY removed the info:reviewed Pull Request changes follow basic guidelines label Jun 22, 2021
@JackBoosY
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@JackBoosY JackBoosY added the info:reviewed Pull Request changes follow basic guidelines label Jun 30, 2021
@PhoebeHui
Copy link
Contributor Author

@vicroms, could you help merge this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:port-bug The issue is with a library, which is something the port should already support info:internal This PR or Issue was filed by the vcpkg team. info:reviewed Pull Request changes follow basic guidelines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[OpenSSL] build failure
7 participants