cmake: Cleanup CMakeLists.txt for all components

- Add missing CMakeLists.txt
- Use POCO_ macros to improve code structure in XCode/VisualStudio
- Better ODBC detection
- Remove unnecessary commented out code

The CMake documentation recommends explicitly listing source files, but because CMake is not the primary build system GLOB patterns are used for the moment.
This commit is contained in:
Pascal Bach
2014-08-22 17:10:24 +02:00
parent 65fcaf65a0
commit 7950001803
96 changed files with 630 additions and 1296 deletions

View File

@@ -1,172 +1,55 @@
set( TEST_SRCS
src/ActiveDispatcherTest.cpp
src/ActiveMethodTest.cpp
src/ActivityTest.cpp
src/AnyTest.cpp
src/ArrayTest.cpp
src/AutoPtrTest.cpp
src/AutoReleasePoolTest.cpp
src/Base32Test.cpp
src/Base64Test.cpp
src/BasicEventTest.cpp
src/BinaryReaderWriterTest.cpp
src/ByteOrderTest.cpp
src/CacheTestSuite.cpp
src/ChannelTest.cpp
src/ClassLoaderTest.cpp
src/ClockTest.cpp
src/ConditionTest.cpp
src/CoreTest.cpp
src/CoreTestSuite.cpp
src/CountingStreamTest.cpp
src/CryptTestSuite.cpp
src/DateTimeFormatterTest.cpp
src/DateTimeParserTest.cpp
src/DateTimeTest.cpp
src/DateTimeTestSuite.cpp
src/DigestStreamTest.cpp
src/DirectoryIteratorsTest.cpp
src/DirectoryWatcherTest.cpp
src/Driver.cpp
src/DummyDelegate.cpp
src/DynamicFactoryTest.cpp
src/DynamicTestSuite.cpp
src/EventTestSuite.cpp
src/ExpireCacheTest.cpp
src/ExpireLRUCacheTest.cpp
src/FIFOEventTest.cpp
src/FIFOBufferStreamTest.cpp
src/FPETest.cpp
src/FileChannelTest.cpp
src/FileStreamTest.cpp
src/FileTest.cpp
src/FilesystemTestSuite.cpp
src/FormatTest.cpp
src/FoundationTestSuite.cpp
src/GlobTest.cpp
src/HMACEngineTest.cpp
src/HashMapTest.cpp
src/HashSetTest.cpp
src/HashTableTest.cpp
src/HashingTestSuite.cpp
src/HexBinaryTest.cpp
src/LRUCacheTest.cpp
src/LineEndingConverterTest.cpp
src/LinearHashTableTest.cpp
src/ListMapTest.cpp
src/LocalDateTimeTest.cpp
src/LogStreamTest.cpp
src/LoggerTest.cpp
src/LoggingFactoryTest.cpp
src/LoggingRegistryTest.cpp
src/LoggingTestSuite.cpp
src/MD4EngineTest.cpp
src/MD5EngineTest.cpp
src/ManifestTest.cpp
src/MemoryPoolTest.cpp
src/MemoryStreamTest.cpp
src/NDCTest.cpp
src/NamedEventTest.cpp
src/NamedMutexTest.cpp
src/NamedTuplesTest.cpp
src/NotificationCenterTest.cpp
src/NotificationQueueTest.cpp
src/ObjectPoolTest.cpp
src/PriorityNotificationQueueTest.cpp
src/TimedNotificationQueueTest.cpp
src/NotificationsTestSuite.cpp
src/NullStreamTest.cpp
src/NumberFormatterTest.cpp
src/NumberParserTest.cpp
src/PathTest.cpp
src/PatternFormatterTest.cpp
src/PBKDF2EngineTest.cpp
src/PriorityEventTest.cpp
src/ProcessTest.cpp
src/ProcessesTestSuite.cpp
src/RWLockTest.cpp
src/RandomStreamTest.cpp
src/RandomTest.cpp
src/RegularExpressionTest.cpp
src/SHA1EngineTest.cpp
src/SemaphoreTest.cpp
src/SharedLibraryTest.cpp
src/SharedLibraryTestSuite.cpp
src/SharedMemoryTest.cpp
src/SharedPtrTest.cpp
src/SimpleFileChannelTest.cpp
src/SimpleHashTableTest.cpp
src/StopwatchTest.cpp
src/StreamConverterTest.cpp
src/StreamCopierTest.cpp
src/StreamTokenizerTest.cpp
src/StreamsTestSuite.cpp
src/StringTest.cpp
src/StringTokenizerTest.cpp
src/TaskManagerTest.cpp
src/TaskTest.cpp
src/TaskTestSuite.cpp
src/TeeStreamTest.cpp
src/TestChannel.cpp
src/TestPlugin.cpp
src/TextConverterTest.cpp
src/TextEncodingTest.cpp
src/TextIteratorTest.cpp
src/TextBufferIteratorTest.cpp
src/TextTestSuite.cpp
src/ThreadLocalTest.cpp
src/ThreadPoolTest.cpp
src/ThreadTest.cpp
src/ThreadingTestSuite.cpp
src/TimerTest.cpp
src/TimespanTest.cpp
src/TimestampTest.cpp
src/TimezoneTest.cpp
src/TuplesTest.cpp
src/TypeListTest.cpp
src/URIStreamOpenerTest.cpp
src/URITest.cpp
src/URITestSuite.cpp
src/UTF8StringTest.cpp
src/UUIDGeneratorTest.cpp
src/UUIDTest.cpp
src/UUIDTestSuite.cpp
src/UniqueExpireCacheTest.cpp
src/UnicodeConverterTest.cpp
src/UniqueExpireLRUCacheTest.cpp
src/VarTest.cpp
src/ZLibTest.cpp
)
set( WIN_TEST_SRCS
src/WinDriver.cpp
)
set(TESTUNIT "${LIBNAME}-testrunner")
# Sources
file(GLOB SRCS_G "src/*.cpp")
file(GLOB SRCS_G_REMOVE
src/TestApp.cpp
src/TestApp_WINCE.cpp
src/TestLibrary.cpp
src/TestPlugin.cpp
)
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})
POCO_SOURCES_AUTO_PLAT( TEST_SRCS WIN32
src/WinDriver.cpp
)
POCO_SOURCES_PLAT( TEST_SRCS FoundationTest WINCE
src/WinCEDriver.cpp
)
add_executable( ${TESTUNIT} ${TEST_SRCS} )
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMAND ${TESTUNIT} -all)
add_test(NAME ${LIBNAME} WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} COMMAND ${TESTUNIT} -all)
set_tests_properties(${LIBNAME} PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=.") # The SharedLibaryTest has to look for shared libraries in the working directory
#set_target_properties( ${TESTUNIT} PROPERTIES COMPILE_FLAGS ${RELEASE_CXX_FLAGS} )
target_link_libraries( ${TESTUNIT} PocoFoundation CppUnit )
if (NOT ANDROID)
target_link_libraries( ${TESTUNIT} pthread)
endif ()
if( WIN32)
add_definitions("-D_AFXDLL")
target_link_libraries( ${TESTUNIT} WinTestRunner)
else()
target_link_libraries( ${TESTUNIT} pthread)
endif(WIN32)
# The test is run in the build directory. So the test data is copied there too
# The test is run in the runtime directory. So the test data is copied there too
add_custom_command(TARGET ${TESTUNIT} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/data ${CMAKE_CURRENT_BINARY_DIR}/data )
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/data ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/data )
# TestApp
add_executable( TestApp src/TestApp.cpp )
# The test is run in the build directory. So the TestApp is built there too because it is used by the tests
set_target_properties( TestApp PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} )
#set_target_properties( TestApp PROPERTIES COMPILE_FLAGS ${RELEASE_CXX_FLAGS} )
# 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 PocoFoundation )
# TODO: Add TestApp_WINCE
add_library( TestLibrary SHARED src/TestLibrary.cpp )
set_target_properties( TestLibrary PROPERTIES PREFIX "") # The test requires the library named TestLibrary. By default it is prefixed with lib.
# The test is run in the build directory. So the TestLibrary is built there too because it is used by the tests
set_target_properties( TestLibrary PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} )
#set_target_properties( TestLibrary PROPERTIES COMPILE_FLAGS ${RELEASE_CXX_FLAGS} )
# TestLibrary
add_library( TestLibrary SHARED src/TestLibrary.cpp src/TestPlugin.cpp src/TestPlugin.h )
set_target_properties( TestLibrary PROPERTIES PREFIX "" DEBUG_POSTFIX "") # The test requires the library named TestLibrary. By default it is prefixed with lib.
# 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 PocoFoundation )