CMake: Only link in Bochs on x86 platforms

Bochs' disassembler is only for disassembling x86 code. On non-x86
platforms it doesn't really make sense to build and link this in.
This commit is contained in:
Lioncash 2018-06-22 18:52:34 -04:00
parent 68731995b5
commit 7f8cdbb2a4
No known key found for this signature in database
GPG Key ID: 4E3C3CC1031BA9C7
4 changed files with 28 additions and 18 deletions

View File

@ -534,7 +534,9 @@ endif()
# - place the CMakeLists.txt in the first-level subdirectory, e.g. # - place the CMakeLists.txt in the first-level subdirectory, e.g.
# Externals/zlib/CMakeLists.txt (that is: NOT in some Src/ subdirectory) # Externals/zlib/CMakeLists.txt (that is: NOT in some Src/ subdirectory)
# #
add_subdirectory(Externals/Bochs_disasm) if (_M_X86)
add_subdirectory(Externals/Bochs_disasm)
endif()
add_subdirectory(Externals/cpp-optparse) add_subdirectory(Externals/cpp-optparse)
add_subdirectory(Externals/glslang) add_subdirectory(Externals/glslang)

View File

@ -295,11 +295,15 @@ PUBLIC
videosoftware videosoftware
PRIVATE PRIVATE
bdisasm
${LZO} ${LZO}
ZLIB::ZLIB ZLIB::ZLIB
) )
if ((DEFINED CMAKE_ANDROID_ARCH_ABI AND CMAKE_ANDROID_ARCH_ABI MATCHES "x86|x86_64") OR
(NOT DEFINED CMAKE_ANDROID_ARCH_ABI AND _M_X86))
target_link_libraries(core PRIVATE bdisasm)
endif()
if (APPLE) if (APPLE)
target_link_libraries(core target_link_libraries(core
PRIVATE PRIVATE

View File

@ -16,10 +16,14 @@ PUBLIC
cpp-optparse cpp-optparse
PRIVATE PRIVATE
bdisasm
$<$<BOOL:APPLE>:${IOK_LIBRARY}> $<$<BOOL:APPLE>:${IOK_LIBRARY}>
) )
if ((DEFINED CMAKE_ANDROID_ARCH_ABI AND CMAKE_ANDROID_ARCH_ABI MATCHES "x86|x86_64") OR
(NOT DEFINED CMAKE_ANDROID_ARCH_ABI AND _M_X86))
target_link_libraries(uicommon PRIVATE bdisasm)
endif()
if(USE_X11) if(USE_X11)
target_sources(uicommon PRIVATE X11Utils.cpp) target_sources(uicommon PRIVATE X11Utils.cpp)
endif() endif()

View File

@ -1,11 +1,11 @@
#include <disasm.h> // Bochs
#if defined(HAVE_LLVM) #if defined(HAVE_LLVM)
// PowerPC.h defines PC. // PowerPC.h defines PC.
// This conflicts with a function that has an argument named PC // This conflicts with a function that has an argument named PC
#undef PC #undef PC
#include <llvm-c/Disassembler.h> #include <llvm-c/Disassembler.h>
#include <llvm-c/Target.h> #include <llvm-c/Target.h>
#elif defined(_M_X86)
#include <disasm.h> // Bochs
#endif #endif
#include "Common/StringUtil.h" #include "Common/StringUtil.h"
@ -16,18 +16,6 @@
#include "UICommon/Disassembler.h" #include "UICommon/Disassembler.h"
class HostDisassemblerX86 : public HostDisassembler
{
public:
HostDisassemblerX86();
private:
disassembler m_disasm;
std::string DisassembleHostBlock(const u8* code_start, const u32 code_size,
u32* host_instructions_count, u64 starting_pc) override;
};
#if defined(HAVE_LLVM) #if defined(HAVE_LLVM)
class HostDisassemblerLLVM : public HostDisassembler class HostDisassemblerLLVM : public HostDisassembler
{ {
@ -126,7 +114,18 @@ std::string HostDisassemblerLLVM::DisassembleHostBlock(const u8* code_start, con
return x86_disasm.str(); return x86_disasm.str();
} }
#endif #elif defined(_M_X86)
class HostDisassemblerX86 : public HostDisassembler
{
public:
HostDisassemblerX86();
private:
disassembler m_disasm;
std::string DisassembleHostBlock(const u8* code_start, const u32 code_size,
u32* host_instructions_count, u64 starting_pc) override;
};
HostDisassemblerX86::HostDisassemblerX86() HostDisassemblerX86::HostDisassemblerX86()
{ {
@ -150,6 +149,7 @@ std::string HostDisassemblerX86::DisassembleHostBlock(const u8* code_start, cons
return x86_disasm.str(); return x86_disasm.str();
} }
#endif
std::unique_ptr<HostDisassembler> GetNewDisassembler(const std::string& arch) std::unique_ptr<HostDisassembler> GetNewDisassembler(const std::string& arch)
{ {