From 5550d7af0d08a2102d79bbf6580904e0893daa34 Mon Sep 17 00:00:00 2001 From: Felix Geyer Date: Fri, 29 Mar 2013 16:27:02 +0100 Subject: [PATCH] Fix autotype test (build) failures on Mac OS and Windows. We need to tell Windows what symbols the main program exports and the autotype plugin imports. On both systems the linker needs the path of the main program that loads the plugin. --- src/CMakeLists.txt | 3 +++ src/autotype/AutoTypeAction.h | 14 ++++++++------ src/autotype/test/CMakeLists.txt | 2 +- src/core/Global.h | 10 ++++++++++ tests/CMakeLists.txt | 1 + 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f424d765..68cc685a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -198,6 +198,7 @@ qt4_wrap_ui(keepassx_SOURCES ${keepassx_FORMS}) qt4_wrap_cpp(keepassx_SOURCES ${keepassx_MOC}) add_library(keepassx_core STATIC ${keepassx_SOURCES}) +set_target_properties(keepassx_core PROPERTIES COMPILE_DEFINITIONS KEEPASSX_BUILDING_CORE) add_executable(${PROGNAME} WIN32 MACOSX_BUNDLE ${keepassx_SOURCES_MAINEXE}) target_link_libraries(${PROGNAME} @@ -211,6 +212,8 @@ if(UNIX AND NOT APPLE) target_link_libraries(${PROGNAME} ${QT_QTDBUS_LIBRARY}) endif() +set_target_properties(${PROGNAME} PROPERTIES ENABLE_EXPORTS ON) + if(APPLE) configure_file(${CMAKE_SOURCE_DIR}/share/macosx/Info.plist.cmake ${CMAKE_CURRENT_BINARY_DIR}/Info.plist) set_target_properties(${PROGNAME} PROPERTIES diff --git a/src/autotype/AutoTypeAction.h b/src/autotype/AutoTypeAction.h index efaabeb5..1bd061c1 100644 --- a/src/autotype/AutoTypeAction.h +++ b/src/autotype/AutoTypeAction.h @@ -21,9 +21,11 @@ #include #include +#include "core/Global.h" + class AutoTypeExecutor; -class AutoTypeAction +class KEEPASSX_EXPORT AutoTypeAction { public: virtual ~AutoTypeAction() {} @@ -31,7 +33,7 @@ public: virtual void accept(AutoTypeExecutor* executor) = 0; }; -class AutoTypeChar : public AutoTypeAction +class KEEPASSX_EXPORT AutoTypeChar : public AutoTypeAction { public: explicit AutoTypeChar(const QChar& character); @@ -41,7 +43,7 @@ public: const QChar character; }; -class AutoTypeKey : public AutoTypeAction +class KEEPASSX_EXPORT AutoTypeKey : public AutoTypeAction { public: explicit AutoTypeKey(Qt::Key key); @@ -51,7 +53,7 @@ public: const Qt::Key key; }; -class AutoTypeDelay : public AutoTypeAction +class KEEPASSX_EXPORT AutoTypeDelay : public AutoTypeAction { public: explicit AutoTypeDelay(int delayMs); @@ -61,7 +63,7 @@ public: const int delayMs; }; -class AutoTypeClearField : public AutoTypeAction +class KEEPASSX_EXPORT AutoTypeClearField : public AutoTypeAction { public: explicit AutoTypeClearField(); @@ -69,7 +71,7 @@ public: void accept(AutoTypeExecutor* executor); }; -class AutoTypeExecutor +class KEEPASSX_EXPORT AutoTypeExecutor { public: virtual ~AutoTypeExecutor() {} diff --git a/src/autotype/test/CMakeLists.txt b/src/autotype/test/CMakeLists.txt index 31b1df7e..749f7d5f 100644 --- a/src/autotype/test/CMakeLists.txt +++ b/src/autotype/test/CMakeLists.txt @@ -9,4 +9,4 @@ set(autotype_test_MOC qt4_wrap_cpp(autotype_test_SOURCES ${autotype_test_MOC}) add_library(keepassx-autotype-test MODULE ${autotype_test_SOURCES}) -target_link_libraries(keepassx-autotype-test ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY}) +target_link_libraries(keepassx-autotype-test testautotype ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY}) diff --git a/src/core/Global.h b/src/core/Global.h index a2a4e5d3..b6976060 100644 --- a/src/core/Global.h +++ b/src/core/Global.h @@ -118,4 +118,14 @@ template <> class QStaticAssertFailure {}; #endif // COMPILER_STATIC_ASSERT #endif // !defined(Q_STATIC_ASSERT) && !defined(Q_STATIC_ASSERT_X) +#if defined(Q_OS_WIN) +# if defined(KEEPASSX_BUILDING_CORE) +# define KEEPASSX_EXPORT Q_DECL_EXPORT +# else +# define KEEPASSX_EXPORT Q_DECL_IMPORT +# endif +#else +# define KEEPASSX_EXPORT +#endif + #endif // KEEPASSX_GLOBAL_H diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 38018c83..02fa1029 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -154,6 +154,7 @@ add_unit_test(NAME testwildcardmatcher SOURCES TestWildcardMatcher.cpp MOCS Test add_unit_test(NAME testautotype SOURCES TestAutoType.cpp MOCS TestAutoType.h LIBS ${TEST_LIBRARIES}) +set_target_properties(testautotype PROPERTIES ENABLE_EXPORTS ON) add_unit_test(NAME testentry SOURCES TestEntry.cpp MOCS TestEntry.h LIBS ${TEST_LIBRARIES})