cmakeconfig.h.in defines ENABLE_SHARED as follows:

`#define ENABLE_SHARED @BUILD_SHARED_LIBS@`

And uses it in common.h as follows:

```
#ifndef EXPORT
#  if defined(_WIN32) && defined(ENABLE_SHARED)
```

There are two bugs causing this not to work correctly with CMake:

1) The CMake functions which define BUILD_SHARED_LIBS happen _after_ config.h has been generated.  This is only an issue if the parent CMake script did not explicitly set this variable.
2) If any part of the CMake script decides to set BUILD_SHARED_LIBS to OFF, config.h will then contain the following #define:

`#define ENABLE_SHARED OFF`

This causes the defined(ENABLE_SHARED) check to pass, rather than fail.

The following solution seems to resolve the issue:

1) In cmakeconfig.h.in, use `#cmakedefine ENABLE_SHARED` in place of `#define ENABLE_SHARED @BUILD_SHARED_LIBS@`
2) Reorder CMakeLists.txt such that the lines controlling BUILD_SHARED_LIBS are executed before the lines generating config.h

BUILD_SHARED_LIBS not respected on WIN32
This is a GitHub Issue
repo:libredwg
owner:LibreDWG
Title : BUILD_SHARED_LIBS not respected on WIN32
Issue date:

--- start body ---
cmakeconfig.h.in defines ENABLE_SHARED as follows:

`#define ENABLE_SHARED @BUILD_SHARED_LIBS@`

And uses it in common.h as follows:

```
#ifndef EXPORT
#  if defined(_WIN32) && defined(ENABLE_SHARED)
```

There are two bugs causing this not to work correctly with CMake:

1) The CMake functions which define BUILD_SHARED_LIBS happen _after_ config.h has been generated.  This is only an issue if the parent CMake script did not explicitly set this variable.
2) If any part of the CMake script decides to set BUILD_SHARED_LIBS to OFF, config.h will then contain the following #define:

`#define ENABLE_SHARED OFF`

This causes the defined(ENABLE_SHARED) check to pass, rather than fail.

The following solution seems to resolve the issue:

1) In cmakeconfig.h.in, use `#cmakedefine ENABLE_SHARED` in place of `#define ENABLE_SHARED @BUILD_SHARED_LIBS@`
2) Reorder CMakeLists.txt such that the lines controlling BUILD_SHARED_LIBS are executed before the lines generating config.h

--- end body ---
