From 1eadf99b609b7e4f4ef4e9b8e467a93f6fa2b8f4 Mon Sep 17 00:00:00 2001 From: sneurlax Date: Thu, 18 Jan 2024 10:41:10 -0600 Subject: [PATCH] Use find_file to find secp256k1.dll * use find_file to find secp256k1.dll because in testing we found that CMAKE_BINARY_DIR is usually app/build/windows/x64, but some Windows hosts use app/build/windows. This should support both force pushed to fix a small typo. * remove explicit references to secp256k1.dll * formatting limit lines to 180 characters, align comments --- coinlib_flutter/windows/CMakeLists.txt | 45 +++++++++++++++++++------- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/coinlib_flutter/windows/CMakeLists.txt b/coinlib_flutter/windows/CMakeLists.txt index 45bee62..c440a91 100644 --- a/coinlib_flutter/windows/CMakeLists.txt +++ b/coinlib_flutter/windows/CMakeLists.txt @@ -11,16 +11,39 @@ project(${PROJECT_NAME} LANGUAGES CXX) # Invoke the build for native code shared with the other target platforms. # This can be changed to accommodate different builds. # add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../src" "${CMAKE_CURRENT_BINARY_DIR}/shared") -# TODO re-enable the above line if/when the CMake process is made Windows-compatible. See also below. +# TODO re-enable the above line if/when the CMake process is made Windows-compatible. +# See also below. -# List of absolute paths to libraries that should be bundled with the plugin. -# This list could contain prebuilt libraries, or libraries created by an -# external build triggered from this build file. -set(coinlib_flutter_bundled_libraries - # Defined in ../src/CMakeLists.txt. - # This can be changed to accommodate different builds. - # $ - # TODO re-enable the above line if/when the CMake process is made Windows-compatible. See also above. - ${CMAKE_BINARY_DIR}/../../secp256k1.dll - PARENT_SCOPE +# Search for secp256k1.dll in multiple possible directories. +# +# This is only necessary because in testing we have found that most Windows hosts +# have CMAKE_BINARY_DIR = app/build/windows/x64, but some use app/build/windows. +# This should search through its multiple possible locations. +find_file(SECP256K1_DLL + NAMES secp256k1.dll + PATHS + "${CMAKE_BINARY_DIR}/../" # Check one level up. + "${CMAKE_BINARY_DIR}/../../" # Check two levels up. + "${CMAKE_BINARY_DIR}/../../../" # Used for the example app. + "${CMAKE_SOURCE_DIR}/../build" + "${CMAKE_SOURCE_DIR}/../../build" # Works for the example app. + NO_DEFAULT_PATH ) + +# Check if SECP256K1_DLL was found +if (SECP256K1_DLL) + # List of absolute paths to libraries that should be bundled with the plugin. + # This list could contain prebuilt libraries, or libraries created by an + # external build triggered from this build file. + set(coinlib_flutter_bundled_libraries + # Defined in ../src/CMakeLists.txt. + # This can be changed to accommodate different builds. + # $ + # TODO re-enable if/when the CMake process is made Windows-compatible. + # See also above. + ${SECP256K1_DLL} + PARENT_SCOPE + ) +else () + message(FATAL_ERROR "Could not find secp256k1.dll.") +endif ()