/[pcre]/code/trunk/CMakeLists.txt
ViewVC logotype

Diff of /code/trunk/CMakeLists.txt

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 685 by ph10, Tue Sep 6 15:02:07 2011 UTC revision 732 by ph10, Tue Oct 11 10:24:28 2011 UTC
# Line 41  Line 41 
41  # 2011-08-22 PH added PCRE_SUPPORT_JIT  # 2011-08-22 PH added PCRE_SUPPORT_JIT
42  # 2011-09-06 PH modified WIN32 ADD_TEST line as suggested by Sergey Cherepanov  # 2011-09-06 PH modified WIN32 ADD_TEST line as suggested by Sergey Cherepanov
43  # 2011-09-06 PH added PCRE_SUPPORT_PCREGREP_JIT  # 2011-09-06 PH added PCRE_SUPPORT_PCREGREP_JIT
44    # 2011-10-04 Sheri added support for including coff data in windows shared libraries
45    #            compiled with MINGW if pcre.rc and/or pcreposix.rc are placed in
46    #            the source dir by the user prior to building
47    # 2011-10-04 Sheri changed various add_test's to use exes' location built instead
48    #            of DEBUG location only (likely only matters in MSVC)
49    # 2011-10-04 Sheri added scripts to provide needed variables to RunTest and
50    #            RunGrepTest (used for UNIX and Msys)
51    # 2011-10-04 Sheri added scripts to provide needed variables and to execute
52    #            RunTest.bat in Win32 (for effortless testing with "make test")
53    # 2011-10-04 Sheri Increased minimum required cmake version
54    
55  PROJECT(PCRE C CXX)  PROJECT(PCRE C CXX)
56    
57  CMAKE_MINIMUM_REQUIRED(VERSION 2.4.6)  # Increased minimum to 2.8.0 to support newer add_test features
58    
59    CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0)
60    
61  SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) # for FindReadline.cmake  SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) # for FindReadline.cmake
62    
# Line 117  SET(PCRE_POSIX_MALLOC_THRESHOLD "10" CAC Line 129  SET(PCRE_POSIX_MALLOC_THRESHOLD "10" CAC
129    
130  SET(PCRE_SUPPORT_JIT OFF CACHE BOOL  SET(PCRE_SUPPORT_JIT OFF CACHE BOOL
131      "Enable support for Just-in-time compiling.")      "Enable support for Just-in-time compiling.")
132    
133  SET(PCRE_SUPPORT_PCREGREP_JIT ON CACHE BOOL  SET(PCRE_SUPPORT_PCREGREP_JIT ON CACHE BOOL
134      "Enable use of Just-in-time compiling in pcregrep.")      "Enable use of Just-in-time compiling in pcregrep.")
135    
136  SET(PCRE_SUPPORT_UNICODE_PROPERTIES OFF CACHE BOOL  SET(PCRE_SUPPORT_UNICODE_PROPERTIES OFF CACHE BOOL
137      "Enable support for Unicode properties. (If set, UTF-8 support will be enabled as well)")      "Enable support for Unicode properties. (If set, UTF-8 support will be enabled as well)")
138    
# Line 217  ENDIF(PCRE_SUPPORT_UNICODE_PROPERTIES) Line 229  ENDIF(PCRE_SUPPORT_UNICODE_PROPERTIES)
229    
230  IF(PCRE_SUPPORT_JIT)  IF(PCRE_SUPPORT_JIT)
231          SET(SUPPORT_JIT 1)          SET(SUPPORT_JIT 1)
232  ELSE  ENDIF(PCRE_SUPPORT_JIT)
         SET(PCRE_SUPPORT_PCREGREP_JIT 0)  
 ENDIF(PCRE_SUPPORT_JIT)  
233    
234  IF(PCRE_SUPPORT_PCREGREP_JIT)  IF(PCRE_SUPPORT_PCREGREP_JIT)
235          SET(SUPPORT_PCREGREP_JIT 1)          SET(SUPPORT_PCREGREP_JIT 1)
236  ENDIF(PCRE_SUPPORT_PCREGREP_JIT)  ENDIF(PCRE_SUPPORT_PCREGREP_JIT)
237    
238  # This next one used to contain  # This next one used to contain
239  #       SET(PCRETEST_LIBS ${READLINE_LIBRARY})  #       SET(PCRETEST_LIBS ${READLINE_LIBRARY})
# Line 346  SET(PCRE_SOURCES Line 356  SET(PCRE_SOURCES
356    pcre_xclass.c    pcre_xclass.c
357  )  )
358    
359    
360  SET(PCREPOSIX_HEADERS pcreposix.h)  SET(PCREPOSIX_HEADERS pcreposix.h)
361    
362  SET(PCREPOSIX_SOURCES pcreposix.c)  SET(PCREPOSIX_SOURCES pcreposix.c)
363    
364    IF(MINGW AND NOT PCRE_STATIC)
365    IF (EXISTS ${PROJECT_SOURCE_DIR}/pcre.rc)
366    ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/pcre.o
367    PRE-LINK
368    COMMAND windres ARGS pcre.rc pcre.o
369    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
370    COMMENT Using pcre coff info in mingw build)
371    SET(PCRE_SOURCES
372      ${PCRE_SOURCES} ${PROJECT_SOURCE_DIR}/pcre.o
373    )
374    ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/pcre.rc)
375    IF (EXISTS ${PROJECT_SOURCE_DIR}/pcreposix.rc)
376    ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/pcreposix.o
377    PRE-LINK
378    COMMAND windres ARGS pcreposix.rc pcreposix.o
379    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
380    COMMENT Using pcreposix coff info in mingw build)
381    SET(PCREPOSIX_SOURCES
382      ${PCREPOSIX_SOURCES} ${PROJECT_SOURCE_DIR}/pcreposix.o
383    )
384    ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/pcreposix.rc)
385    ENDIF(MINGW AND NOT PCRE_STATIC)
386    
387  SET(PCRECPP_HEADERS  SET(PCRECPP_HEADERS
388    pcrecpp.h    pcrecpp.h
389    pcre_scanner.h    pcre_scanner.h
# Line 435  ENDIF(PCRE_BUILD_PCRECPP) Line 469  ENDIF(PCRE_BUILD_PCRECPP)
469  #         SET_TARGET_PROPERTIES(pcredemo PROPERTIES COMPILE_FLAGS "-DPCRE_STATIC")  #         SET_TARGET_PROPERTIES(pcredemo PROPERTIES COMPILE_FLAGS "-DPCRE_STATIC")
470  # ENDIF(NOT BUILD_SHARED_LIBS)  # ENDIF(NOT BUILD_SHARED_LIBS)
471    
472  IF(PCRE_BUILD_PCREGREP)  IF(PCRE_BUILD_PCREGREP OR PCRE_BUILD_TESTS)
473    ADD_EXECUTABLE(pcregrep pcregrep.c)    ADD_EXECUTABLE(pcregrep pcregrep.c)
474    SET(targets ${targets} pcregrep)    SET(targets ${targets} pcregrep)
475    TARGET_LINK_LIBRARIES(pcregrep pcreposix ${PCREGREP_LIBS})    TARGET_LINK_LIBRARIES(pcregrep pcreposix ${PCREGREP_LIBS})
476  ENDIF(PCRE_BUILD_PCREGREP)  ENDIF(PCRE_BUILD_PCREGREP OR PCRE_BUILD_TESTS)
   
477    
478  # Testing  # Testing
479  IF(PCRE_BUILD_TESTS)  IF(PCRE_BUILD_TESTS)
# Line 449  IF(PCRE_BUILD_TESTS) Line 482  IF(PCRE_BUILD_TESTS)
482    ADD_EXECUTABLE(pcretest pcretest.c)    ADD_EXECUTABLE(pcretest pcretest.c)
483    SET(targets ${targets} pcretest)    SET(targets ${targets} pcretest)
484    TARGET_LINK_LIBRARIES(pcretest pcreposix ${PCRETEST_LIBS})    TARGET_LINK_LIBRARIES(pcretest pcreposix ${PCRETEST_LIBS})
485    
486    IF(PCRE_SUPPORT_JIT)    IF(PCRE_SUPPORT_JIT)
487      ADD_EXECUTABLE(pcre_jit_test pcre_jit_test.c)      ADD_EXECUTABLE(pcre_jit_test pcre_jit_test.c)
488      SET(targets ${targets} pcre_jit_test)      SET(targets ${targets} pcre_jit_test)
489      TARGET_LINK_LIBRARIES(pcre_jit_test pcre)      TARGET_LINK_LIBRARIES(pcre_jit_test pcre)
490    ENDIF(PCRE_SUPPORT_JIT)    ENDIF(PCRE_SUPPORT_JIT)
491    
492    IF(PCRE_BUILD_PCRECPP)    IF(PCRE_BUILD_PCRECPP)
493      ADD_EXECUTABLE(pcrecpp_unittest pcrecpp_unittest.cc)      ADD_EXECUTABLE(pcrecpp_unittest pcrecpp_unittest.cc)
# Line 475  IF(PCRE_BUILD_TESTS) Line 508  IF(PCRE_BUILD_TESTS)
508      TARGET_LINK_LIBRARIES(pcre_stringpiece_unittest pcrecpp)      TARGET_LINK_LIBRARIES(pcre_stringpiece_unittest pcrecpp)
509    ENDIF(PCRE_BUILD_PCRECPP)    ENDIF(PCRE_BUILD_PCRECPP)
510    
511      # exes in Debug location tested by the RunTest shell script
512      # via "make test"
513    GET_TARGET_PROPERTY(PCREGREP_EXE pcregrep DEBUG_LOCATION)    GET_TARGET_PROPERTY(PCREGREP_EXE pcregrep DEBUG_LOCATION)
514    GET_TARGET_PROPERTY(PCRETEST_EXE pcretest DEBUG_LOCATION)    GET_TARGET_PROPERTY(PCRETEST_EXE pcretest DEBUG_LOCATION)
515    
516    # Write out a CTest configuration file that sets some needed environment  # =================================================
517    # variables for the test scripts.    # Write out a CTest configuration file
518    #    #
519    FILE(WRITE ${PROJECT_BINARY_DIR}/CTestCustom.ctest    FILE(WRITE ${PROJECT_BINARY_DIR}/CTestCustom.ctest
520    "# This is a generated file.    "# This is a generated file.
521    SET(ENV{srcdir} ${PROJECT_SOURCE_DIR})  MESSAGE(\"When testing is complete, review test output in the
522    SET(ENV{pcregrep} ${PCREGREP_EXE})  ${PROJECT_BINARY_DIR}/Testing/Temporary folder.\")
523    SET(ENV{pcretest} ${PCRETEST_EXE})  MESSAGE(\"\")
524    ")  ")
525    
526          FILE(WRITE ${PROJECT_BINARY_DIR}/pcre_test.sh
527          "#! /bin/sh
528    # This is a generated file.
529    srcdir=${PROJECT_SOURCE_DIR}
530    pcregrep=${PCREGREP_EXE}
531    pcretest=${PCRETEST_EXE}
532    source ${PROJECT_SOURCE_DIR}/RunTest
533    if test \"$?\" != \"0\"; then exit 1; fi
534    # End
535    ")
536    
537          FILE(WRITE ${PROJECT_BINARY_DIR}/pcre_grep_test.sh
538          "#! /bin/sh
539    # This is a generated file.
540    srcdir=${PROJECT_SOURCE_DIR}
541    pcregrep=${PCREGREP_EXE}
542    pcretest=${PCRETEST_EXE}
543    source ${PROJECT_SOURCE_DIR}/RunGrepTest
544    if test \"$?\" != \"0\"; then exit 1; fi
545    # End
546    ")
547    
548    IF(UNIX)    IF(UNIX)
549            ADD_TEST(pcre_test      ${PROJECT_SOURCE_DIR}/RunTest)      ADD_TEST(pcre_test      sh ${PROJECT_BINARY_DIR}/pcre_test.sh)
550            ADD_TEST(pcre_grep_test ${PROJECT_SOURCE_DIR}/RunGrepTest)      ADD_TEST(pcre_grep_test sh ${PROJECT_BINARY_DIR}/pcre_grep_test.sh)
551    ENDIF(UNIX)    ENDIF(UNIX)
552    
553    IF(WIN32)    IF(WIN32)
554            # ADD_TEST(pcre_test cmd /C ${PROJECT_SOURCE_DIR}/RunTest.bat)      # Provide environment for executing the bat file version of RunTest
555            ADD_TEST(pcre_test ${PROJECT_SOURCE_DIR}/RunTest.bat)      string(REPLACE "/" "\\" winsrc "${PROJECT_SOURCE_DIR}")
556    
557        FILE(WRITE ${PROJECT_BINARY_DIR}/pcre_test.txt
558        "\@REM This is a generated file.
559    \@Echo off
560    setlocal
561    SET\ srcdir=\${srcdir}
562    SET\ pcretest=\${pcretest}
563    SET\ pcregrep=\${pcregrep}
564    call \"\${srcdir}\\RunTest.Bat\"
565    if errorlevel 1 exit /b 1
566    echo RunTest.bat tests successfully completed
567    ")
568    
569      FILE(WRITE ${PROJECT_BINARY_DIR}/BatDriver.cmake
570      "# This is a generated file.
571    # this script is run with arguments via the cmake command in add_test(NAME pcre_test_bat)
572    # BatDriver feeds the actual location of pcretest.exe and pcregrep.exe
573    FILE(TO_NATIVE_PATH \${pcretestx} pcretest)
574    FILE(TO_NATIVE_PATH \${pcregrepx} pcregrep)
575    FILE(TO_NATIVE_PATH \${srcdirx} srcdir)
576    configure_file(\"\${bindirx}/pcre_test.txt\" \"\${bindirx}/pcre_test.bat\")
577    # MESSAGE(\"cmake\ variable\ pcretest\ is\ \${pcretest}\")
578    # MESSAGE(\"cmake\ variable\ pcregrep\ is\ \${pcregrep}\")
579    # STRING(REPLACE \" \" \"\\ \" bindir \${bindirx})
580    MESSAGE(\"COMMAND pcre_test.bat \")
581    EXECUTE_PROCESS(COMMAND pcre_test.bat
582    WORKING_DIRECTORY .
583    OUTPUT_VARIABLE batoutput)
584    MESSAGE(\"OUTPUT: \${batoutput}\")
585    ")
586    
587      ADD_TEST(NAME pcre_test_bat
588      COMMAND ${CMAKE_COMMAND} -D bindirx=${PROJECT_BINARY_DIR} -D srcdirx=${PROJECT_SOURCE_DIR} -D pcretestx=$<TARGET_FILE:pcretest> -D pcregrepx=$<TARGET_FILE:pcregrep> -P "${PROJECT_BINARY_DIR}/BatDriver.cmake")
589      SET_TESTS_PROPERTIES(pcre_test_bat PROPERTIES
590      PASS_REGULAR_EXPRESSION "RunTest\\.bat tests successfully completed")
591    
592        IF("$ENV{OSTYPE}" STREQUAL "msys")
593        # Both the sh and bat file versions of RunTest are run if make test is used
594        # in msys
595    
596          ADD_TEST(pcre_test_sh    sh.exe ${PROJECT_BINARY_DIR}/pcre_test.sh)
597          ADD_TEST(pcre_grep_test sh.exe ${PROJECT_BINARY_DIR}/pcre_grep_test.sh)
598    
599        ENDIF("$ENV{OSTYPE}" STREQUAL "msys")
600    ENDIF(WIN32)    ENDIF(WIN32)
601    
602    IF(PCRE_SUPPORT_JIT)    # Changed to accommodate testing whichever location was just built
   GET_TARGET_PROPERTY(PCRE_JIT_TEST_EXE  
                       pcre_jit_test  
                       DEBUG_LOCATION)  
   ENDIF(PCRE_SUPPORT_JIT)  
   
   GET_TARGET_PROPERTY(PCRECPP_UNITTEST_EXE  
                       pcrecpp_unittest  
                       DEBUG_LOCATION)  
   
   GET_TARGET_PROPERTY(PCRE_SCANNER_UNITTEST_EXE  
                       pcre_scanner_unittest  
                       DEBUG_LOCATION)  
   
   GET_TARGET_PROPERTY(PCRE_STRINGPIECE_UNITTEST_EXE  
                       pcre_stringpiece_unittest  
                       DEBUG_LOCATION)  
603    
604    IF(PCRE_SUPPORT_JIT)    IF(PCRE_SUPPORT_JIT)
605    ADD_TEST(pcre_jit_test         ${PCRE_JIT_TEST_EXE})    ADD_TEST(pcre_jit_test       pcre_jit_test)
606    ENDIF(PCRE_SUPPORT_JIT)    ENDIF(PCRE_SUPPORT_JIT)
607    ADD_TEST(pcrecpp_test          ${PCRECPP_UNITTEST_EXE})  
608    ADD_TEST(pcre_scanner_test     ${PCRE_SCANNER_UNITTEST_EXE})    IF(PCRE_BUILD_PCRECPP)
609    ADD_TEST(pcre_stringpiece_test ${PCRE_STRINGPIECE_UNITTEST_EXE})      ADD_TEST(pcrecpp_test          pcrecpp_unittest)
610        ADD_TEST(pcre_scanner_test     pcre_scanner_unittest)
611        ADD_TEST(pcre_stringpiece_test pcre_stringpiece_unittest)
612    
613      ENDIF(PCRE_BUILD_PCRECPP)
614  ENDIF(PCRE_BUILD_TESTS)  ENDIF(PCRE_BUILD_TESTS)
615    
616  # Installation  # Installation
# Line 550  ELSE(PCRE_BUILD_PCRECPP) Line 640  ELSE(PCRE_BUILD_PCRECPP)
640          SET(man3 ${man3_new})          SET(man3 ${man3_new})
641  ENDIF(PCRE_BUILD_PCRECPP)  ENDIF(PCRE_BUILD_PCRECPP)
642    
   
643  INSTALL(FILES ${man1} DESTINATION man/man1)  INSTALL(FILES ${man1} DESTINATION man/man1)
644  INSTALL(FILES ${man3} DESTINATION man/man3)  INSTALL(FILES ${man3} DESTINATION man/man3)
645  INSTALL(FILES ${html} DESTINATION share/doc/pcre/html)  INSTALL(FILES ${html} DESTINATION share/doc/pcre/html)
# Line 598  IF(PCRE_SHOW_REPORT) Line 687  IF(PCRE_SHOW_REPORT)
687    MESSAGE(STATUS "  Build pcregrep .................. : ${PCRE_BUILD_PCREGREP}")    MESSAGE(STATUS "  Build pcregrep .................. : ${PCRE_BUILD_PCREGREP}")
688    MESSAGE(STATUS "  Enable JIT in pcregrep .......... : ${PCRE_SUPPORT_PCREGREP_JIT}")    MESSAGE(STATUS "  Enable JIT in pcregrep .......... : ${PCRE_SUPPORT_PCREGREP_JIT}")
689    MESSAGE(STATUS "  Buffer size for pcregrep ........ : ${PCREGREP_BUFSIZE}")    MESSAGE(STATUS "  Buffer size for pcregrep ........ : ${PCREGREP_BUFSIZE}")
690    MESSAGE(STATUS "  Build tests (implies pcretest) .. : ${PCRE_BUILD_TESTS}")    MESSAGE(STATUS "  Build tests (implies pcretest  .. : ${PCRE_BUILD_TESTS}")
691      MESSAGE(STATUS "               and pcregrep)")
692    IF(ZLIB_FOUND)    IF(ZLIB_FOUND)
693      MESSAGE(STATUS "  Link pcregrep with libz ......... : ${PCRE_SUPPORT_LIBZ}")      MESSAGE(STATUS "  Link pcregrep with libz ......... : ${PCRE_SUPPORT_LIBZ}")
694    ELSE(ZLIB_FOUND)    ELSE(ZLIB_FOUND)

Legend:
Removed from v.685  
changed lines
  Added in v.732

  ViewVC Help
Powered by ViewVC 1.1.5