You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by tr...@apache.org on 2013/10/11 14:43:25 UTC

svn commit: r1531275 - in /apr/apr-util/branches/1.5.x: CMakeLists.txt README.cmake

Author: trawick
Date: Fri Oct 11 12:43:25 2013
New Revision: 1531275

URL: http://svn.apache.org/r1531275
Log:
Merge the APR-Util bits of r1523604 from trunk:

Support building test suite against either static or dynamic libs.
  (Requiring separate builds is ugly, but so is creating a more
  complex directory structure or naming convention in the build 
  directory and possibly having to modify test program source to 
  find child programs.)

Add running the test suite to the build system.
  (Using the "NMake Makefiles" generator, use "nmake test" to run
  silently, with output logged to some files, or "nmake check" to
  run with test output logged to the console.)

Modified:
    apr/apr-util/branches/1.5.x/CMakeLists.txt
    apr/apr-util/branches/1.5.x/README.cmake

Modified: apr/apr-util/branches/1.5.x/CMakeLists.txt
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.5.x/CMakeLists.txt?rev=1531275&r1=1531274&r2=1531275&view=diff
==============================================================================
--- apr/apr-util/branches/1.5.x/CMakeLists.txt (original)
+++ apr/apr-util/branches/1.5.x/CMakeLists.txt Fri Oct 11 12:43:25 2013
@@ -26,6 +26,7 @@ OPTION(APU_HAVE_ODBC        "Build ODBC 
 OPTION(APR_HAS_LDAP         "LDAP support"                              ON)
 OPTION(INSTALL_PDB          "Install .pdb files (if generated)"         ON)
 OPTION(APR_BUILD_TESTAPR    "Build the test suite"                      OFF)
+OPTION(TEST_STATIC_LIBS     "Test programs use APR static libraries instead of shared libraries?" OFF)
 SET(APR_INCLUDE_DIR         "${CMAKE_INSTALL_PREFIX}/include"           CACHE STRING "Directory with APR include files")
 SET(APR_LIBRARIES           "${CMAKE_INSTALL_PREFIX}/lib/libapr-1.lib"  CACHE STRING "APR library to link with")
 
@@ -220,6 +221,7 @@ SET(EXPAT_SOURCES
 SET(install_targets)
 SET(install_bin_pdb)
 SET(install_lib_pdb)
+SET(dbd_drivers)
 
 # static expat (not installed)
 ADD_LIBRARY(libexpat STATIC ${EXPAT_SOURCES})
@@ -254,6 +256,7 @@ IF(APU_HAVE_ODBC)
   ADD_LIBRARY(apr_dbd_odbc-1 SHARED dbd/apr_dbd_odbc.c libaprutil.rc)
   SET(install_targets ${install_targets} apr_dbd_odbc-1)
   SET(install_bin_pdb ${install_bin_pdb} ${PROJECT_BINARY_DIR}/apr_dbd_odbc-1.pdb)
+  SET(dbd_drivers ${dbd_drivers} odbc)
   TARGET_LINK_LIBRARIES(apr_dbd_odbc-1 libaprutil-1 ${APR_LIBRARIES} odbc32 odbccp32)
   SET_PROPERTY(TARGET apr_dbd_odbc-1 APPEND PROPERTY LINK_FLAGS /export:apr_dbd_odbc_driver)
   SET_TARGET_PROPERTIES(apr_dbd_odbc-1 PROPERTIES COMPILE_DEFINITIONS "APU_HAVE_ODBC;HAVE_SQL_H;APU_DECLARE_EXPORT;APU_DSO_MODULE_BUILD")
@@ -273,17 +276,42 @@ ELSE()
 ENDIF()
 
 IF(APR_BUILD_TESTAPR)
-  EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_BINARY_DIR}/data)
-  EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${PROJECT_SOURCE_DIR}/test/data/billion-laughs.xml ${PROJECT_BINARY_DIR}/data/billion-laughs.xml)
+  ENABLE_TESTING()
+  # Create a "check" target that displays test program output to the console.
+  ADD_CUSTOM_TARGET(check COMMAND ${CMAKE_CTEST_COMMAND} --verbose)
+
+  # copy data files to build directory so that we can run programs from there
+  EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E make_directory 
+                  ${PROJECT_BINARY_DIR}/data)
+  EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy_if_different 
+                  ${PROJECT_SOURCE_DIR}/test/data/billion-laughs.xml
+                  ${PROJECT_BINARY_DIR}/data/billion-laughs.xml)
+
+  IF(TEST_STATIC_LIBS)
+    SET(whichapr    aprutil-1)
+    SET(apiflag     "-DAPR_DECLARE_STATIC -DAPU_DECLARE_STATIC")
+  ELSE()
+    SET(whichapr    libaprutil-1)
+    SET(apiflag)
+  ENDIF()
 
   ADD_EXECUTABLE(testall ${APR_TEST_SOURCES})
-  TARGET_LINK_LIBRARIES(testall aprutil-1 ${apr_ldap_libraries} ${XMLLIB_LIBRARIES} ${LDAP_LIBRARIES})
+  TARGET_LINK_LIBRARIES(testall ${whichapr} ${apr_ldap_libraries} ${XMLLIB_LIBRARIES} ${LDAP_LIBRARIES})
+  IF(apiflag)
+    SET_TARGET_PROPERTIES(testall PROPERTIES COMPILE_FLAGS ${apiflag})
+  ENDIF()
+  ADD_TEST(NAME testall COMMAND testall)
 
   ADD_EXECUTABLE(dbd test/dbd.c)
-  TARGET_LINK_LIBRARIES(dbd aprutil-1)
+  TARGET_LINK_LIBRARIES(dbd ${whichapr})
+  IF(apiflag)
+    SET_TARGET_PROPERTIES(dbd PROPERTIES COMPILE_FLAGS ${apiflag})
+  ENDIF()
 
-  # test programs are linked with static library
-  SET_TARGET_PROPERTIES(testall dbd PROPERTIES COMPILE_FLAGS "-DAPU_DECLARE_STATIC -DAPR_DECLARE_STATIC")
+  # dbd is run multiple times with different parameters.
+  FOREACH(somedbd ${dbd_drivers})
+    ADD_TEST(NAME dbd-${somedbd} COMMAND dbd ${somedbd})
+  ENDFOREACH()
 
 ENDIF (APR_BUILD_TESTAPR)
 
@@ -322,3 +350,8 @@ MESSAGE(STATUS "  DBD ODBC driver ......
 MESSAGE(STATUS "  APU_HAVE_CRYPTO ................. : ${APU_HAVE_CRYPTO}")
 MESSAGE(STATUS "  APR_HAS_LDAP .................... : ${APR_HAS_LDAP}")
 MESSAGE(STATUS "  Build test suite ................ : ${APR_BUILD_TESTAPR}")
+IF(TEST_STATIC_LIBS)
+MESSAGE(STATUS "    (testing static libraries)")
+ELSE()
+MESSAGE(STATUS "    (testing dynamic libraries)")
+ENDIF()

Modified: apr/apr-util/branches/1.5.x/README.cmake
URL: http://svn.apache.org/viewvc/apr/apr-util/branches/1.5.x/README.cmake?rev=1531275&r1=1531274&r2=1531275&view=diff
==============================================================================
--- apr/apr-util/branches/1.5.x/README.cmake (original)
+++ apr/apr-util/branches/1.5.x/README.cmake Fri Oct 11 12:43:25 2013
@@ -79,6 +79,13 @@ How to build
                               Default: ON
        APR_BUILD_TESTAPR      Build APR-Util test suite
                               Default: OFF
+       TEST_STATIC_LIBS       Build the test suite to test the APR static
+                              library instead of the APR dynamic library.
+                              Default: OFF
+                              In order to build the test suite against both
+                              static and dynamic libraries, separate builds
+                              will be required, one with TEST_STATIC_LIBS
+                              set to ON.
        INSTALL_PDB            Install .pdb files if generated.
                               Default: ON
 
@@ -114,8 +121,6 @@ Known Bugs and Limitations
     . APU_HAVE_NSS
   + XLATE, APU_HAVE_ICONV (no way to consume an apr-iconv build yet)
 * Static builds of APR modules are not supported.
-* No test program build to use libaprutil-1.dll is created.
-* No script or other mechanism is provided to run the test suite.
 * CHANGES/LICENSE/NOTICE is not installed, unlike Makefile.win.
   (But unlike Makefile.win we want to call them APR-Util-CHANGES.txt
   and so on.)  But perhaps that is a job for a higher-level script.