|
| 1 | +# Build PCSX2 dependencies during the configure step. |
| 2 | +# |
| 3 | +# This is intentionally executed during CMake configure because |
| 4 | +# SearchForStuff.cmake uses find_package() during configure. |
| 5 | + |
| 6 | +set(PCSX2_DEPS_PREFIX "${CMAKE_BINARY_DIR}/deps" CACHE PATH |
| 7 | + "Where PCSX2 dependencies are installed") |
| 8 | + |
| 9 | +set(PCSX2_DEPS_JOBS "" CACHE STRING |
| 10 | + "Parallel jobs for dependency builds") |
| 11 | + |
| 12 | +set(_deps_build "${CMAKE_BINARY_DIR}/deps-build") |
| 13 | + |
| 14 | +set(_deps_args |
| 15 | + -DCMAKE_INSTALL_PREFIX=${PCSX2_DEPS_PREFIX} |
| 16 | +) |
| 17 | + |
| 18 | +if(PCSX2_DEPS_JOBS) |
| 19 | + list(APPEND _deps_args -DNPROCS=${PCSX2_DEPS_JOBS}) |
| 20 | +endif() |
| 21 | + |
| 22 | +# Pass the parent toolchain/compiler configuration to the dependency build. |
| 23 | +foreach(_var |
| 24 | + CMAKE_TOOLCHAIN_FILE |
| 25 | + CMAKE_C_COMPILER |
| 26 | + CMAKE_CXX_COMPILER |
| 27 | + CMAKE_C_COMPILER_LAUNCHER |
| 28 | + CMAKE_CXX_COMPILER_LAUNCHER |
| 29 | + CMAKE_SYSROOT |
| 30 | + CMAKE_OSX_DEPLOYMENT_TARGET |
| 31 | + CMAKE_OSX_ARCHITECTURES |
| 32 | + ANDROID_ABI |
| 33 | + ANDROID_PLATFORM |
| 34 | +) |
| 35 | + if(DEFINED ${_var}) |
| 36 | + list(APPEND _deps_args -D${_var}=${${_var}}) |
| 37 | + endif() |
| 38 | +endforeach() |
| 39 | + |
| 40 | +message(STATUS "") |
| 41 | +message(STATUS "Building PCSX2 dependencies into:") |
| 42 | +message(STATUS " ${PCSX2_DEPS_PREFIX}") |
| 43 | +message(STATUS "") |
| 44 | + |
| 45 | +execute_process( |
| 46 | + COMMAND ${CMAKE_COMMAND} |
| 47 | + -S "${CMAKE_SOURCE_DIR}/pcsx2-deps" |
| 48 | + -B "${_deps_build}" |
| 49 | + -G "${CMAKE_GENERATOR}" |
| 50 | + ${_deps_args} |
| 51 | + RESULT_VARIABLE _deps_result |
| 52 | +) |
| 53 | + |
| 54 | +if(NOT _deps_result EQUAL 0) |
| 55 | + message(FATAL_ERROR |
| 56 | + "Configuring the PCSX2 dependency build failed (${_deps_result})") |
| 57 | +endif() |
| 58 | + |
| 59 | +execute_process( |
| 60 | + COMMAND ${CMAKE_COMMAND} |
| 61 | + --build "${_deps_build}" |
| 62 | + --parallel |
| 63 | + RESULT_VARIABLE _deps_result |
| 64 | +) |
| 65 | + |
| 66 | +if(NOT _deps_result EQUAL 0) |
| 67 | + message(FATAL_ERROR |
| 68 | + "Building the PCSX2 dependencies failed (${_deps_result})") |
| 69 | +endif() |
| 70 | + |
| 71 | +# Make the freshly installed packages visible to SearchForStuff.cmake. |
| 72 | +list(PREPEND CMAKE_PREFIX_PATH "${PCSX2_DEPS_PREFIX}") |
| 73 | + |
| 74 | +if(CMAKE_FIND_ROOT_PATH) |
| 75 | + list(PREPEND CMAKE_FIND_ROOT_PATH "${PCSX2_DEPS_PREFIX}") |
| 76 | +endif() |
0 commit comments