2021-01-30 08:51:39 +02:00
set ( TESTUNIT "Foundation-testrunner" )
# Sources
file ( GLOB SRCS_G "src/*.cpp" )
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
)
list ( REMOVE_ITEM SRCS_G ${ SRCS_G_REMOVE } )
POCO_SOURCES_AUTO ( TEST_SRCS ${ SRCS_G } )
# Headers
file ( GLOB_RECURSE HDRS_G "src/*.h" )
POCO_HEADERS_AUTO ( TEST_SRCS ${ HDRS_G } )
# WinDriver depends on WinTestRunner which depends on MFC, and we don't want that
POCO_SOURCES_AUTO_PLAT ( TEST_SRCS OFF
s r c / W i n D r i v e r . c p p
)
POCO_SOURCES_AUTO_PLAT ( TEST_SRCS WINCE
s r c / W i n C E D r i v e r . c p p
)
add_executable ( Foundation-testrunner ${ TEST_SRCS } )
if ( ANDROID )
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
)
else ( )
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
)
endif ( )
target_link_libraries ( Foundation-testrunner PUBLIC Poco::Foundation CppUnit )
if ( UNIX AND NOT ANDROID )
target_link_libraries ( Foundation-testrunner PUBLIC pthread )
endif ( UNIX AND NOT ANDROID )
# TestApp
if ( WINCE )
add_executable ( TestApp src/TestApp_WINCE.cpp )
set_target_properties ( TestApp PROPERTIES LINK_FLAGS "/ENTRY:wmainCRTStartup" )
else ( )
add_executable ( TestApp src/TestApp.cpp )
endif ( )
# The test is run in the runtime directory. So the TestApp is built there too because it is used by the tests
set_target_properties ( TestApp PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${ CMAKE_RUNTIME_OUTPUT_DIRECTORY } )
target_link_libraries ( TestApp PUBLIC Poco::Foundation )
# TestLibrary
add_library ( TestLibrary SHARED src/TestLibrary.cpp src/TestPlugin.cpp src/TestPlugin.h )
2023-03-23 20:19:11 +02:00
set_target_properties ( TestLibrary PROPERTIES PREFIX "" DEBUG_POSTFIX "d" ) # The test requires the library named TestLibrary. By default it is prefixed with lib.
2021-01-30 08:51:39 +02:00
# The test is run in the runtime directory. So the TestLibrary is built there too because it is used by the tests
set_target_properties ( TestLibrary PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${ CMAKE_RUNTIME_OUTPUT_DIRECTORY } )
target_link_libraries ( TestLibrary PUBLIC Poco::Foundation )
add_dependencies ( Foundation-testrunner TestApp TestLibrary )