rdbo / libmem

Advanced Game Hacking Library for C, Modern C++, Rust and Python (Windows/Linux/FreeBSD) (Process/Memory Hacking) (Hooking/Detouring) (Cross Platform) (x86/x64/ARM/ARM64) (DLL/SO Injection) (Internal/External) (Assembler/Disassembler)
GNU Affero General Public License v3.0
748 stars 90 forks source link

Fix MSVC runtime library selection #157

Closed nathan818fr closed 7 months ago

nathan818fr commented 7 months ago

A few objects in the libmem windows-msvc static library use the wrong runtime library. This leads to a warning at link time: LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs.

It's caused by:

  1. In some places, I had used KEYSTONE_CMAKE_ARGS instead of CAPSTONE_CMAKE_ARGS.
  2. The Capstone v4 CMakeLists.txt contains hardcoded /MT flags (this is clearly a mistake, and has been fixed in v5).

With this commit, the Capstone CMakeLists.txt is patched before calling ExternalProject_Add to void the hardcoded /MT flags. This is a bit hacky, but it works. And it seems much easier than forking capstone only to change that.

I've tested all the scenarios now and everything works.