File tree Expand file tree Collapse file tree 4 files changed +31
-10
lines changed
Expand file tree Collapse file tree 4 files changed +31
-10
lines changed Original file line number Diff line number Diff line change 44Makefile
55moc_ * .cpp
66* .pro.user *
7+ # CMake build directory
8+ build /
Original file line number Diff line number Diff line change 1- cmake_minimum_required (VERSION 3.16 )
1+ cmake_minimum_required (VERSION 3.21 )
22
33project (SmtpMime
44 VERSION 2.0
@@ -13,22 +13,36 @@ set(CMAKE_AUTOUIC OFF)
1313set (CMAKE_AUTOMOC ON )
1414set (CMAKE_AUTORCC OFF )
1515
16- find_package (QT NAMES Qt6 COMPONENTS Core Network REQUIRED )
17- find_package (Qt${QT_VERSION_MAJOR} COMPONENTS Core Network REQUIRED )
16+ find_package (QT NAMES Qt6 COMPONENTS Core Network Test REQUIRED )
17+ find_package (Qt${QT_VERSION_MAJOR} COMPONENTS Core Network Test REQUIRED )
1818
1919set (LIBRARY_TARGET_NAME ${PROJECT_NAME} )
2020
21- message (USING Qt${QT_VERSION_MAJOR} )
21+ message ("Using Qt" ${QT_VERSION_MAJOR} )
22+
23+ #
24+ # Allow -DBUILD_SHARED_LIBS to control the library type built by qt_add_library
25+ #
26+ qt_policy (SET QTP0003 NEW )
27+
28+ #
29+ # Set the default for BUILD_SHARED_LIBS to ON, but allow command line
30+ # to override using -DBUILD_SHARED_LIBS=OFF
31+ #
32+ option (BUILD_SHARED_LIBS "Build as a shared library" ON )
2233
23- set (CMAKE_SKIP_BUILD_RPATH FALSE )
24- #set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE) # note: this breaks the demos
2534set (CMAKE_INSTALL_RPATH $ORIGIN)
2635
36+ if (BUILD_SHARED_LIBS )
37+ add_compile_options (-DBUILD_SHARED_LIBS )
38+ endif ()
39+
2740add_subdirectory (src )
2841
2942if (BUILD_TESTS)
3043 add_subdirectory (test )
3144endif ()
45+
3246if (BUILD_DEMOS)
3347 add_subdirectory (demos )
3448endif ()
Original file line number Diff line number Diff line change 11add_compile_options (-DSMTP_MIME_LIBRARY )
22
3- qt_add_library (${LIBRARY_TARGET_NAME} SHARED
3+ qt_add_library (${LIBRARY_TARGET_NAME}
44 emailaddress.cpp
55 mimeattachment.cpp
66 mimebytearrayattachment.cpp
@@ -91,3 +91,4 @@ install(TARGETS ${LIBRARY_TARGET_NAME}
9191 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
9292 PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} /smtpmime
9393)
94+
Original file line number Diff line number Diff line change 11#ifndef SMTPMIME_GLOBAL_H
22#define SMTPMIME_GLOBAL_H
33
4- #ifdef SMTP_MIME_LIBRARY
5- #define SMTP_MIME_EXPORT Q_DECL_EXPORT
4+ #if defined(BUILD_SHARED_LIBS )
5+ # ifdef SMTP_MIME_LIBRARY
6+ # define SMTP_MIME_EXPORT Q_DECL_EXPORT
7+ # else
8+ # define SMTP_MIME_EXPORT Q_DECL_IMPORT
9+ # endif
610#else
7- #define SMTP_MIME_EXPORT Q_DECL_IMPORT
11+ # define SMTP_MIME_EXPORT
812#endif
913
1014#endif // SMTPMIME_GLOBAL_H
You can’t perform that action at this time.
0 commit comments