Skip to content

Commit

Permalink
Implement macro for library version info #172 #45
Browse files Browse the repository at this point in the history
  • Loading branch information
sammycage committed Jul 7, 2024
1 parent 73da3ef commit 3342507
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ project(lunasvg VERSION 2.4.0 LANGUAGES CXX C)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_C_STANDARD 11)

option(BUILD_SHARED_LIBS "Build as a shared library" OFF)
option(BUILD_SHARED_LIBS "Build as a shared library" ON)
option(LUNASVG_BUILD_EXAMPLES "Build example(s)" OFF)

add_library(lunasvg)
Expand All @@ -14,9 +14,9 @@ add_subdirectory(include)
add_subdirectory(source)
add_subdirectory(3rdparty/plutovg)

if(BUILD_SHARED_LIBS)
target_compile_definitions(lunasvg PUBLIC LUNASVG_SHARED)
target_compile_definitions(lunasvg PRIVATE LUNASVG_EXPORT)
target_compile_definitions(lunasvg PRIVATE LUNASVG_BUILD)
if(NOT BUILD_SHARED_LIBS)
target_compile_definitions(lunasvg PRIVATE LUNASVG_BUILD_STATIC)
endif()

if(LUNASVG_BUILD_EXAMPLES)
Expand Down
28 changes: 23 additions & 5 deletions include/lunasvg.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,34 @@
#include <string>
#include <map>

#if defined(_MSC_VER) && defined(LUNASVG_SHARED)
#ifdef LUNASVG_EXPORT
#define LUNASVG_API __declspec(dllexport)
#if !defined(LUNASVG_BUILD_STATIC) && (defined(_WIN32) || defined(__CYGWIN__))
#define LUNASVG_EXPORT __declspec(dllexport)
#define LUNASVG_IMPORT __declspec(dllimport)
#elif defined(__GNUC__) && (__GNUC__ >= 4)
#define LUNASVG_EXPORT __attribute__((__visibility__("default")))
#define LUNASVG_IMPORT
#else
#define LUNASVG_API __declspec(dllimport)
#define LUNASVG_EXPORT
#define LUNASVG_IMPORT
#endif

#ifdef LUNASVG_BUILD
#define LUNASVG_API LUNASVG_EXPORT
#else
#define LUNASVG_API
#define LUNASVG_API LUNASVG_IMPORT
#endif

#define LUNASVG_VERSION_MAJOR 2
#define LUNASVG_VERSION_MINOR 4
#define LUNASVG_VERSION_MICRO 0

#define LUNASVG_VERSION_ENCODE(major, minor, micro) (((major) * 10000) + ((minor) * 100) + ((micro) * 1))
#define LUNASVG_VERSION LUNASVG_VERSION_ENCODE(LUNASVG_VERSION_MAJOR, LUNASVG_VERSION_MINOR, LUNASVG_VERSION_MICRO)

#define LUNASVG_VERSION_XSTRINGIZE(major, minor, micro) #major"."#minor"."#micro
#define LUNASVG_VERSION_STRINGIZE(major, minor, micro) LUNASVG_VERSION_XSTRINGIZE(major, minor, micro)
#define LUNASVG_VERSION_STRING LUNASVG_VERSION_STRINGIZE(LUNASVG_VERSION_MAJOR, LUNASVG_VERSION_MINOR, LUNASVG_VERSION_MICRO)

namespace lunasvg {

class Rect;
Expand Down

0 comments on commit 3342507

Please sign in to comment.