2018-06-03 18:17:50 +02:00
set ( TESTUNIT "Foundation-testrunner" )
2014-08-22 17:10:24 +02:00
# Sources
file ( GLOB SRCS_G "src/*.cpp" )
2020-02-14 11:07:32 +01:00
file ( GLOB SRCS_G_REMOVE
s r c / T e s t A p p . c p p
s r c / T e s t A p p _ W I N C E . c p p
s r c / T e s t L i b r a r y . c p p
s r c / T e s t P l u g i n . c p p
2012-06-26 14:37:02 +02:00
)
2014-08-22 17:10:24 +02:00
list ( REMOVE_ITEM SRCS_G ${ SRCS_G_REMOVE } )
2020-02-14 11:07:32 +01:00
POCO_SOURCES_AUTO ( TEST_SRCS ${ SRCS_G } )
2014-08-22 17:10:24 +02:00
# Headers
2020-02-14 11:07:32 +01:00
file ( GLOB_RECURSE HDRS_G "src/*.h" )
POCO_HEADERS_AUTO ( TEST_SRCS ${ HDRS_G } )
2012-06-26 14:37:02 +02:00
2014-12-11 13:24:56 +01:00
# WinDriver depends on WinTestRunner which depends on MFC, and we don't want that
2020-02-14 11:07:32 +01:00
POCO_SOURCES_AUTO_PLAT ( TEST_SRCS OFF
s r c / W i n D r i v e r . c p p
2012-06-26 14:37:02 +02:00
)
2020-02-14 11:07:32 +01:00
POCO_SOURCES_AUTO_PLAT ( TEST_SRCS WINCE
s r c / W i n C E D r i v e r . c p p
2014-08-22 17:10:24 +02:00
)
2012-06-26 14:37:02 +02:00
2020-02-14 11:07:32 +01:00
add_executable ( Foundation-testrunner ${ TEST_SRCS } )
2018-02-27 01:54:40 +01:00
if ( ANDROID )
2020-02-14 11:07:32 +01:00
add_test (
N A M E F o u n d a t i o n
W O R K I N G _ D I R E C T O R Y $ { C M A K E _ R U N T I M E _ O U T P U T _ D I R E C T O R Y }
C O M M A N D $ { C M A K E _ C O M M A N D } - D A N D R O I D _ N D K = $ { A N D R O I D _ N D K } " - D T E S T _ F I L E S = $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / d a t a ; $ { C M A K E _ B I N A R Y _ D I R } / b i n / T e s t A p p ; $ { C M A K E _ B I N A R Y _ D I R } / b i n / T e s t L i b r a r y . s o " - D L I B R A R Y _ D I R = $ { C M A K E _ B I N A R Y _ D I R } / l i b - D U N I T T E S T = $ { C M A K E _ B I N A R Y _ D I R } / b i n / F o u n d a t i o n - t e s t r u n n e r - D T E S T _ P A R A M E T E R = - a l l - P $ { C M A K E _ S O U R C E _ D I R } / c m a k e / E x e c u t e O n A n d r o i d . c m a k e
)
2018-02-27 01:54:40 +01:00
else ( )
2020-02-14 11:07:32 +01:00
add_test (
N A M E F o u n d a t i o n
W O R K I N G _ D I R E C T O R Y $ { C M A K E _ R U N T I M E _ O U T P U T _ D I R E C T O R Y }
C O M M A N D F o u n d a t i o n - t e s t r u n n e r - i g n o r e $ { C M A K E _ S O U R C E _ D I R } / c p p i g n o r e . l n x - a l l
)
set_tests_properties ( Foundation PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" ) # The SharedLibaryTest has to look for shared libraries in the working directory
set_property ( TEST Foundation APPEND PROPERTY ENVIRONMENT "PATH=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}:$ENV{PATH}" ) # The ProcessTest has to look for the TestApp in the working directory
set_property ( TEST Foundation APPEND PROPERTY ENVIRONMENT "POCO_BASE=${CMAKE_SOURCE_DIR}" )
# The test is run in the runtime directory. So the test data is copied there too
add_custom_command (
T A R G E T F o u n d a t i o n - t e s t r u n n e r P O S T _ B U I L D
C O M M A N D $ { C M A K E _ C O M M A N D } - E c o p y _ d i r e c t o r y $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / d a t a $ { C M A K E _ R U N T I M E _ O U T P U T _ D I R E C T O R Y } / d a t a
)
2018-02-27 01:54:40 +01:00
endif ( )
2014-12-11 13:24:56 +01:00
2020-02-14 11:07:32 +01:00
target_link_libraries ( Foundation-testrunner PUBLIC Poco::Foundation CppUnit )
2018-02-27 01:54:40 +01:00
if ( UNIX AND NOT ANDROID )
2018-06-03 18:17:50 +02:00
target_link_libraries ( Foundation-testrunner PUBLIC pthread )
2018-02-27 01:54:40 +01:00
endif ( UNIX AND NOT ANDROID )
2012-06-26 14:37:02 +02:00
2014-08-22 17:10:24 +02:00
# TestApp
2014-12-11 13:25:40 +01:00
if ( WINCE )
2020-02-14 11:07:32 +01:00
add_executable ( TestApp src/TestApp_WINCE.cpp )
2018-06-03 18:17:50 +02:00
set_target_properties ( TestApp PROPERTIES LINK_FLAGS "/ENTRY:wmainCRTStartup" )
2014-12-11 13:25:40 +01:00
else ( )
2020-02-14 11:07:32 +01:00
add_executable ( TestApp src/TestApp.cpp )
2014-12-11 13:25:40 +01:00
endif ( )
2014-08-22 17:10:24 +02:00
# The test is run in the runtime directory. So the TestApp is built there too because it is used by the tests
2020-02-14 11:07:32 +01:00
set_target_properties ( TestApp PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${ CMAKE_RUNTIME_OUTPUT_DIRECTORY } )
target_link_libraries ( TestApp PUBLIC Poco::Foundation )
2012-06-26 14:37:02 +02:00
2014-08-22 17:10:24 +02:00
# TestLibrary
2020-02-14 11:07:32 +01:00
add_library ( TestLibrary SHARED src/TestLibrary.cpp src/TestPlugin.cpp src/TestPlugin.h )
2018-06-03 18:17:50 +02:00
set_target_properties ( TestLibrary PROPERTIES PREFIX "" DEBUG_POSTFIX "" ) # The test requires the library named TestLibrary. By default it is prefixed with lib.
2014-08-22 17:10:24 +02:00
# The test is run in the runtime directory. So the TestLibrary is built there too because it is used by the tests
2020-02-14 11:07:32 +01:00
set_target_properties ( TestLibrary PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${ CMAKE_RUNTIME_OUTPUT_DIRECTORY } )
target_link_libraries ( TestLibrary PUBLIC Poco::Foundation )
2012-06-26 14:37:02 +02:00
2018-06-03 18:17:50 +02:00
add_dependencies ( Foundation-testrunner TestApp TestLibrary )