wut/share/wut.toolchain.cmake
Ash Logan 65d7bdd3e5 cmake: Add libwut to standard include dirs
apparently cmake also has a CMAKE_<LANG>_STANDARD_INCLUDE_DIRECTORIES
2019-05-03 18:08:42 +10:00

86 lines
2.9 KiB
CMake

cmake_minimum_required(VERSION 3.2)
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_SYSTEM_PROCESSOR "ppc")
set(CMAKE_CROSSCOMPILING 1)
# Find DEVKITPRO
if(NOT DEFINED ENV{DEVKITPRO})
message(FATAL_ERROR "You must have defined DEVKITPRO before calling cmake.")
endif()
set(DEVKITPRO $ENV{DEVKITPRO})
if(NOT DEFINED ENV{DEVKITPPC})
set(DEVKITPPC $ENV{DEVKITPRO}/devkitPPC)
else()
set(DEVKITPPC $ENV{DEVKITPPC})
endif()
if(NOT DEFINED ENV{WUT_ROOT})
set(WUT_ROOT $ENV{DEVKITPRO}/wut)
else()
set(WUT_ROOT $ENV{WUT_ROOT})
endif()
# Find elf2rpl
find_program(ELF2RPL_BIN
NAMES elf2rpl
)
if(NOT ELF2RPL_BIN)
message(FATAL_ERROR "Could not find elf2rpl")
endif()
# Find rplexportgen
find_program(RPLEXPORTGEN_BIN
NAMES rplexportgen
)
if(NOT RPLEXPORTGEN_BIN)
message(FATAL_ERROR "Could not find rplexportgen")
endif()
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__")
set(CMAKE_C_FLAGS "${WUT_C_FLAGS}" CACHE STRING "")
set(CMAKE_CXX_FLAGS "${WUT_C_FLAGS}" CACHE STRING "")
set(CMAKE_ASM_FLAGS "${WUT_C_FLAGS}" CACHE STRING "")
set(CMAKE_EXE_LINKER_FLAGS "\"-L${WUT_ROOT}/lib/stubs\" -specs=${WUT_ROOT}/share/wut.specs" CACHE STRING "")
set(WUT_STANDARD_LIBRARIES "\"${WUT_ROOT}/lib/libwut.a\"")
set(CMAKE_C_STANDARD_LIBRARIES "${WUT_STANDARD_LIBRARIES}" CACHE STRING "")
set(CMAKE_CXX_STANDARD_LIBRARIES "${WUT_STANDARD_LIBRARIES}" CACHE STRING "")
set(CMAKE_ASM_STANDARD_LIBRARIES "${WUT_STANDARD_LIBRARIES}" CACHE STRING "")
#for some reason cmake (3.14.3) doesn't appreciate having \" here
set(WUT_STANDARD_INCLUDE_DIRECTORIES "${WUT_ROOT}/include")
set(CMAKE_C_STANDARD_INCLUDE_DIRECTORIES "${WUT_STANDARD_INCLUDE_DIRECTORIES}" CACHE STRING "")
set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES "${WUT_STANDARD_INCLUDE_DIRECTORIES}" CACHE STRING "")
set(CMAKE_ASM_STANDARD_INCLUDE_DIRECTORIES "${WUT_STANDARD_INCLUDE_DIRECTORIES}" CACHE STRING "")
# Setup root to exclude host system headers + libraries
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)
# Tools
set(WUT_ELF2RPL "${ELF2RPL_BIN}" CACHE PATH "")
set(WUT_RPLEXPORTGEN "${RPLEXPORTGEN_BIN}" CACHE PATH "")
# Flags
set(WUT TRUE)
set(WIIU TRUE)
# There is no shared lib support in devkitPPC
set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "Shared libs not available")