From 92f93d47dcf53953bbe0a32fb718b28beb80b471 Mon Sep 17 00:00:00 2001 From: Zeex Date: Sun, 4 Nov 2018 21:32:20 +0600 Subject: Add option to disable #inclusion of platform-specific files into subhook.c --- CMakeLists.txt | 9 +++++++-- subhook.c | 4 ++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c4e1065..7c97ea2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,9 +31,14 @@ subhook_add_option_var(SUBHOOK_FORCE_32BIT BOOL OFF "Configure for compiling 32-bit binaries (on 64-bit systems)") set(SUBHOOK_HEADERS subhook.h) -set(SUBHOOK_SOURCES subhook.c subhook_private.h) +set(SUBHOOK_SOURCES subhook.c subhook_private.h subhook_x86.c) +if(WIN32) + list(APPEND SUBHOOK_SOURCES subhook_windows.c) +elseif(UNIX) + list(APPEND SUBHOOK_SOURCES subhook_unix.c) +endif() -add_definitions(-DSUBHOOK_IMPLEMENTATION) +add_definitions(-DSUBHOOK_IMPLEMENTATION -DSUBHOOK_SEPARATE_SOURCE_FILES) if(SUBHOOK_STATIC) add_library(subhook STATIC ${SUBHOOK_HEADERS} ${SUBHOOK_SOURCES}) diff --git a/subhook.c b/subhook.c index 7118884..3e620ce 100644 --- a/subhook.c +++ b/subhook.c @@ -54,6 +54,8 @@ SUBHOOK_EXPORT int SUBHOOK_API subhook_is_installed(subhook_t hook) { return hook->installed; } +#ifndef SUBHOOK_SEPARATE_SOURCE_FILES + #if defined SUBHOOK_WINDOWS #include "subhook_windows.c" #elif defined SUBHOOK_UNIX @@ -63,3 +65,5 @@ SUBHOOK_EXPORT int SUBHOOK_API subhook_is_installed(subhook_t hook) { #if defined SUBHOOK_X86 || defined SUBHOOK_X86_64 #include "subhook_x86.c" #endif + +#endif -- cgit v1.1