diff options
author | Gennadiy Civil <gennadiycivil@users.noreply.github.com> | 2018-09-04 14:56:49 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-04 14:56:49 (GMT) |
commit | 3787a483b994784c6710fdf8cc7fb405a4886dd3 (patch) | |
tree | 9808dd0a655ba1855b0f239c6db273b598c9bad8 /googletest | |
parent | 25bf88432123d13a6ce2fde9a879ba90399fce1d (diff) | |
parent | de9675986f49becc83626820a6158686240ba30a (diff) | |
download | googletest-3787a483b994784c6710fdf8cc7fb405a4886dd3.zip googletest-3787a483b994784c6710fdf8cc7fb405a4886dd3.tar.gz googletest-3787a483b994784c6710fdf8cc7fb405a4886dd3.tar.bz2 |
Merge pull request #1803 from KindDragon/patch-2
Update documentation to syntax highlight code
Diffstat (limited to 'googletest')
-rw-r--r-- | googletest/README.md | 106 | ||||
-rw-r--r-- | googletest/docs/Pkgconfig.md | 4 | ||||
-rw-r--r-- | googletest/docs/PumpManual.md | 6 |
3 files changed, 60 insertions, 56 deletions
diff --git a/googletest/README.md b/googletest/README.md index e30fe80..46de3dd 100644 --- a/googletest/README.md +++ b/googletest/README.md @@ -115,60 +115,64 @@ pulled into the main build with `add_subdirectory()`. For example: New file `CMakeLists.txt.in`: - cmake_minimum_required(VERSION 2.8.2) - - project(googletest-download NONE) - - include(ExternalProject) - ExternalProject_Add(googletest - GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG master - SOURCE_DIR "${CMAKE_BINARY_DIR}/googletest-src" - BINARY_DIR "${CMAKE_BINARY_DIR}/googletest-build" - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" - TEST_COMMAND "" - ) +``` cmake +cmake_minimum_required(VERSION 2.8.2) + +project(googletest-download NONE) + +include(ExternalProject) +ExternalProject_Add(googletest + GIT_REPOSITORY https://github.com/google/googletest.git + GIT_TAG master + SOURCE_DIR "${CMAKE_BINARY_DIR}/googletest-src" + BINARY_DIR "${CMAKE_BINARY_DIR}/googletest-build" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + TEST_COMMAND "" +) +``` Existing build's `CMakeLists.txt`: - # Download and unpack googletest at configure time - configure_file(CMakeLists.txt.in googletest-download/CMakeLists.txt) - execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . - RESULT_VARIABLE result - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download ) - if(result) - message(FATAL_ERROR "CMake step for googletest failed: ${result}") - endif() - execute_process(COMMAND ${CMAKE_COMMAND} --build . - RESULT_VARIABLE result - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download ) - if(result) - message(FATAL_ERROR "Build step for googletest failed: ${result}") - endif() - - # Prevent overriding the parent project's compiler/linker - # settings on Windows - set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) - - # Add googletest directly to our build. This defines - # the gtest and gtest_main targets. - add_subdirectory(${CMAKE_BINARY_DIR}/googletest-src - ${CMAKE_BINARY_DIR}/googletest-build - EXCLUDE_FROM_ALL) - - # The gtest/gtest_main targets carry header search path - # dependencies automatically when using CMake 2.8.11 or - # later. Otherwise we have to add them here ourselves. - if (CMAKE_VERSION VERSION_LESS 2.8.11) - include_directories("${gtest_SOURCE_DIR}/include") - endif() - - # Now simply link against gtest or gtest_main as needed. Eg - add_executable(example example.cpp) - target_link_libraries(example gtest_main) - add_test(NAME example_test COMMAND example) +``` cmake +# Download and unpack googletest at configure time +configure_file(CMakeLists.txt.in googletest-download/CMakeLists.txt) +execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . + RESULT_VARIABLE result + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download ) +if(result) + message(FATAL_ERROR "CMake step for googletest failed: ${result}") +endif() +execute_process(COMMAND ${CMAKE_COMMAND} --build . + RESULT_VARIABLE result + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download ) +if(result) + message(FATAL_ERROR "Build step for googletest failed: ${result}") +endif() + +# Prevent overriding the parent project's compiler/linker +# settings on Windows +set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) + +# Add googletest directly to our build. This defines +# the gtest and gtest_main targets. +add_subdirectory(${CMAKE_BINARY_DIR}/googletest-src + ${CMAKE_BINARY_DIR}/googletest-build + EXCLUDE_FROM_ALL) + +# The gtest/gtest_main targets carry header search path +# dependencies automatically when using CMake 2.8.11 or +# later. Otherwise we have to add them here ourselves. +if (CMAKE_VERSION VERSION_LESS 2.8.11) + include_directories("${gtest_SOURCE_DIR}/include") +endif() + +# Now simply link against gtest or gtest_main as needed. Eg +add_executable(example example.cpp) +target_link_libraries(example gtest_main) +add_test(NAME example_test COMMAND example) +``` Note that this approach requires CMake 2.8.2 or later due to its use of the `ExternalProject_Add()` command. The above technique is discussed in more detail diff --git a/googletest/docs/Pkgconfig.md b/googletest/docs/Pkgconfig.md index 9761289..8b4acda 100644 --- a/googletest/docs/Pkgconfig.md +++ b/googletest/docs/Pkgconfig.md @@ -19,7 +19,7 @@ all examples here we assume you want to compile the sample Using `pkg-config` in CMake is fairly easy: -``` +``` cmake cmake_minimum_required(VERSION 3.0) cmake_policy(SET CMP0048 NEW) @@ -102,7 +102,7 @@ test('first_and_only_test', testapp) Since `pkg-config` is a small Unix command-line utility, it can be used in handwritten `Makefile`s too: -``` +``` Makefile GTEST_CFLAGS = `pkg-config --cflags gtest_main` GTEST_LIBS = `pkg-config --libs gtest_main` diff --git a/googletest/docs/PumpManual.md b/googletest/docs/PumpManual.md index 827bb24..3ec428e 100644 --- a/googletest/docs/PumpManual.md +++ b/googletest/docs/PumpManual.md @@ -71,7 +71,7 @@ $if i == 0 [[ will be translated by the Pump compiler to: -``` +``` cpp // Foo0 does blah for 0-ary predicates. template <size_t N> class Foo0 { @@ -107,7 +107,7 @@ $$ The text between i and [[ is the separator between iterations. will generate one of the following lines (without the comments), depending on the value of `n`: -``` +``` cpp Func(); // If n is 0. Func(a1); // If n is 1. Func(a1 + a2); // If n is 2. @@ -140,7 +140,7 @@ up in your output. ## Grammar ## -``` +``` ebnf code ::= atomic_code* atomic_code ::= $var id = exp | $var id = [[ code ]] |