blob: e9ab41f01f970f57e672b5b06ba7d2d481df0dd6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 26118eb..ccda00b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -141,7 +141,12 @@ set(XEUS_SOURCES
# Output
# ======
-add_library(xeus SHARED ${XEUS_SOURCES} ${XEUS_HEADERS})
+option(BUILD_SHARED_LIBS "Build shared instead of static libraries." ON)
+if (BUILD_SHARED_LIBS)
+ add_library(xeus SHARED ${XEUS_SOURCES} ${XEUS_HEADERS})
+else ()
+ add_library(xeus STATIC ${XEUS_SOURCES} ${XEUS_HEADERS})
+endif ()
if (APPLE)
set_target_properties(xeus PROPERTIES
@@ -166,9 +171,9 @@ target_link_libraries(xeus
OPTION(XEUS_USE_SHARED_CRYPTOPP "Used shared library for cryptopp" OFF)
if (XEUS_USE_SHARED_CRYPTOPP)
- target_link_libraries(xeus PRIVATE cryptopp-shared)
+ target_link_libraries(xeus PUBLIC cryptopp-shared)
else ()
- target_link_libraries(xeus PRIVATE cryptopp-static)
+ target_link_libraries(xeus PUBLIC cryptopp-static)
endif ()
if(NOT MSVC)
@@ -226,6 +231,10 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU"
message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
endif()
+if (NOT BUILD_SHARED_LIBS)
+ target_compile_definitions(xeus PUBLIC XEUS_STATIC_LIB)
+endif ()
+
if(MSVC)
target_compile_definitions(xeus PUBLIC -DNOMINMAX)
target_compile_options(xeus PUBLIC /DGUID_WINDOWS /MP /bigobj)
diff --git a/include/xeus/xeus.hpp b/include/xeus/xeus.hpp
index 99e1d79..522bb78 100644
--- a/include/xeus/xeus.hpp
+++ b/include/xeus/xeus.hpp
@@ -10,10 +10,14 @@
#define XEUS_EXPORT_HPP
#ifdef _WIN32
- #ifdef XEUS_EXPORTS
- #define XEUS_API __declspec(dllexport)
+ #ifdef XEUS_STATIC_LIB
+ #define XEUS_API
#else
- #define XEUS_API __declspec(dllimport)
+ #ifdef XEUS_EXPORTS
+ #define XEUS_API __declspec(dllexport)
+ #else
+ #define XEUS_API __declspec(dllimport)
+ #endif
#endif
#else
#define XEUS_API
|