cmake: Move LLVM import to UICommon

To use it, with a modern LLVM (3.9+), set your CMAKE_PREFIX_PATH
to point to the LLVM install folder or to a LLVM build folder.
We're linking ALL of LLVM libs since I don't really know which ones we need.
LTO will take care of sliming the binary size...
This commit is contained in:
Florent Castelli 2017-02-08 02:59:41 +01:00
parent 8c82607c95
commit f649e26655
3 changed files with 10 additions and 57 deletions

View File

@ -436,19 +436,6 @@ if (OPENGL_GL)
include_directories(${OPENGL_INCLUDE_DIR}) include_directories(${OPENGL_INCLUDE_DIR})
endif() endif()
if(ENABLE_LLVM)
find_package(LLVM)
if (LLVM_FOUND)
add_definitions(-DHAS_LLVM=1)
set(HAS_LLVM 1)
include_directories(${LLVM_INCLUDE_DIRS})
list(APPEND LIBS ${LLVM_LIBRARIES})
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
endif()
endif()
set(USE_X11 0) set(USE_X11 0)
if(UNIX AND NOT APPLE AND NOT ANDROID AND NOT ENABLE_HEADLESS) if(UNIX AND NOT APPLE AND NOT ANDROID AND NOT ENABLE_HEADLESS)

View File

@ -1,44 +0,0 @@
# This file only exists because LLVM's cmake files are broken.
# This affects both LLVM 3.4 and 3.5.
# Hopefully when they fix their cmake system we don't need this garbage.
include(CheckLibraryExists)
list(APPEND LLVM_CONFIG_EXECUTABLES "llvm-config")
list(APPEND LLVM_CONFIG_EXECUTABLES "llvm-config-3.5")
list(APPEND LLVM_CONFIG_EXECUTABLES "llvm-config-3.4")
foreach(LLVM_CONFIG_NAME ${LLVM_CONFIG_EXECUTABLES})
find_program(LLVM_CONFIG_EXE NAMES ${LLVM_CONFIG_NAME})
if (LLVM_CONFIG_EXE)
execute_process(COMMAND ${LLVM_CONFIG_EXE} --version OUTPUT_VARIABLE LLVM_PACKAGE_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE )
if (LLVM_PACKAGE_VERSION VERSION_GREATER "3.3")
execute_process(COMMAND ${LLVM_CONFIG_EXE} --includedir OUTPUT_VARIABLE LLVM_INCLUDE_DIRS
OUTPUT_STRIP_TRAILING_WHITESPACE )
execute_process(COMMAND ${LLVM_CONFIG_EXE} --ldflags OUTPUT_VARIABLE LLVM_LDFLAGS
OUTPUT_STRIP_TRAILING_WHITESPACE )
check_library_exists(LLVM-${LLVM_PACKAGE_VERSION} LLVMVerifyFunction "${LLVM_LDFLAGS}" HAVE_DYNAMIC_LLVM_${LLVM_PACKAGE_VERSION})
if (HAVE_DYNAMIC_LLVM_${LLVM_PACKAGE_VERSION})
set(LLVM_LIBRARIES "${LLVM_LDFLAGS} -lLLVM-${LLVM_PACKAGE_VERSION}")
set(CMAKE_REQUIRED_LIBRARIES ${LLVM_LIBRARIES})
CHECK_CXX_SOURCE_COMPILES(
"#include <llvm-c/Disassembler.h>
#include <llvm-c/Target.h>
int main(int argc, char **argv)
{
LLVMInitializeAllTargetInfos();
LLVMInitializeAllTargetMCs();
LLVMInitializeAllDisassemblers();
return 0;
}"
LLVM_FOUND)
unset(CMAKE_REQUIRED_LIBRARIES)
if (LLVM_FOUND)
break()
endif()
endif()
endif()
endif()
endforeach()

View File

@ -8,3 +8,13 @@ if(LIBUSB_FOUND)
endif() endif()
add_dolphin_library(uicommon "${SRCS}" "${LIBS}") add_dolphin_library(uicommon "${SRCS}" "${LIBS}")
if(ENABLE_LLVM)
find_package(LLVM CONFIG QUIET)
if(LLVM_FOUND)
message(STATUS "LLVM found, enabling LLVM support in disassembler")
target_compile_definitions(uicommon PRIVATE HAS_LLVM)
target_link_libraries(uicommon PRIVATE ${LLVM_AVAILABLE_LIBS})
target_include_directories(uicommon PRIVATE ${LLVM_INCLUDE_DIRS})
endif()
endif()