diff --git a/CMakeLists.txt b/CMakeLists.txt index f136fda..d31fe5f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ if(CGLM_USE_C99) endif() if(MSVC) - add_definitions(-DNDEBUG -D_WINDOWS -D_USRDLL -DCGLM_EXPORTS -DCGLM_DLL) + add_definitions(-DNDEBUG -D_WINDOWS -D_USRDLL) add_compile_options(/W3 /Ox /Gy /Oi /TC) # Ref: https://skia.googlesource.com/third_party/sdl/+/refs/heads/master/CMakeLists.txt#225 @@ -75,6 +75,12 @@ add_library(${PROJECT_NAME} src/affine2d.c ) +if(CGLM_SHARED) + add_definitions(-DCGLM_EXPORTS) +else() + target_compile_definitions(${PROJECT_NAME} PUBLIC -DCGLM_STATIC) +endif() + set_target_properties(${PROJECT_NAME} PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR}) diff --git a/include/cglm/common.h b/include/cglm/common.h index 749fb5d..810d7ef 100644 --- a/include/cglm/common.h +++ b/include/cglm/common.h @@ -23,7 +23,9 @@ #include #if defined(_MSC_VER) -# ifdef CGLM_DLL +# ifdef CGLM_STATIC +# define CGLM_EXPORT +# elif defined(CGLM_EXPORTS) # define CGLM_EXPORT __declspec(dllexport) # else # define CGLM_EXPORT __declspec(dllimport) diff --git a/win/cglm.vcxproj b/win/cglm.vcxproj index 86b1fc6..8e6e1e7 100644 --- a/win/cglm.vcxproj +++ b/win/cglm.vcxproj @@ -209,7 +209,7 @@ NotUsing Level3 MaxSpeed - WIN32;_DEBUG;_WINDOWS;_USRDLL;CGLM_EXPORTS;CGLM_DLL;%(PreprocessorDefinitions);CGLM_DLL + WIN32;_DEBUG;_WINDOWS;_USRDLL;CGLM_EXPORTS;%(PreprocessorDefinitions) None Default @@ -225,7 +225,7 @@ Level3 MaxSpeed - _DEBUG;_WINDOWS;_USRDLL;CGLM_EXPORTS;CGLM_DLL;%(PreprocessorDefinitions);CGLM_DLL + _DEBUG;_WINDOWS;_USRDLL;CGLM_EXPORTS;%(PreprocessorDefinitions) AnySuitable true true @@ -246,7 +246,7 @@ MaxSpeed true true - WIN32;NDEBUG;_WINDOWS;_USRDLL;CGLM_EXPORTS;CGLM_DLL;%(PreprocessorDefinitions);CGLM_DLL + WIN32;NDEBUG;_WINDOWS;_USRDLL;CGLM_EXPORTS;%(PreprocessorDefinitions) None CompileAsC @@ -266,7 +266,7 @@ MaxSpeed true true - NDEBUG;_WINDOWS;_USRDLL;CGLM_EXPORTS;CGLM_DLL;%(PreprocessorDefinitions);CGLM_DLL + NDEBUG;_WINDOWS;_USRDLL;CGLM_EXPORTS;%(PreprocessorDefinitions) None CompileAsC