Skip to content

Commit 23d2aa5

Browse files
committed
Fix compilation of test when PythonQt_Wrap_Qtcore option is disabled
This commit fixes the following link error: PythonQtTestMain.cpp:(.text+0x1637): undefined reference to `PythonQtTestCleanup::~PythonQtTestCleanup()'
1 parent cbf890f commit 23d2aa5

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,8 @@ if(BUILD_TESTING)
270270
tests/PythonQtTestMain.cpp
271271
)
272272

273+
set_property(SOURCE tests/PythonQtTestMain.cpp PROPERTY COMPILE_DEFINITIONS "main=tests_PythonQtTestMain")
274+
273275
list(APPEND test_sources
274276
tests/PythonQtTests.cpp
275277
tests/PythonQtTests.h
@@ -289,9 +291,9 @@ if(BUILD_TESTING)
289291
QT4_WRAP_CPP(test_sources
290292
tests/PythonQtTestCleanup.h
291293
)
292-
endif()
293294

294-
set_property(SOURCE tests/PythonQtTestMain.cpp PROPERTY COMPILE_DEFINITIONS "main=tests_PythonQtTestMain")
295+
set_property(SOURCE tests/PythonQtTestMain.cpp APPEND PROPERTY COMPILE_DEFINITIONS "PythonQt_Wrap_Qtcore")
296+
endif()
295297

296298
add_executable(PythonQtCppTests ${test_sources})
297299
target_link_libraries(PythonQtCppTests PythonQt)

tests/PythonQtTestMain.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ int main(int argc, char *argv[])
6565
Py_Finalize();
6666
}
6767

68+
#ifdef PythonQt_Wrap_Qtcore
6869
PythonQtTestCleanup cleanup;
6970
failCount += QTest::qExec(&cleanup, argc, argv);
7071

@@ -73,6 +74,8 @@ int main(int argc, char *argv[])
7374
} else {
7475
std::cout << "All tests passed successfully." << std::endl;
7576
}
77+
#endif
78+
7679
return failCount;
7780
}
7881

0 commit comments

Comments
 (0)