devkitPro / wut

Let's try to make a Wii U Toolchain / SDK for creating rpx/rpl.
zlib License
244 stars 52 forks source link

CMAKE_PREFIX_PATH option doesn't work #59

Closed Ghabry closed 6 years ago

Ghabry commented 7 years ago

In my build system I have the Wii(U) libraries outside of the ${DEVKITPPC} folder and want to specify the folder via -DCMAKE_PREFIX_PATH, but line 44 in wut-toolchain.cmake hardcodes a CMAKE_FIND_ROOT_PATH, so the PREFIX_PATH doesn't work anymore (because the ROOT_PATH is prefixed to the PREFIX_PATH I guess?).

Looks like CMAKE_PREFIX_PATH is the newer option. No idea how to properly fix this, maybe use CMAKE_PREFIX_PATH and APPEND?

CreeperMario commented 7 years ago

Not sure if this will help, but I was able to get a CMake WUT project to link with the devkitPro PowerPC portlibs by adding the following to my CMakeLists.txt file, underneath my project declaration:

include_directories(include $ENV{DEVKITPRO}/portlibs/ppc/include)
set(CMAKE_LIBRARY_PATH $ENV{DEVKITPRO}/portlibs/ppc/lib)

The WUT toolchain automatically detects if these are used and adds these to WUT's predefined paths.

Ghabry commented 7 years ago

thanks, this seems to work however I would prefer if the standard CMake way is supported.

I can't really see the purpose of set(CMAKE_FIND_ROOT_PATH ${DEVKITPPC}) when I delete this everything still works including the -DCMAKE_PREFIX_PATH.

exjam commented 7 years ago

I think the point of using CMAKE_FIND_ROOT_PATH was to stop CMake from looking into your library paths where there could be libs which are not designed for the toolchain you're targeting - your default lib path is going to have be full of x64 libs, not only the ones for PPC.

CMake docs seem to support this idea by mentioning cross-compiling: https://cmake.org/cmake/help/v3.0/variable/CMAKE_FIND_ROOT_PATH.html

Ghabry commented 7 years ago

Yeah, I know that this is the purpose. By further reading through the docs I think CMAKE_PREFIX_PATH is appended to CMAKE_FIND_ROOT_PATH.

Untested, but by replacing the line with

list(APPEND CMAKE_FIND_ROOT_PATH ${DEVKITPPC})

everything should work as expected (and I simply pass my library path via -DCMAKE_FIND_ROOT_PATH instead of PREFIX_PATH)

EDIT: Just looked at vitasdk. They do

set( CMAKE_FIND_ROOT_PATH "${VITASDK}/bin" "${VITASDK}/arm-vita-eabi" "${CMAKE_INSTALL_PREFIX}" "${CMAKE_INSTALL_PREFIX}/share" )
set( CMAKE_INSTALL_PREFIX "${VITASDK}/arm-vita-eabi" CACHE PATH "default install path" )

Explicitly adding CMAKE_INSTALL_PREFIX to CMAKE_FIND_ROOT_PATH sounds like a solution, too. 👍

exjam commented 6 years ago

Fixed in the rewrite branch. https://github.com/decaf-emu/wut/blob/rewrite/share/wut.toolchain.cmake#L37

JonathanSum commented 5 years ago

404 https://github.com/decaf-emu/wut/blob/rewrite/share/wut.toolchain.cmake#L37

WinterMute commented 5 years ago

Please don't necrobump issues with broken links. If you have an issue you need help with then please ask on the devkitPro forums or raise a new issue.

Unfortunately attempting to research and solve your problem by yourself will most likely lead to further problems due to following poor advice.