CMake fixups (#104)

* Provide default $WUT_ROOT

* default install path to /opt/devkitpro/wut

* only reinstall tools when required

* Correct search paths

* allow host paths for programs

* find tools via PATH & CMAKE_FIND_ROOT_PATH

* specify root path without bin component
This commit is contained in:
Dave Murphy 2019-04-04 02:01:17 +01:00 committed by Ash
parent 1afdff1a21
commit 96cf21131d
3 changed files with 23 additions and 27 deletions

View File

@ -26,9 +26,10 @@ git:
install:
- wget https://github.com/devkitPro/pacman/releases/download/devkitpro-pacman-1.0.1/devkitpro-pacman.deb -O /tmp/devkitpro-pacman.deb
- sudo dpkg -i /tmp/devkitpro-pacman.deb
- yes | sudo dkp-pacman -Syu devkitPPC wut-tools
- yes | sudo dkp-pacman -Syu --needed devkitPPC wut-tools
- export DEVKITPRO=/opt/devkitpro
- export DEVKITPPC=/opt/devkitpro/devkitPPC
- export PATH=$DEVKITPRO/tools/bin:$DEVKITPPC/bin:$PATH
script:
- cd "$TRAVIS_BUILD_DIR"

View File

@ -6,6 +6,10 @@ set(CMAKE_TOOLCHAIN_FILE "${WUT_ROOT}/share/wut.toolchain.cmake")
project(wut)
option(WUT_BUILD_DOCS "Build documentation" OFF)
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set (CMAKE_INSTALL_PREFIX "/opt/devkitpro/wut" CACHE PATH "default install path" FORCE )
endif()
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/lib")

View File

@ -12,33 +12,23 @@ endif()
set(DEVKITPRO $ENV{DEVKITPRO})
# Find DEVKITPPC
find_program(DEVKITPPC_GCC
NAMES powerpc-eabi-gcc
PATHS "${DEVKITPRO}/devkitPPC/bin")
if(DEVKITPPC_GCC)
get_filename_component(DEVKITPPC_BIN ${DEVKITPPC_GCC} DIRECTORY)
get_filename_component(DEVKITPPC ${DEVKITPPC_BIN} DIRECTORY)
if(NOT DEFINED ENV{DEVKITPPC})
set(DEVKITPPC $ENV{DEVKITPRO}/devkitPPC)
else()
if(NOT DEFINED ENV{DEVKITPPC})
message(FATAL_ERROR "You must have added DEVKITPPC to PATH or defined DEVKITPPC before calling cmake.")
endif()
set(DEVKITPPC $ENV{DEVKITPPC})
set(DEVKITPPC_BIN "${DEVKITPPC}/bin")
endif()
# Find WUT
if(NOT DEFINED ENV{WUT_ROOT})
message(FATAL_ERROR "You must have defined WUT_ROOT before calling cmake.")
set(WUT_ROOT $ENV{DEVKITPRO}/wut)
else()
set(WUT_ROOT $ENV{WUT_ROOT})
endif()
set(WUT_ROOT $ENV{WUT_ROOT})
# Find elf2rpl
find_program(ELF2RPL_BIN
NAMES elf2rpl
PATHS "${DEVKITPRO}/tools/bin")
)
if(NOT ELF2RPL_BIN)
message(FATAL_ERROR "Could not find elf2rpl")
endif()
@ -46,17 +36,18 @@ endif()
# Find rplexportgen
find_program(RPLEXPORTGEN_BIN
NAMES rplexportgen
PATHS "${DEVKITPRO}/tools/bin")
)
if(NOT RPLEXPORTGEN_BIN)
message(FATAL_ERROR "Could not find rplexportgen")
endif()
set(CMAKE_ASM_COMPILER "${DEVKITPPC_BIN}/powerpc-eabi-gcc" CACHE PATH "")
set(CMAKE_C_COMPILER "${DEVKITPPC_BIN}/powerpc-eabi-gcc" CACHE PATH "")
set(CMAKE_CXX_COMPILER "${DEVKITPPC_BIN}/powerpc-eabi-g++" CACHE PATH "")
set(CMAKE_LINKER "${DEVKITPPC_BIN}/powerpc-eabi-ld" CACHE PATH "")
set(CMAKE_AR "${DEVKITPPC_BIN}/powerpc-eabi-ar" CACHE PATH "")
set(CMAKE_STRIP "${DEVKITPPC_BIN}/powerpc-eabi-strip" CACHE PATH "")
set(CMAKE_ASM_COMPILER "powerpc-eabi-gcc" CACHE PATH "")
set(CMAKE_C_COMPILER "powerpc-eabi-gcc" CACHE PATH "")
set(CMAKE_CXX_COMPILER "powerpc-eabi-g++" CACHE PATH "")
set(CMAKE_LINKER "powerpc-eabi-ld" CACHE PATH "")
set(CMAKE_AR "powerpc-eabi-ar" CACHE PATH "")
set(CMAKE_STRIP "powerpc-eabi-strip" CACHE PATH "")
set(WUT_C_FLAGS "-mcpu=750 -meabi -mhard-float -Wl,-q -D__WIIU__ -D__WUT__ -isystem \"${WUT_ROOT}/include\"")
set(CMAKE_C_FLAGS "${WUT_C_FLAGS}" CACHE STRING "")
@ -65,8 +56,8 @@ set(CMAKE_ASM_FLAGS "${WUT_C_FLAGS}" CACHE STRING "")
set(CMAKE_EXE_LINKER_FLAGS "-Wl,-z,nocopyreloc -T \"${WUT_ROOT}/share/wut.ld\" \"-L${WUT_ROOT}/lib\"" CACHE STRING "")
# Setup root to exclude host system headers + libraries
set(CMAKE_FIND_ROOT_PATH "${DEVKITPPC}" "${DEVKITPRO}/tools/bin" "${CMAKE_INSTALL_PREFIX}" "${CMAKE_INSTALL_PREFIX}/share")
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH "${DEVKITPPC}" "${DEVKITPRO}/tools" "${DEVKITPRO}/portlibs/wiiu" "${DEVKITPRO}/portlibs/ppc" "${WUT_ROOT}/share")
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)