/[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 853 by ph10, Fri Jan 6 13:48:54 2012 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    # 2012-01-06 PH removed pcre_info.c and added pcre_string_utils.c
55    
56  PROJECT(PCRE C CXX)  PROJECT(PCRE C CXX)
57    
58  CMAKE_MINIMUM_REQUIRED(VERSION 2.4.6)  # Increased minimum to 2.8.0 to support newer add_test features
59    
60    CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0)
61    
62  SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) # for FindReadline.cmake  SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) # for FindReadline.cmake
63    
# Line 117  SET(PCRE_POSIX_MALLOC_THRESHOLD "10" CAC Line 130  SET(PCRE_POSIX_MALLOC_THRESHOLD "10" CAC
130    
131  SET(PCRE_SUPPORT_JIT OFF CACHE BOOL  SET(PCRE_SUPPORT_JIT OFF CACHE BOOL
132      "Enable support for Just-in-time compiling.")      "Enable support for Just-in-time compiling.")
133    
134  SET(PCRE_SUPPORT_PCREGREP_JIT ON CACHE BOOL  SET(PCRE_SUPPORT_PCREGREP_JIT ON CACHE BOOL
135      "Enable use of Just-in-time compiling in pcregrep.")      "Enable use of Just-in-time compiling in pcregrep.")
136    
137  SET(PCRE_SUPPORT_UNICODE_PROPERTIES OFF CACHE BOOL  SET(PCRE_SUPPORT_UNICODE_PROPERTIES OFF CACHE BOOL
138      "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)")
139    
# Line 217  ENDIF(PCRE_SUPPORT_UNICODE_PROPERTIES) Line 230  ENDIF(PCRE_SUPPORT_UNICODE_PROPERTIES)
230    
231  IF(PCRE_SUPPORT_JIT)  IF(PCRE_SUPPORT_JIT)
232          SET(SUPPORT_JIT 1)          SET(SUPPORT_JIT 1)
233  ELSE  ENDIF(PCRE_SUPPORT_JIT)
         SET(PCRE_SUPPORT_PCREGREP_JIT 0)  
 ENDIF(PCRE_SUPPORT_JIT)  
234    
235  IF(PCRE_SUPPORT_PCREGREP_JIT)  IF(PCRE_SUPPORT_PCREGREP_JIT)
236          SET(SUPPORT_PCREGREP_JIT 1)          SET(SUPPORT_PCREGREP_JIT 1)
237  ENDIF(PCRE_SUPPORT_PCREGREP_JIT)  ENDIF(PCRE_SUPPORT_PCREGREP_JIT)
238    
239  # This next one used to contain  # This next one used to contain
240  #       SET(PCRETEST_LIBS ${READLINE_LIBRARY})  #       SET(PCRETEST_LIBS ${READLINE_LIBRARY})
# Line 323  ENDIF(PCRE_REBUILD_CHARTABLES) Line 334  ENDIF(PCRE_REBUILD_CHARTABLES)
334  SET(PCRE_HEADERS ${PROJECT_BINARY_DIR}/pcre.h)  SET(PCRE_HEADERS ${PROJECT_BINARY_DIR}/pcre.h)
335    
336  SET(PCRE_SOURCES  SET(PCRE_SOURCES
337    ${PROJECT_BINARY_DIR}/pcre_chartables.c    ${PROJECT_BINARY_DIR}/pcre_byte_order.c
338      pcre_chartables.c
339    pcre_compile.c    pcre_compile.c
340    pcre_config.c    pcre_config.c
341    pcre_dfa_exec.c    pcre_dfa_exec.c
# Line 331  SET(PCRE_SOURCES Line 343  SET(PCRE_SOURCES
343    pcre_fullinfo.c    pcre_fullinfo.c
344    pcre_get.c    pcre_get.c
345    pcre_globals.c    pcre_globals.c
   pcre_info.c  
346    pcre_jit_compile.c    pcre_jit_compile.c
   pcre_newline.c  
347    pcre_maketables.c    pcre_maketables.c
348      pcre_newline.c
349    pcre_ord2utf8.c    pcre_ord2utf8.c
350    pcre_refcount.c    pcre_refcount.c
351      pcre_string_utils.c
352    pcre_study.c    pcre_study.c
353    pcre_tables.c    pcre_tables.c
   pcre_try_flipped.c  
354    pcre_ucd.c    pcre_ucd.c
355    pcre_valid_utf8.c    pcre_valid_utf8.c
356    pcre_version.c    pcre_version.c
357    pcre_xclass.c    pcre_xclass.c
358  )  )
359    
360    
361  SET(PCREPOSIX_HEADERS pcreposix.h)  SET(PCREPOSIX_HEADERS pcreposix.h)
362    
363  SET(PCREPOSIX_SOURCES pcreposix.c)  SET(PCREPOSIX_SOURCES pcreposix.c)
364    
365    IF(MINGW AND NOT PCRE_STATIC)
366    IF (EXISTS ${PROJECT_SOURCE_DIR}/pcre.rc)
367    ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/pcre.o
368    PRE-LINK
369    COMMAND windres ARGS pcre.rc pcre.o
370    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
371    COMMENT Using pcre coff info in mingw build)
372    SET(PCRE_SOURCES
373      ${PCRE_SOURCES} ${PROJECT_SOURCE_DIR}/pcre.o
374    )
375    ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/pcre.rc)
376    IF (EXISTS ${PROJECT_SOURCE_DIR}/pcreposix.rc)
377    ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/pcreposix.o
378    PRE-LINK
379    COMMAND windres ARGS pcreposix.rc pcreposix.o
380    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
381    COMMENT Using pcreposix coff info in mingw build)
382    SET(PCREPOSIX_SOURCES
383      ${PCREPOSIX_SOURCES} ${PROJECT_SOURCE_DIR}/pcreposix.o
384    )
385    ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/pcreposix.rc)
386    ENDIF(MINGW AND NOT PCRE_STATIC)
387    
388  SET(PCRECPP_HEADERS  SET(PCRECPP_HEADERS
389    pcrecpp.h    pcrecpp.h
390    pcre_scanner.h    pcre_scanner.h
# Line 435  ENDIF(PCRE_BUILD_PCRECPP) Line 470  ENDIF(PCRE_BUILD_PCRECPP)
470  #         SET_TARGET_PROPERTIES(pcredemo PROPERTIES COMPILE_FLAGS "-DPCRE_STATIC")  #         SET_TARGET_PROPERTIES(pcredemo PROPERTIES COMPILE_FLAGS "-DPCRE_STATIC")
471  # ENDIF(NOT BUILD_SHARED_LIBS)  # ENDIF(NOT BUILD_SHARED_LIBS)
472    
473  IF(PCRE_BUILD_PCREGREP)  IF(PCRE_BUILD_PCREGREP OR PCRE_BUILD_TESTS)
474    ADD_EXECUTABLE(pcregrep pcregrep.c)    ADD_EXECUTABLE(pcregrep pcregrep.c)
475    SET(targets ${targets} pcregrep)    SET(targets ${targets} pcregrep)
476    TARGET_LINK_LIBRARIES(pcregrep pcreposix ${PCREGREP_LIBS})    TARGET_LINK_LIBRARIES(pcregrep pcreposix ${PCREGREP_LIBS})
477  ENDIF(PCRE_BUILD_PCREGREP)  ENDIF(PCRE_BUILD_PCREGREP OR PCRE_BUILD_TESTS)
   
478    
479  # Testing  # Testing
480  IF(PCRE_BUILD_TESTS)  IF(PCRE_BUILD_TESTS)
# Line 449  IF(PCRE_BUILD_TESTS) Line 483  IF(PCRE_BUILD_TESTS)
483    ADD_EXECUTABLE(pcretest pcretest.c)    ADD_EXECUTABLE(pcretest pcretest.c)
484    SET(targets ${targets} pcretest)    SET(targets ${targets} pcretest)
485    TARGET_LINK_LIBRARIES(pcretest pcreposix ${PCRETEST_LIBS})    TARGET_LINK_LIBRARIES(pcretest pcreposix ${PCRETEST_LIBS})
486    
487    IF(PCRE_SUPPORT_JIT)    IF(PCRE_SUPPORT_JIT)
488      ADD_EXECUTABLE(pcre_jit_test pcre_jit_test.c)      ADD_EXECUTABLE(pcre_jit_test pcre_jit_test.c)
489      SET(targets ${targets} pcre_jit_test)      SET(targets ${targets} pcre_jit_test)
490      TARGET_LINK_LIBRARIES(pcre_jit_test pcre)      TARGET_LINK_LIBRARIES(pcre_jit_test pcre)
491    ENDIF(PCRE_SUPPORT_JIT)    ENDIF(PCRE_SUPPORT_JIT)
492    
493    IF(PCRE_BUILD_PCRECPP)    IF(PCRE_BUILD_PCRECPP)
494      ADD_EXECUTABLE(pcrecpp_unittest pcrecpp_unittest.cc)      ADD_EXECUTABLE(pcrecpp_unittest pcrecpp_unittest.cc)
# Line 475  IF(PCRE_BUILD_TESTS) Line 509  IF(PCRE_BUILD_TESTS)
509      TARGET_LINK_LIBRARIES(pcre_stringpiece_unittest pcrecpp)      TARGET_LINK_LIBRARIES(pcre_stringpiece_unittest pcrecpp)
510    ENDIF(PCRE_BUILD_PCRECPP)    ENDIF(PCRE_BUILD_PCRECPP)
511    
512      # exes in Debug location tested by the RunTest shell script
513      # via "make test"
514    GET_TARGET_PROPERTY(PCREGREP_EXE pcregrep DEBUG_LOCATION)    GET_TARGET_PROPERTY(PCREGREP_EXE pcregrep DEBUG_LOCATION)
515    GET_TARGET_PROPERTY(PCRETEST_EXE pcretest DEBUG_LOCATION)    GET_TARGET_PROPERTY(PCRETEST_EXE pcretest DEBUG_LOCATION)
516    
517    # Write out a CTest configuration file that sets some needed environment  # =================================================
518    # variables for the test scripts.    # Write out a CTest configuration file
519    #    #
520    FILE(WRITE ${PROJECT_BINARY_DIR}/CTestCustom.ctest    FILE(WRITE ${PROJECT_BINARY_DIR}/CTestCustom.ctest
521    "# This is a generated file.    "# This is a generated file.
522    SET(ENV{srcdir} ${PROJECT_SOURCE_DIR})  MESSAGE(\"When testing is complete, review test output in the
523    SET(ENV{pcregrep} ${PCREGREP_EXE})  ${PROJECT_BINARY_DIR}/Testing/Temporary folder.\")
524    SET(ENV{pcretest} ${PCRETEST_EXE})  MESSAGE(\"\")
525    ")  ")
526    
527          FILE(WRITE ${PROJECT_BINARY_DIR}/pcre_test.sh
528          "#! /bin/sh
529    # This is a generated file.
530    srcdir=${PROJECT_SOURCE_DIR}
531    pcregrep=${PCREGREP_EXE}
532    pcretest=${PCRETEST_EXE}
533    source ${PROJECT_SOURCE_DIR}/RunTest
534    if test \"$?\" != \"0\"; then exit 1; fi
535    # End
536    ")
537    
538          FILE(WRITE ${PROJECT_BINARY_DIR}/pcre_grep_test.sh
539          "#! /bin/sh
540    # This is a generated file.
541    srcdir=${PROJECT_SOURCE_DIR}
542    pcregrep=${PCREGREP_EXE}
543    pcretest=${PCRETEST_EXE}
544    source ${PROJECT_SOURCE_DIR}/RunGrepTest
545    if test \"$?\" != \"0\"; then exit 1; fi
546    # End
547    ")
548    
549    IF(UNIX)    IF(UNIX)
550            ADD_TEST(pcre_test      ${PROJECT_SOURCE_DIR}/RunTest)      ADD_TEST(pcre_test      sh ${PROJECT_BINARY_DIR}/pcre_test.sh)
551            ADD_TEST(pcre_grep_test ${PROJECT_SOURCE_DIR}/RunGrepTest)      ADD_TEST(pcre_grep_test sh ${PROJECT_BINARY_DIR}/pcre_grep_test.sh)
552    ENDIF(UNIX)    ENDIF(UNIX)
553    
554    IF(WIN32)    IF(WIN32)
555            # ADD_TEST(pcre_test cmd /C ${PROJECT_SOURCE_DIR}/RunTest.bat)      # Provide environment for executing the bat file version of RunTest
556            ADD_TEST(pcre_test ${PROJECT_SOURCE_DIR}/RunTest.bat)      string(REPLACE "/" "\\" winsrc "${PROJECT_SOURCE_DIR}")
557    
558        FILE(WRITE ${PROJECT_BINARY_DIR}/pcre_test.txt
559        "\@REM This is a generated file.
560    \@Echo off
561    setlocal
562    SET\ srcdir=\${srcdir}
563    SET\ pcretest=\${pcretest}
564    SET\ pcregrep=\${pcregrep}
565    call \"\${srcdir}\\RunTest.Bat\"
566    if errorlevel 1 exit /b 1
567    echo RunTest.bat tests successfully completed
568    ")
569    
570      FILE(WRITE ${PROJECT_BINARY_DIR}/BatDriver.cmake
571      "# This is a generated file.
572    # this script is run with arguments via the cmake command in add_test(NAME pcre_test_bat)
573    # BatDriver feeds the actual location of pcretest.exe and pcregrep.exe
574    FILE(TO_NATIVE_PATH \${pcretestx} pcretest)
575    FILE(TO_NATIVE_PATH \${pcregrepx} pcregrep)
576    FILE(TO_NATIVE_PATH \${srcdirx} srcdir)
577    configure_file(\"\${bindirx}/pcre_test.txt\" \"\${bindirx}/pcre_test.bat\")
578    # MESSAGE(\"cmake\ variable\ pcretest\ is\ \${pcretest}\")
579    # MESSAGE(\"cmake\ variable\ pcregrep\ is\ \${pcregrep}\")
580    # STRING(REPLACE \" \" \"\\ \" bindir \${bindirx})
581    MESSAGE(\"COMMAND pcre_test.bat \")
582    EXECUTE_PROCESS(COMMAND pcre_test.bat
583    WORKING_DIRECTORY .
584    OUTPUT_VARIABLE batoutput)
585    MESSAGE(\"OUTPUT: \${batoutput}\")
586    ")
587    
588      ADD_TEST(NAME pcre_test_bat
589      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")
590      SET_TESTS_PROPERTIES(pcre_test_bat PROPERTIES
591      PASS_REGULAR_EXPRESSION "RunTest\\.bat tests successfully completed")
592    
593        IF("$ENV{OSTYPE}" STREQUAL "msys")
594        # Both the sh and bat file versions of RunTest are run if make test is used
595        # in msys
596    
597          ADD_TEST(pcre_test_sh    sh.exe ${PROJECT_BINARY_DIR}/pcre_test.sh)
598          ADD_TEST(pcre_grep_test sh.exe ${PROJECT_BINARY_DIR}/pcre_grep_test.sh)
599    
600        ENDIF("$ENV{OSTYPE}" STREQUAL "msys")
601    ENDIF(WIN32)    ENDIF(WIN32)
602    
603    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)  
604    
605    IF(PCRE_SUPPORT_JIT)    IF(PCRE_SUPPORT_JIT)
606    ADD_TEST(pcre_jit_test         ${PCRE_JIT_TEST_EXE})    ADD_TEST(pcre_jit_test       pcre_jit_test)
607    ENDIF(PCRE_SUPPORT_JIT)    ENDIF(PCRE_SUPPORT_JIT)
608    ADD_TEST(pcrecpp_test          ${PCRECPP_UNITTEST_EXE})  
609    ADD_TEST(pcre_scanner_test     ${PCRE_SCANNER_UNITTEST_EXE})    IF(PCRE_BUILD_PCRECPP)
610    ADD_TEST(pcre_stringpiece_test ${PCRE_STRINGPIECE_UNITTEST_EXE})      ADD_TEST(pcrecpp_test          pcrecpp_unittest)
611        ADD_TEST(pcre_scanner_test     pcre_scanner_unittest)
612        ADD_TEST(pcre_stringpiece_test pcre_stringpiece_unittest)
613    
614      ENDIF(PCRE_BUILD_PCRECPP)
615  ENDIF(PCRE_BUILD_TESTS)  ENDIF(PCRE_BUILD_TESTS)
616    
617  # Installation  # Installation
# Line 550  ELSE(PCRE_BUILD_PCRECPP) Line 641  ELSE(PCRE_BUILD_PCRECPP)
641          SET(man3 ${man3_new})          SET(man3 ${man3_new})
642  ENDIF(PCRE_BUILD_PCRECPP)  ENDIF(PCRE_BUILD_PCRECPP)
643    
   
644  INSTALL(FILES ${man1} DESTINATION man/man1)  INSTALL(FILES ${man1} DESTINATION man/man1)
645  INSTALL(FILES ${man3} DESTINATION man/man3)  INSTALL(FILES ${man3} DESTINATION man/man3)
646  INSTALL(FILES ${html} DESTINATION share/doc/pcre/html)  INSTALL(FILES ${html} DESTINATION share/doc/pcre/html)
# Line 598  IF(PCRE_SHOW_REPORT) Line 688  IF(PCRE_SHOW_REPORT)
688    MESSAGE(STATUS "  Build pcregrep .................. : ${PCRE_BUILD_PCREGREP}")    MESSAGE(STATUS "  Build pcregrep .................. : ${PCRE_BUILD_PCREGREP}")
689    MESSAGE(STATUS "  Enable JIT in pcregrep .......... : ${PCRE_SUPPORT_PCREGREP_JIT}")    MESSAGE(STATUS "  Enable JIT in pcregrep .......... : ${PCRE_SUPPORT_PCREGREP_JIT}")
690    MESSAGE(STATUS "  Buffer size for pcregrep ........ : ${PCREGREP_BUFSIZE}")    MESSAGE(STATUS "  Buffer size for pcregrep ........ : ${PCREGREP_BUFSIZE}")
691    MESSAGE(STATUS "  Build tests (implies pcretest) .. : ${PCRE_BUILD_TESTS}")    MESSAGE(STATUS "  Build tests (implies pcretest  .. : ${PCRE_BUILD_TESTS}")
692      MESSAGE(STATUS "               and pcregrep)")
693    IF(ZLIB_FOUND)    IF(ZLIB_FOUND)
694      MESSAGE(STATUS "  Link pcregrep with libz ......... : ${PCRE_SUPPORT_LIBZ}")      MESSAGE(STATUS "  Link pcregrep with libz ......... : ${PCRE_SUPPORT_LIBZ}")
695    ELSE(ZLIB_FOUND)    ELSE(ZLIB_FOUND)

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

  ViewVC Help
Powered by ViewVC 1.1.5