MarkusJx / install-boost

Install boost on Github actions
MIT License
62 stars 3 forks source link

find_package with Boost not working... #7

Closed MichaelVoelkel closed 2 years ago

MichaelVoelkel commented 2 years ago

Hi,

thanks for the other answer, it was really helpful!

I have tried for some time getting this to run with CMake find_package Boost now on a Windows runner (windows-latest), but encounter some problems. I see in stage/lib that there are tons of lib files after your download action, which is great. But providing BOOST_ROOT into CMake does not seem to be enough for find_package to actually find boost (in particular, I have find_package(Boost REQUIRED thread)). It will always tell me:

Could NOT find Boost (missing: Boost_INCLUDE_DIR thread)

Trying to run find_package in debug did not really help because it just gave tons of output that it looked for tons of specific boost lib files...

I also checked that BOOST_ROOT is really in CMake (used message to give me own debug output), but it was correctly set...

Any idea? This is probably on this damn cmake find_package but maybe I get lucky here...

Edit: Hm, running it on a bare repository gives:

See also "D:/a/github-action-tests/github-action-tests/build/CMakeFiles/CMakeOutput.log".
29
  considered to be NOT FOUND.  Reason given by package:
30

31
  No suitable build variant has been found.
32

33
  The following variants have been tried and rejected:
34

35
  * libboost_thread-vc141-mt-gd-x32-1_72.lib (32 bit, need 64)
36

37
  * libboost_thread-vc141-mt-gd-x64-1_72.lib (vc141, detected vc142, set
38
  Boost_COMPILER to override)
39

40
  * libboost_thread-vc141-mt-x32-1_72.lib (32 bit, need 64)
41

42
  * libboost_thread-vc141-mt-x64-1_72.lib (vc141, detected vc142, set
43
  Boost_COMPILER to override)

Should I use legacy to actually bump the compiler version with toolset?

MarkusJx commented 2 years ago

I am assuming you are using msvc 14.1 which is not supported by my own prebuilt boost versions as this compiler is slowly becoming obsolete (or is it?). But yes, I would also suggest using the legacy setting as actions/boost-versions can supply boost compiled using msvc 14.1 up to version 1.73.0, so your actions.yml may look like this:

- name: Install boost
  uses: MarkusJx/install-boost@v2.0.0
  with:
    boost_version: 1.72.0
    # You'll need this:
    version: legacy
    # And this:
    toolset: msvc14.2

But if you need newer boost versions, I'll suggest either updating to msvc 14.2 or if you really depend on msvc 14.1, let me know, I could make that work using my own repository.

MichaelVoelkel commented 2 years ago

Hmm, I have not changed anything with relation to the compiler version and the messages seem to indicate that the downloaded boost files are 14.1..? My compiler is actually 14.2 and CMake configure also shows this. Probably, I am just reading it wrong, but from where do you get the information that I use 14.1? Anyway, I will try with legacy+toolset (although this again seems to rather tell your action that 14.2 should be used instead of 14.1, indicating that I already use 14.2 but the download is wrong? bit confused here :) )

MarkusJx commented 2 years ago

Oh, so you are using msvc 14.2? In that case this should work fine but for some reason your cmake seems to search for boost compiled using msvc 14.1, which is weird...

MichaelVoelkel commented 2 years ago

I created a sample repository and there the job is failed, might be easier to see this way :) Maybe, I'm just doing something stupid: https://github.com/MichaelVoelkel/github-action-tests https://github.com/MichaelVoelkel/github-action-tests/runs/4497347273?check_suite_focus=true

MarkusJx commented 2 years ago

Found the issue. This action uses boost built for windows server 2016 by default but you were using windows server 2019 (windows-latest). Windows server 2016 (the github-hosted runners) ships with msvc 14.1, while windows server 2019 ships with msvc 14.2, which was causing your issue.

So I've just changed

- name: Install boost
  uses: MarkusJx/install-boost@v2.0.0
  id: install-boost
  with:
    boost_version: 1.72.0

to

- name: Install boost
  uses: MarkusJx/install-boost@v2.0.0
  id: install-boost
  with:
    boost_version: 1.72.0
    platform_version: 2019

adding the platform_version argument.

I should add this to the readme or let the action figure out the runner's os version. Edit: The versions built for windows server 2019 do even work for windows server 2022, which is nice.

MichaelVoelkel commented 2 years ago

Great! Thanks for taking the time, I also tested it on my repository and seems to work!! Will try on my "real repository" soon, hopefully it will work there, too. Have a nice Sunday!