1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 10:42:36 +01:00
rpcs3/3rdparty/llvm.cmake
Lassi Hämäläinen 7aef811ff7 CMake: Refactor CMake build (#5032)
* CMake: Refactor build to multiple libraries

- Refactor CMake build system by creating separate libraries for
  different components
- Create interface libraries for most dependencies and add 3rdparty::*
  ALIAS targets for ease of use and use them to try specifying correct
  dependencies for each target
- Prefer 3rdparty:: ALIAS when linking dependencies
- Exclude xxHash subdirectory from ALL build target
- Add USE_SYSTEM_ZLIB option to select between using included ZLib and
  the ZLib in CMake search path

* Add cstring include to Log.cpp

* CMake: Add 3rdparty::glew interface target

* Add Visual Studio CMakeSettings.json to gitignore

* CMake: Move building and finding LLVM to 3rdparty/llvm.cmake script

- LLVM is now built under 3rdparty/ directory in the binary directory

* CMake: Move finding Qt5 to 3rdparty/qt5.cmake script

- Script has to be included in rpcs3/CMakeLists.txt because it defines
  Qt5::moc target which isn't available in that folder if it is
  included in 3rdparty directory
- Set AUTOMOC and AUTOUIC properties for targets requiring them (rpcs3
  and rpcs3_ui) instead of setting CMAKE_AUTOMOC and CMAKE_AUTOUIC so
  those properties are not defined for all targets under rpcs3 dir

* CMake: Remove redundant code from rpcs3/CMakeLists.txt

* CMake: Add BUILD_LLVM_SUBMODULE option instead of hardcoded check

- Add BUILD_LLVM_SUBMODULE option (defaults to ON) to allow controlling
  usage of the LLVM submodule.
- Move option definitions to root CMakeLists

* CMake: Remove separate Emu subtargets

- Based on discussion in pull request #5032, I decided to combine
  subtargets under Emu folder back to a single rpcs3_emu target

* CMake: Remove utilities, loader and crypto targets: merge them to Emu

- Removed separate targets and merged them into rpcs3_emu target as
  recommended in pull request (#5032) conversations. Separating targets
  probably later in a separate pull request

* Fix relative includes in pad_thread.cpp

* Fix Travis-CI cloning all submodules needlessly
2018-09-18 13:07:33 +03:00

66 lines
2.2 KiB
CMake

if(NOT WITHOUT_LLVM)
if(BUILD_LLVM_SUBMODULE)
message(STATUS "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)
option(LLVM_ENABLE_CXX1Z TRUE)
set(CXX_FLAGS_OLD ${CMAKE_CXX_FLAGS})
if (MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS")
endif()
# LLVM needs to be built out-of-tree
add_subdirectory(${CMAKE_SOURCE_DIR}/llvm ${CMAKE_CURRENT_BINARY_DIR}/llvm_build EXCLUDE_FROM_ALL)
set(LLVM_DIR "${CMAKE_CURRENT_BINARY_DIR}/llvm_build/lib/cmake/llvm/")
set(CMAKE_CXX_FLAGS ${CXX_FLAGS_OLD})
# now tries to find LLVM again
find_package(LLVM 7.0 CONFIG)
if(NOT LLVM_FOUND)
message(FATAL_ERROR "Couldn't build LLVM from the submodule. You might need to run `git submodule update --init`")
endif()
else()
message(STATUS "Using prebuilt LLVM")
if (LLVM_DIR AND NOT IS_ABSOLUTE "${LLVM_DIR}")
# change relative LLVM_DIR to be relative to the source dir
set(LLVM_DIR ${CMAKE_SOURCE_DIR}/${LLVM_DIR})
endif()
find_package(LLVM 7.0 CONFIG)
if (NOT LLVM_FOUND)
if (LLVM_VERSION AND LLVM_VERSION_MAJOR LESS 7)
message(FATAL_ERROR "Found LLVM version ${LLVM_VERSION}. Required version 7.0. \
Enable BUILD_LLVM_SUBMODULE option to build LLVM from included as a git submodule.")
endif()
message(FATAL_ERROR "Can't find LLVM libraries from the CMAKE_PREFIX_PATH path or LLVM_DIR. \
Enable BUILD_LLVM_SUBMODULE option to build LLVM from included as a git submodule.")
endif()
endif()
set(LLVM_LIBS LLVMMCJIT LLVMX86CodeGen)
add_library(3rdparty_llvm INTERFACE)
target_link_libraries(3rdparty_llvm INTERFACE ${LLVM_LIBS})
target_include_directories(3rdparty_llvm INTERFACE ${LLVM_INCLUDE_DIRS})
target_compile_definitions(3rdparty_llvm INTERFACE ${LLVM_DEFINITIONS} -DLLVM_AVAILABLE)
add_library(3rdparty::llvm ALIAS 3rdparty_llvm)
else()
add_library(3rdparty::llvm ALIAS 3rdparty_dummy_lib)
endif()