diff --git a/CMakeLists.txt b/CMakeLists.txt index 1eee549f22..f418cf1060 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -436,19 +436,6 @@ if (OPENGL_GL) include_directories(${OPENGL_INCLUDE_DIR}) 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) if(UNIX AND NOT APPLE AND NOT ANDROID AND NOT ENABLE_HEADLESS) diff --git a/CMakeTests/FindLLVM.cmake b/CMakeTests/FindLLVM.cmake deleted file mode 100644 index 006ca9e899..0000000000 --- a/CMakeTests/FindLLVM.cmake +++ /dev/null @@ -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 - #include - 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() diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index e1836da317..b6a6fef1e4 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -21,7 +21,7 @@ add_definitions(-D__STDC_CONSTANT_MACROS) macro(add_dolphin_library lib srcs libs) add_library(${lib} STATIC ${srcs}) - target_link_libraries(${lib} ${libs}) + target_link_libraries(${lib} PUBLIC ${libs}) endmacro() add_subdirectory(Core) diff --git a/Source/Core/UICommon/CMakeLists.txt b/Source/Core/UICommon/CMakeLists.txt index 6bfc4be9bd..b76e79a66f 100644 --- a/Source/Core/UICommon/CMakeLists.txt +++ b/Source/Core/UICommon/CMakeLists.txt @@ -8,3 +8,13 @@ if(LIBUSB_FOUND) endif() 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 HAVE_LLVM) + target_link_libraries(uicommon PRIVATE ${LLVM_AVAILABLE_LIBS}) + target_include_directories(uicommon PRIVATE ${LLVM_INCLUDE_DIRS}) + endif() +endif() diff --git a/Source/Core/UICommon/Disassembler.cpp b/Source/Core/UICommon/Disassembler.cpp index 6d0a4fb014..14cab2ef9a 100644 --- a/Source/Core/UICommon/Disassembler.cpp +++ b/Source/Core/UICommon/Disassembler.cpp @@ -1,6 +1,6 @@ #include // Bochs -#if defined(HAS_LLVM) +#if defined(HAVE_LLVM) // PowerPC.h defines PC. // This conflicts with a function that has an argument named PC #undef PC @@ -28,7 +28,7 @@ private: u32* host_instructions_count, u64 starting_pc) override; }; -#if defined(HAS_LLVM) +#if defined(HAVE_LLVM) class HostDisassemblerLLVM : public HostDisassembler { public: @@ -153,7 +153,7 @@ std::string HostDisassemblerX86::DisassembleHostBlock(const u8* code_start, cons HostDisassembler* GetNewDisassembler(const std::string& arch) { -#if defined(HAS_LLVM) +#if defined(HAVE_LLVM) if (arch == "x86") return new HostDisassemblerLLVM("x86_64-none-unknown"); else if (arch == "aarch64") diff --git a/Source/Core/VideoBackends/Vulkan/CMakeLists.txt b/Source/Core/VideoBackends/Vulkan/CMakeLists.txt index fc5ac99df9..5df1876bfd 100644 --- a/Source/Core/VideoBackends/Vulkan/CMakeLists.txt +++ b/Source/Core/VideoBackends/Vulkan/CMakeLists.txt @@ -37,5 +37,5 @@ include_directories(SYSTEM ${CMAKE_SOURCE_DIR}/Externals/glslang/SPIRV) # Link against glslang, the other necessary libraries are referenced by the executable. add_dolphin_library(videovulkan "${SRCS}" "${LIBS}") -target_link_libraries(videovulkan glslang) +target_link_libraries(videovulkan PRIVATE glslang) diff --git a/Source/Core/VideoCommon/CMakeLists.txt b/Source/Core/VideoCommon/CMakeLists.txt index cb9bc61720..b7138ec6df 100644 --- a/Source/Core/VideoCommon/CMakeLists.txt +++ b/Source/Core/VideoCommon/CMakeLists.txt @@ -62,5 +62,5 @@ endif() add_dolphin_library(videocommon "${SRCS}" "${LIBS}") if(LIBAV_FOUND) - target_link_libraries(videocommon ${LIBS} ${LIBAV_LIBRARIES}) + target_link_libraries(videocommon PRIVATE ${LIBS} ${LIBAV_LIBRARIES}) endif()