From 0ac146cb9e974ba2f0e0e990aaae5de37589aa8a Mon Sep 17 00:00:00 2001 From: Marian Krivos Date: Sat, 22 Jan 2011 11:46:03 +0000 Subject: [PATCH] cmake improvements: test and samples are from now disabled by default, you can enable this option with cmdline option to cmake: '-DENABLE_TESTS=1' minimum required CMAKE version is 2.6 from now --- ApacheConnector/CMakeLists.txt | 4 ++- CMakeLists.txt | 33 +++++++++++++++++------ Crypto/CMakeLists.txt | 6 +++-- Data/CMakeLists.txt | 6 +++-- Data/MySQL/CMakeLists.txt | 4 ++- Data/ODBC/CMakeLists.txt | 4 ++- Data/SQLite/CMakeLists.txt | 5 +++- Foundation/CMakeLists.txt | 9 ++++--- Net/CMakeLists.txt | 7 +++-- NetSSL_OpenSSL/CMakeLists.txt | 7 +++-- Util/CMakeLists.txt | 6 +++-- WebWidgets/CMakeLists.txt | 5 +++- WebWidgets/ExtJS/CMakeLists.txt | 7 +++-- WebWidgets/ExtJS/testsuite/CMakeLists.txt | 20 ++++++++++++++ XML/CMakeLists.txt | 7 +++-- Zip/CMakeLists.txt | 7 +++-- 16 files changed, 105 insertions(+), 32 deletions(-) create mode 100644 WebWidgets/ExtJS/testsuite/CMakeLists.txt diff --git a/ApacheConnector/CMakeLists.txt b/ApacheConnector/CMakeLists.txt index 46c78970c..0704657d5 100644 --- a/ApacheConnector/CMakeLists.txt +++ b/ApacheConnector/CMakeLists.txt @@ -19,4 +19,6 @@ set_target_properties( ${LIBNAMED} SOVERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}) target_link_libraries( ${LIBNAMED} ) -add_subdirectory(samples) +if (ENABLE_TESTS) + add_subdirectory(samples) +endif () \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 39170d635..6fedaa701 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,9 @@ -PROJECT(poco) +PROJECT(Poco) -cmake_minimum_required(VERSION 2.4.8) +cmake_minimum_required(VERSION 2.6.0) set(CPACK_PACKAGE_VERSION_MAJOR "1") -set(CPACK_PACKAGE_VERSION_MINOR "3") +set(CPACK_PACKAGE_VERSION_MINOR "4") set(CPACK_PACKAGE_VERSION_PATCH "99") SET(COMPLETE_VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}) SET(RELEASE_NAME "Unstable-trunk") @@ -13,19 +13,28 @@ SET(PROJECT_VERSION ${COMPLETE_VERSION}) set(DEBUG_CXX_FLAGS "${COMMON_CXX} ${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG") set(RELEASE_CXX_FLAGS "${COMMON_CXX} ${CMAKE_CXX_FLAGS_MINSIZEREL}") +option(ENABLE_TESTS + "Set to OFF|ON (default is OFF) to control build of POCO tests & samples" OFF) + +option(POCO_STATIC + "Set to OFF|ON (default is OFF) to control build of POCO as STATIC library" OFF) + # Uncomment from next two lines to force statitc or dynamic library, default is autodetection if(POCO_STATIC) set( LIB_MODE STATIC ) + message(STATUS "Building static libraries") else(POCO_STATIC) set( LIB_MODE SHARED ) + message(STATUS "Building dynamic libraries") endif(POCO_STATIC) -# whether unit tests should be build -SET (ENABLE_TESTS FALSE CACHE BOOL "Build unit tests?") - IF (ENABLE_TESTS) + include(CTest) ENABLE_TESTING() -ENDIF (ENABLE_TESTS) + message(STATUS "Building with unittests & samples") +ELSE () + message(STATUS "Building without tests & samples") +ENDIF () # Set local include path include_directories( CppUnit/include Foundation/include XML/include Net/include NetSSL_OpenSSL/include Util/include Data/include WebWidgets/include Zip/include Crypto/include) @@ -75,7 +84,10 @@ if (${CMAKE_CXX_COMPILER_ID} MATCHES "SunPro") add_definitions( -D_BSD_SOURCE -library=stlport4) endif (${CMAKE_CXX_COMPILER_ID} MATCHES "SunPro") -add_subdirectory(CppUnit) +IF (ENABLE_TESTS) + add_subdirectory(CppUnit) +ENDIF () + add_subdirectory(Foundation) add_subdirectory(XML) add_subdirectory(Util) @@ -116,3 +128,8 @@ SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") SET(CPACK_PACKAGE_INSTALL_DIRECTORY "/usr/local") INCLUDE(CPack) + +message(STATUS "CMake ${CMAKE_VERSION} successfully configured ${PROJECT_NAME} using ${CMAKE_GENERATOR} generator") +message(STATUS "XXX: CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}") +message(STATUS "XXX: CMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG}") +message(STATUS "XXX: CMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE}") \ No newline at end of file diff --git a/Crypto/CMakeLists.txt b/Crypto/CMakeLists.txt index 120edfbb2..b3ef3b96d 100644 --- a/Crypto/CMakeLists.txt +++ b/Crypto/CMakeLists.txt @@ -30,5 +30,7 @@ install( DESTINATION lib ) -add_subdirectory(samples) -add_subdirectory(testsuite) +if (ENABLE_TESTS) + add_subdirectory(samples) + add_subdirectory(testsuite) +endif () diff --git a/Data/CMakeLists.txt b/Data/CMakeLists.txt index 33f56f902..6292af220 100644 --- a/Data/CMakeLists.txt +++ b/Data/CMakeLists.txt @@ -50,5 +50,7 @@ else () endif () endif() -add_subdirectory( samples ) -add_subdirectory( testsuite ) +if (ENABLE_TESTS) + add_subdirectory(samples) + add_subdirectory(testsuite) +endif () diff --git a/Data/MySQL/CMakeLists.txt b/Data/MySQL/CMakeLists.txt index 8152ffcb6..19ff2dc47 100644 --- a/Data/MySQL/CMakeLists.txt +++ b/Data/MySQL/CMakeLists.txt @@ -34,4 +34,6 @@ install( DESTINATION lib ) -add_subdirectory( testsuite ) +if (ENABLE_TESTS) + add_subdirectory(testsuite) +endif () diff --git a/Data/ODBC/CMakeLists.txt b/Data/ODBC/CMakeLists.txt index 331047adb..766b9b77e 100644 --- a/Data/ODBC/CMakeLists.txt +++ b/Data/ODBC/CMakeLists.txt @@ -47,4 +47,6 @@ install( DESTINATION lib ) -add_subdirectory( testsuite ) +if (ENABLE_TESTS) + add_subdirectory(testsuite) +endif () diff --git a/Data/SQLite/CMakeLists.txt b/Data/SQLite/CMakeLists.txt index 1575151c9..a28dd0000 100644 --- a/Data/SQLite/CMakeLists.txt +++ b/Data/SQLite/CMakeLists.txt @@ -33,4 +33,7 @@ install( DESTINATION lib ) -add_subdirectory( testsuite ) +if (ENABLE_TESTS) + add_subdirectory(testsuite) +endif () + diff --git a/Foundation/CMakeLists.txt b/Foundation/CMakeLists.txt index 3d601389c..60a497416 100644 --- a/Foundation/CMakeLists.txt +++ b/Foundation/CMakeLists.txt @@ -213,6 +213,9 @@ install( TARGETS ${LIBNAME} ${LIBNAMED} DESTINATION lib ) - -add_subdirectory( samples ) -add_subdirectory( testsuite ) + +if (ENABLE_TESTS) + add_subdirectory( samples ) + add_subdirectory( testsuite ) +endif () + diff --git a/Net/CMakeLists.txt b/Net/CMakeLists.txt index 6e674926d..e3e196f2c 100644 --- a/Net/CMakeLists.txt +++ b/Net/CMakeLists.txt @@ -45,5 +45,8 @@ install( DESTINATION lib ) -add_subdirectory( samples ) -add_subdirectory( testsuite ) +if (ENABLE_TESTS) + add_subdirectory(samples) + add_subdirectory(testsuite) +endif () + diff --git a/NetSSL_OpenSSL/CMakeLists.txt b/NetSSL_OpenSSL/CMakeLists.txt index 43cd5bdc5..07879b871 100644 --- a/NetSSL_OpenSSL/CMakeLists.txt +++ b/NetSSL_OpenSSL/CMakeLists.txt @@ -28,5 +28,8 @@ install( DESTINATION lib ) -add_subdirectory( samples ) -add_subdirectory( testsuite ) +if (ENABLE_TESTS) + add_subdirectory(samples) + add_subdirectory(testsuite) +endif () + diff --git a/Util/CMakeLists.txt b/Util/CMakeLists.txt index 94e929525..6c995e406 100644 --- a/Util/CMakeLists.txt +++ b/Util/CMakeLists.txt @@ -67,5 +67,7 @@ install( DESTINATION lib ) -add_subdirectory( testsuite ) -add_subdirectory( samples ) +if (ENABLE_TESTS) + add_subdirectory(samples) + add_subdirectory(testsuite) +endif () diff --git a/WebWidgets/CMakeLists.txt b/WebWidgets/CMakeLists.txt index db879bc98..4292fadef 100644 --- a/WebWidgets/CMakeLists.txt +++ b/WebWidgets/CMakeLists.txt @@ -31,4 +31,7 @@ install( add_subdirectory( ExtJS ) -add_subdirectory( testsuite ) +if (ENABLE_TESTS) + add_subdirectory(testsuite) +endif () + diff --git a/WebWidgets/ExtJS/CMakeLists.txt b/WebWidgets/ExtJS/CMakeLists.txt index 83406c598..d36f234b6 100644 --- a/WebWidgets/ExtJS/CMakeLists.txt +++ b/WebWidgets/ExtJS/CMakeLists.txt @@ -33,5 +33,8 @@ install( DESTINATION lib ) -add_subdirectory( samples ) -#add_subdirectory( testsuite ) +if (ENABLE_TESTS) + add_subdirectory(samples) + add_subdirectory(testsuite) +endif () + diff --git a/WebWidgets/ExtJS/testsuite/CMakeLists.txt b/WebWidgets/ExtJS/testsuite/CMakeLists.txt new file mode 100644 index 000000000..b0445db72 --- /dev/null +++ b/WebWidgets/ExtJS/testsuite/CMakeLists.txt @@ -0,0 +1,20 @@ +set( TEST_SRCS +src/Driver.cpp +src/ExtJSTest.cpp +src/ExtJSTest.h +src/ExtJSTestSuite.cpp +src/ExtJSTestSuite.h +) + +#include_directories() + +set( WIN_TEST_SRCS +src/WinDriver.cpp +) + +set(TESTUNIT "${LIBNAME}-testrunner") + +add_executable( ${TESTUNIT} ${TEST_SRCS} ) +set_target_properties( ${TESTUNIT} PROPERTIES COMPILE_FLAGS ${RELEASE_CXX_FLAGS} ) +target_link_libraries( ${TESTUNIT} PocoExtJS PocoWebWidgets PocoNet PocoUtil PocoXML PocoFoundation CppUnit) + diff --git a/XML/CMakeLists.txt b/XML/CMakeLists.txt index fb8331e24..6b1055f6f 100644 --- a/XML/CMakeLists.txt +++ b/XML/CMakeLists.txt @@ -30,5 +30,8 @@ install( DESTINATION lib ) -add_subdirectory( samples ) -add_subdirectory( testsuite ) +if (ENABLE_TESTS) + add_subdirectory(samples) + add_subdirectory(testsuite) +endif () + diff --git a/Zip/CMakeLists.txt b/Zip/CMakeLists.txt index e7916fa72..c0b18a555 100644 --- a/Zip/CMakeLists.txt +++ b/Zip/CMakeLists.txt @@ -28,5 +28,8 @@ install( DESTINATION lib ) -add_subdirectory(samples) -add_subdirectory(testsuite) +if (ENABLE_TESTS) + add_subdirectory(samples) + add_subdirectory(testsuite) +endif () +