hyperrealm / libconfig

C/C++ library for processing configuration files
https://hyperrealm.github.io/libconfig/
GNU Lesser General Public License v2.1
1.1k stars 360 forks source link

cmake: use target properties to define shared/static defines #185

Closed madebr closed 3 years ago

madebr commented 3 years ago

By applying them on the target, these are also available in the installed libconfigConfig.cmake scripts

The DEFINE_SYMBOL property is only active when building shared libraries.

This also fixes building libconfig on Linux with a mingw toolchain.

CMAKE_HOST_WIN32 is a property for the system running cmake. See CMAKE_HOST_SYSTEM for seeing what host means.

For cross building, you need to use CMAKE_SYSTEM_NAME. But here we are happy with WIN32 and MSVC.

After this pr, an install prefix (for a shared libconfig) looks like this:

prefix
├── bin
│   ├── libconfig++.dll
│   └── libconfig.dll
├── include
│   ├── libconfig.h
│   ├── libconfig.h++
│   └── libconfig.hh
└── lib
    ├── cmake
    │   └── libconfig
    │       ├── libconfig++Config.cmake
    │       ├── libconfigConfig.cmake
    │       ├── libconfig++Config-noconfig.cmake
    │       ├── libconfigConfig-noconfig.cmake
    │       ├── libconfig++ConfigVersion.cmake
    │       └── libconfigConfigVersion.cmake
    ├── libconfig++.dll.a
    └── libconfig.dll.a
hyperrealm commented 3 years ago

Would you mind to rebase this CL? It has a merge conflict now...then I'll merge.

madebr commented 3 years ago

@hyperrealm I've rebased this pr.

hyperrealm commented 3 years ago

Thanks!