From ca421f7811025cbaf9b4958f4ff741e860f6672f Mon Sep 17 00:00:00 2001 From: Overhatted <15021741+Overhatted@users.noreply.github.com> Date: Fri, 29 Nov 2024 20:14:55 +0000 Subject: [PATCH] Added LM_STATIC preprocessor flag when doing a static build (#243) --- CMakeLists.txt | 1 + include/libmem/api.h | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 534057a6..e32f5f7a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -97,6 +97,7 @@ set(LIBMEM_DEPS if (LIBMEM_BUILD_STATIC) add_library(libmem STATIC ${LIBMEM_SRC}) + target_compile_definitions(libmem PUBLIC LM_STATIC) else() add_library(libmem SHARED ${LIBMEM_SRC}) endif() diff --git a/include/libmem/api.h b/include/libmem/api.h index 9ec5efcb..886fbfa6 100644 --- a/include/libmem/api.h +++ b/include/libmem/api.h @@ -40,10 +40,14 @@ #endif /* Resolve import/export */ -#ifdef LM_EXPORT -# define LM_API LM_API_EXPORT +#ifdef LM_STATIC +# define LM_API #else -# define LM_API LM_API_IMPORT +# ifdef LM_EXPORT +# define LM_API LM_API_EXPORT +# else +# define LM_API LM_API_IMPORT +# endif #endif /* Calling convention */