tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

DownloadGTest.cmake (1648B)


      1 # Integrates googletest at configure time.  Based on the instructions at
      2 # https://github.com/google/googletest/tree/master/googletest#incorporating-into-an-existing-cmake-project
      3 
      4 # Set up the external googletest project, downloading the latest from Github
      5 # master if requested.
      6 configure_file(
      7  ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt.in
      8  ${CMAKE_BINARY_DIR}/googletest-external/CMakeLists.txt
      9 )
     10 
     11 set(ABSL_SAVE_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
     12 set(ABSL_SAVE_CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
     13 if (BUILD_SHARED_LIBS)
     14  set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
     15  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGTEST_CREATE_SHARED_LIBRARY=1")
     16 endif()
     17 
     18 # Configure and build the googletest source.
     19 execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
     20  RESULT_VARIABLE result
     21  WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-external )
     22 if(result)
     23  message(FATAL_ERROR "CMake step for googletest failed: ${result}")
     24 endif()
     25 
     26 execute_process(COMMAND ${CMAKE_COMMAND} --build .
     27  RESULT_VARIABLE result
     28  WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-external)
     29 if(result)
     30  message(FATAL_ERROR "Build step for googletest failed: ${result}")
     31 endif()
     32 
     33 set(CMAKE_CXX_FLAGS ${ABSL_SAVE_CMAKE_CXX_FLAGS})
     34 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${ABSL_SAVE_CMAKE_RUNTIME_OUTPUT_DIRECTORY})
     35 
     36 # Prevent overriding the parent project's compiler/linker settings on Windows
     37 set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
     38 
     39 # Add googletest directly to our build. This defines the gtest and gtest_main
     40 # targets.
     41 add_subdirectory(${absl_gtest_src_dir} ${absl_gtest_build_dir} EXCLUDE_FROM_ALL)