1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-25 12:12:50 +01:00

[CMake] Build LLVM from the submodule if there's no suitable version

When RPCS3 is compiled with LLVM (default option), CMake only tries to
find LLVM on the default system installation. So the OS must have a
sytstem-wide installation of LLVM of at least version 4.0, which is not
available on many GNU/Linux distributions (e.g. Ubuntu 16.04, Debian
Stretch). If CMake can not find a suitable version, it silently falls
back to compile RPCS3 without LLVM.

This patch makes CMake defaults to compile the LLVM submodule if and
only if a suitable LLVM version is not found installed on the system.
Due to a build time check on LLVM, in-tree builds will not work when
building the submodule (LLVM does not allow in-source builds). For this
reason, the instruction for building on CMake were updated.
This commit is contained in:
Henrique Jung 2017-10-01 03:26:42 -03:00 committed by kd-11
parent 1572d01c53
commit 76b7103fed
2 changed files with 25 additions and 1 deletions

View File

@ -63,7 +63,8 @@ To initialize the repository don't forget to execute `git submodule update --ini
1) `git clone https://github.com/RPCS3/rpcs3.git` </br> 1) `git clone https://github.com/RPCS3/rpcs3.git` </br>
2) `cd rpcs3/` </br> 2) `cd rpcs3/` </br>
3) `git submodule update --init` </br> 3) `git submodule update --init` </br>
4) `cmake CMakeLists.txt && make GitVersion && make` </br> 4) `cd ../ && mkdir rpcs3_build && cd rpcs3_build`
4) `cmake ../rpcs3/ && make GitVersion && make` </br>
5) Run RPCS3 with `./bin/rpcs3` </br> 5) Run RPCS3 with `./bin/rpcs3` </br>
If you are on MacOS and want to build with brew llvm and qt don't forget to add the following environment variables If you are on MacOS and want to build with brew llvm and qt don't forget to add the following environment variables

View File

@ -166,6 +166,29 @@ find_package(OpenGL REQUIRED)
find_package(OpenAL REQUIRED) find_package(OpenAL REQUIRED)
if (NOT WITHOUT_LLVM) if (NOT WITHOUT_LLVM)
find_package(LLVM 4.0 CONFIG) find_package(LLVM 4.0 CONFIG)
if (NOT LLVM_FOUND)
message("System LLVM was not found, LLVM will be built from the submodule.")
set(LLVM_TARGETS_TO_BUILD "X86" CACHE INTERNAL "")
option(LLVM_BUILD_RUNTIME OFF)
option(LLVM_BUILD_TOOLS OFF)
option(LLVM_INCLUDE_DOCS OFF)
option(LLVM_INCLUDE_EXAMPLES OFF)
option(LLVM_INCLUDE_TESTS OFF)
option(LLVM_INCLUDE_TOOLS OFF)
option(LLVM_INCLUDE_UTILS OFF)
option(WITH_POLLY OFF)
# LLVM needs to be built out-of-tree
add_subdirectory(../llvm ../llvm_build)
set(LLVM_DIR "${CMAKE_CURRENT_BINARY_DIR}/../llvm_build/lib/cmake/llvm/")
# now tries to find LLVM again
find_package(LLVM 4.0 CONFIG)
if (NOT LLVM_FOUND)
message(WARNING "Couldn't build LLVM from the submodule. You might need to run `git submodule update --init`")
endif()
endif()
endif() endif()