Skip to content

Commit 651427e

Browse files
author
feihong
committed
add static link support
1 parent e0291e7 commit 651427e

File tree

4 files changed

+21
-20
lines changed

4 files changed

+21
-20
lines changed

extensions/PythonQt_QtAll/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ file(GLOB SOURCES *.h *.cpp)
66

77
if(BUILD_SHARED_LIBS)
88
add_library(${PROJECT_NAME} SHARED)
9+
target_compile_definitions(${PROJECT_NAME} PRIVATE PYTHONQT_QTALL_EXPORTS)
910
else()
1011
add_library(${PROJECT_NAME} STATIC)
12+
target_compile_definitions(${PROJECT_NAME} PUBLIC PYTHONQT_QTALL_STATIC)
1113
endif()
1214

1315
target_sources(${PROJECT_NAME} PRIVATE
@@ -21,7 +23,6 @@ target_link_libraries(${PROJECT_NAME} PUBLIC
2123

2224
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_LIST_DIR})
2325

24-
target_compile_definitions(${PROJECT_NAME} PRIVATE PYTHONQT_QTALL_EXPORTS)
2526

2627
list(APPEND QTMODULES Core Gui Svg Sql Network OpenGL Xml XmlPatterns Multimedia Qml Quick UiTools WebEngineWidgets WebKit)
2728

extensions/PythonQt_QtAll/PythonQt_QtAll.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,16 @@
3333
*
3434
*/
3535

36-
#ifdef WIN32
37-
#ifdef PYTHONQT_QTALL_EXPORTS
38-
#define PYTHONQT_QTALL_EXPORT __declspec(dllexport)
39-
#else
40-
#define PYTHONQT_QTALL_EXPORT __declspec(dllimport)
41-
#endif
36+
#include <QtCore/qglobal.h>
37+
38+
#ifndef PYTHONQT_QTALL_STATIC
39+
# if defined(PYTHONQT_QTALL_EXPORTS)
40+
# define PYTHONQT_QTALL_EXPORT Q_DECL_EXPORT
41+
# else
42+
# define PYTHONQT_QTALL_EXPORT Q_DECL_IMPORT
43+
# endif
4244
#else
43-
#define PYTHONQT_QTALL_EXPORT
45+
# define PYTHONQT_QTALL_EXPORT
4446
#endif
4547

4648
namespace PythonQt_QtAll

src/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ file(GLOB SOURCES *.h *.cpp)
99

1010
if(BUILD_SHARED_LIBS)
1111
add_library(${PROJECT_NAME} SHARED)
12+
target_compile_definitions(${PROJECT_NAME} PRIVATE PYTHONQT_EXPORTS)
1213
else()
1314
add_library(${PROJECT_NAME} STATIC)
15+
target_compile_definitions(${PROJECT_NAME} PUBLIC PYTHONQT_STATIC)
1416
endif()
1517

1618
file(GLOB GENERATE_SOURCES

src/PythonQtSystem.h

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,17 @@
4242
*/
4343
//----------------------------------------------------------------------------------
4444

45+
#include <QtCore/qglobal.h>
4546

46-
#if defined(WIN32)
47-
#ifdef PYTHONQT_EXPORTS
48-
#define PYTHONQT_EXPORT __declspec(dllexport)
49-
#else
50-
#define PYTHONQT_EXPORT __declspec(dllimport)
51-
#endif
47+
#ifndef PYTHONQT_STATIC
48+
# if defined(PYTHONQT_EXPORTS)
49+
# define PYTHONQT_EXPORT Q_DECL_EXPORT
50+
# else
51+
# define PYTHONQT_EXPORT Q_DECL_IMPORT
52+
# endif
5253
#else
53-
#ifdef PYTHONQT_EXPORTS
54-
#define PYTHONQT_EXPORT __attribute__((__visibility__("default")))
55-
#else
56-
#define PYTHONQT_EXPORT
57-
#endif
54+
# define PYTHONQT_EXPORT
5855
#endif
5956

60-
6157
#endif
6258

0 commit comments

Comments
 (0)