Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

USD_STATIC #213

Closed
meshula opened this issue May 12, 2017 · 2 comments
Closed

USD_STATIC #213

meshula opened this issue May 12, 2017 · 2 comments

Comments

@meshula
Copy link
Member

meshula commented May 12, 2017

AR_STATIC
ARCH_STATIC
CAMERAUTIL_STATIC
GF_STATIC
...
TF_STATIC
USDGEOM_STATIC
... etc.

Every module I have in my project that uses USD as a static library, and indeed every module within my static build of USD itself (modulo some modicum of common sense of course) has got to have every other static define mutually defined. When a new module is introduced, I have to touch upwards of a couple dozen projects to add NEWTHING_STATIC everywhere. If I miss even one the consequences are potentially trivial (build broken) to bad (symbols leaked).

This is the reason we defined OPENEXR_DLL for the several dylibs in OpenEXR *; one define ensures correct linkages across the board.

#if defined(OPENEXR_DLL)
    #if defined(IMATH_EXPORTS)
	    #define IMATH_EXPORT __declspec(dllexport)
        #define IMATH_EXPORT_CONST extern __declspec(dllexport)
    #else
	    #define IMATH_EXPORT __declspec(dllimport)
	    #define IMATH_EXPORT_CONST extern __declspec(dllimport)
    #endif
#else
    #define IMATH_EXPORT
    #define IMATH_EXPORT_CONST extern const
#endif
  • (poorly named, my fault, didn't know about visibility attributes back then!)

Anyway, on ingesting a USD drop, I am now hacking the headers like this, because I keep getting stung by programmers unfamiliar with USD messing things up (and by forgetting to vet the defines myself on occasion). Consequently, I've set USD_STATIC up across all projects, and I can tell new participants to make sure USD_STATIC is set; that's far more robust than requesting they set the roughly two dozen existing STATIC defines.

I'd like to request considering replacing AR_STATIC, ARCH_STATIC, etc., with USD_STATIC.

Thanks

#if defined(USD_STATIC)
#   define PLUG_API
#   define PLUG_API_TEMPLATE_CLASS(...)
#   define PLUG_API_TEMPLATE_STRUCT(...)
#   define PLUG_LOCAL
#else
#   if defined(PLUG_EXPORTS)
#       define PLUG_API ARCH_EXPORT
#       define PLUG_API_TEMPLATE_CLASS(...) ARCH_EXPORT_TEMPLATE(class, __VA_ARGS__)
#       define PLUG_API_TEMPLATE_STRUCT(...) ARCH_EXPORT_TEMPLATE(struct, __VA_ARGS__)
#   else
#       define PLUG_API ARCH_IMPORT
#       define PLUG_API_TEMPLATE_CLASS(...) ARCH_IMPORT_TEMPLATE(class, __VA_ARGS__)
#       define PLUG_API_TEMPLATE_STRUCT(...) ARCH_IMPORT_TEMPLATE(struct, __VA_ARGS__)
#   endif
#   define PLUG_LOCAL ARCH_HIDDEN
#endif
@jtran56
Copy link

jtran56 commented May 15, 2017

Filed as internal issue #146471.

pixar-oss added a commit that referenced this issue May 22, 2017
We don't want to support building some libraries as static and
some shared and having a different *_STATIC macro for each
library just makes using a statically built USD a pain since
clients must define each *_STATIC macro for every library used
(transitively).  With this change the USD build and clients
need to define just one macro, PXR_USD_STATIC, when building
or using a static USD.

Fixes #213.

(Internal change: 1748874)
(Internal change: 1748895)
(Internal change: 1748930)
@meshula
Copy link
Member Author

meshula commented May 23, 2017

Thanks!

@meshula meshula closed this as completed May 23, 2017
AdamFelt pushed a commit to autodesk-forks/USD that referenced this issue Apr 16, 2024
…sea/OGSMOD-2701

OGSMOD-2701: Merge USD public to Adsk/dev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants