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

cmake: Set top-level target output locations #1553

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

hebasto
Copy link
Member

@hebasto hebasto commented Jun 26, 2024

While testing #1551, I noticed that when cross-compiling a shared library with examples for Windows, the ctest fails to run examples with Wine. Adjusting the PATH variable in

set_tests_properties(${test_name} PROPERTIES
ENVIRONMENT "PATH=$<TARGET_FILE_DIR:secp256k1>;$ENV{PATH}"
)
does not help because WINEPATH is expected.

Another issue with the current implementation is that the examples cannot run individually on Windows.

This PR resolves both issues by reverting the implementation from #1290 in favour of the reworked and improved implementation from #1233.

This change:
1. Collects build artifacts in dedicated locations.
2. Allows to run individual examples with a shared library on Windows.
3. Is compatible with Wine when testing cross-compiled Windows binaries
   on Linux.
4. Is compatible with integration the project into a larger project
   hierarchy.
Copy link
Contributor

@real-or-random real-or-random left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 3779472

It's probably a good idea that the binaries just work without the need to set a PATH. And it's okay to collect all binary artifacts in a single directory, we don't have that many.

@real-or-random
Copy link
Contributor

What are your commands for building on wine?

@hebasto
Copy link
Member Author

hebasto commented Jun 26, 2024

What are your commands for building on wine?

On Ubuntu 24.04 with the wine-binfmt package installed:

$ cmake -B build --toolchain cmake/x86_64-w64-mingw32.toolchain.cmake -DSECP256K1_BUILD_EXAMPLES=ON
$ cmake --build build
$ ctest --test-dir build
Internal ctest changing into directory: /home/hebasto/git/secp256k1/secp256k1/build
Test project /home/hebasto/git/secp256k1/secp256k1/build
    Start 1: noverify_tests
1/6 Test #1: noverify_tests ...................   Passed   52.72 sec
    Start 2: tests
2/6 Test #2: tests ............................   Passed  111.58 sec
    Start 3: exhaustive_tests
3/6 Test #3: exhaustive_tests .................   Passed    8.01 sec
    Start 4: ecdsa_example
4/6 Test #4: ecdsa_example ....................   Passed    1.35 sec
    Start 5: ecdh_example
5/6 Test #5: ecdh_example .....................   Passed    1.34 sec
    Start 6: schnorr_example
6/6 Test #6: schnorr_example ..................   Passed    1.32 sec

100% tests passed, 0 tests failed out of 6

Total Test time (real) = 176.31 sec
$ ./build/bin/schnorr_example.exe 
Is the signature valid? true
Secret Key: 0x964362f6515fbb691dee49b936c8ba46dadd505eb4aa27f5db9b1ccf510f04a8
Public Key: 0x286123fee26ecfc75ec8bd6d4e175a9b4fa729e7d2bcd4034661a33dee600d80
Signature: 0xef0aa23ae13fd06710e31204a7a8ab52f0b726159b3cb2344c090220ed32d6dda958c9f7b3383c3fa7524a7f7ed54bf381c8a3bab1f8561072887dae6bf7bfe1

@fanquake
Copy link
Member

implementation from #1233.

cc @theuni

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants