summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2017-11-12 20:21:46 -0800
committerArseny Kapoulkine <arseny.kapoulkine@gmail.com>2017-11-12 20:21:46 -0800
commit6016e2180e7364f8e203aa2bac6ecb093be0e875 (patch)
tree8ba47291c76d4074fe73193604441b4b8ebe25b5 /CMakeLists.txt
parent492ebc22bc2a7bf6710d5e154dd6f37c120de4fd (diff)
CMake: Add __declspec(dllexport) for shared library builds
This makes sure that MSVC shared library build actually exports all the needed symbols and generates import table. Somehow, this is actually enough to make pugixml link as a DLL - there's no need to specify __declspec(dllimport) even though pugixml exports classes via DLL. Fixes #113.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt5
1 files changed, 5 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 855045c..dbae2f1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -42,6 +42,11 @@ else()
add_library(pugixml STATIC ${SOURCES})
endif()
+# Export symbols for shared library builds
+if(BUILD_SHARED_LIBS AND MSVC)
+ target_compile_definitions(pugixml PRIVATE "PUGIXML_API=__declspec(dllexport)")
+endif()
+
# Enable C++11 long long for compilers that are capable of it
if(NOT ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} STRLESS 3.1 AND ";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";cxx_long_long_type;")
target_compile_features(pugixml PUBLIC cxx_long_long_type)