Page MenuHomePhabricator

[cmake] support using brew for finding path prefixes on OSX
ClosedPublic

Authored by schancel on May 1 2018, 18:33.

Details

Summary

As per title.

Depends on D1342

Test Plan

Run cmake and build

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
deadalnix requested changes to this revision.May 1 2018, 22:04
deadalnix added inline comments.
cmake/modules/BrewHelper.cmake
1 ↗(On Diff #3687)

whatyearisit

src/qt/CMakeLists.txt
10 ↗(On Diff #3687)

Put this on top of master

This revision now requires changes to proceed.May 1 2018, 22:04

Make sure brew is found.

deadalnix requested changes to this revision.May 1 2018, 23:18
deadalnix added inline comments.
cmake/modules/BrewHelper.cmake
9 ↗(On Diff #3689)

Does this ever run ? This clearly require some kind of internal cache to not recompute the same value again and again, but I don't think this is the way. Even if it work, conssider:

find_brew_prefix(FOO qt5)
find_brew_prefix(BAR qt5)

The cache should be based on NAME .

src/qt/CMakeLists.txt
10 ↗(On Diff #3689)

...

This revision now requires changes to proceed.May 1 2018, 23:18
cmake/modules/BrewHelper.cmake
9 ↗(On Diff #3689)

This is to prevent it from smashing OPENSSL_ROOT_DIR if it's user provided

src/qt/CMakeLists.txt
10 ↗(On Diff #3689)

........

Fix commit rebase mistake

deadalnix requested changes to this revision.May 2 2018, 21:41
deadalnix added inline comments.
cmake/modules/BrewHelper.cmake
1 ↗(On Diff #3722)

whatyearisit

10 ↗(On Diff #3722)

This isn't the proper way to cache that result. Something like:

find_program(BREW brew)
if(NOT ${BREW})
    return()
endif()

if(DEFINED "BREW_CACHED_PREFIX_${NAME}")
    set(${VAR} ${BREW_CACHED_PREFIX_${NAME}} PARENT_SCOPE)
endif()

execute_process(
    COMMAND ${BREW} --prefix ${NAME}
    OUTPUT_VARIABLE PREFIX
    ERROR_QUIET
    OUTPUT_STRIP_TRAILING_WHITESPACE
)
set("BREW_CACHED_PREFIX_${NAME}" ${PREFIX} CACHE PATH "Path for ${NAME} within brew")
set(${VAR} ${PREFIX} PARENT_SCOPE)
This revision now requires changes to proceed.May 2 2018, 21:41
cmake/modules/BrewHelper.cmake
10 ↗(On Diff #3722)

I responded before, it's not a cache. It's so it doesn't overwrite it with blank on on linux or otherwise if someone supplies it on the console.

Ok this looks good. I need to experiment a bit with cmake to make this indeed does what I think it does.

CMakeLists.txt
15 ↗(On Diff #3732)

Let me check this work as expected on linux.

deadalnix requested changes to this revision.May 5 2018, 21:05

Ok some minor details, but this is basically good to go.

CMakeLists.txt
16 ↗(On Diff #3732)

Ok it does as nothing is set if brew is not fond. Please move this wherever openssl is used.

cmake/modules/BrewHelper.cmake
4 ↗(On Diff #3732)

This can be moved out of the function.

21 ↗(On Diff #3732)

You were correct about this if the variable is defined, then you bail. This seems to be a standard cmake behavior. It's kind of weird, but I guess consistency has it virtue.

This revision now requires changes to proceed.May 5 2018, 21:05

Fix nit, and change behavior back to failing if the variable is defined.

Use if(DEFINED "${VAR}")

CMakeLists.txt
16 ↗(On Diff #3732)

I don't understand.

cmake/modules/BrewHelper.cmake
14 ↗(On Diff #3791)

Can this stuff be safely deleted now? Seems redundant.

Revert stuff, move brew prefix check for openssl into usage locations

Include the qt5 support in this diff. Order was backwards somehow.

src/qt/CMakeLists.txt
117 ↗(On Diff #3794)

Does this need to be it's own diff? It got pulled in here during my fiddling.

CMakeLists.txt
23 ↗(On Diff #3794)

Revert.

cmake/modules/BrewHelper.cmake
4 ↗(On Diff #3794)

You don't need to wrap this in an if, as it turns out, if brew is defined, find_program will not do anything.

src/qt/CMakeLists.txt
117 ↗(On Diff #3794)

It's fine.

Remove extraneous if statement.

This revision is now accepted and ready to land.May 9 2018, 19:06
This revision was automatically updated to reflect the committed changes.