mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
87 lines
3.1 KiB
CMake
87 lines
3.1 KiB
CMake
########################################################################
|
|
# CMake build script for Google Mock.
|
|
#
|
|
# To run the tests for Google Mock itself on Linux, use 'make test' or
|
|
# ctest. You can select which tests to run using 'ctest -R regex'.
|
|
# For more options, run 'ctest --help'.
|
|
|
|
# BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to
|
|
# make it prominent in the GUI.
|
|
option(BUILD_SHARED_LIBS "Build shared libraries (DLLs)." OFF)
|
|
|
|
# A directory to find Google Test sources.
|
|
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/gtest/CMakeLists.txt")
|
|
set(gtest_dir gtest)
|
|
else()
|
|
set(gtest_dir ../gtest)
|
|
endif()
|
|
|
|
# Defines pre_project_set_up_hermetic_build() and set_up_hermetic_build().
|
|
include("${gtest_dir}/cmake/hermetic_build.cmake" OPTIONAL)
|
|
|
|
if (COMMAND pre_project_set_up_hermetic_build)
|
|
# Google Test also calls hermetic setup functions from add_subdirectory,
|
|
# although its changes will not affect things at the current scope.
|
|
pre_project_set_up_hermetic_build()
|
|
endif()
|
|
|
|
########################################################################
|
|
#
|
|
# Project-wide settings
|
|
|
|
# Name of the project.
|
|
#
|
|
# CMake files in this project can refer to the root source directory
|
|
# as ${gmock_SOURCE_DIR} and to the root binary directory as
|
|
# ${gmock_BINARY_DIR}.
|
|
# Language "C" is required for find_package(Threads).
|
|
project(gmock CXX C)
|
|
cmake_minimum_required(VERSION 2.6.2)
|
|
|
|
if (COMMAND set_up_hermetic_build)
|
|
set_up_hermetic_build()
|
|
endif()
|
|
|
|
if (NOT MSVC)
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-field-initializers -Wno-format-nonliteral")
|
|
endif()
|
|
|
|
# Instructs CMake to process Google Test's CMakeLists.txt and add its
|
|
# targets to the current scope. We are placing Google Test's binary
|
|
# directory in a subdirectory of our own as VC compilation may break
|
|
# if they are the same (the default).
|
|
add_subdirectory("${gtest_dir}" "${gmock_BINARY_DIR}/gtest")
|
|
|
|
# Although Google Test's CMakeLists.txt calls this function, the
|
|
# changes there don't affect the current scope. Therefore we have to
|
|
# call it again here.
|
|
config_compiler_and_linker() # from ${gtest_dir}/cmake/internal_utils.cmake
|
|
|
|
# Adds Google Mock's and Google Test's header directories to the search path.
|
|
include_directories("${gmock_SOURCE_DIR}/include"
|
|
"${gmock_SOURCE_DIR}"
|
|
"${gtest_SOURCE_DIR}/include"
|
|
# This directory is needed to build directly from Google
|
|
# Test sources.
|
|
"${gtest_SOURCE_DIR}")
|
|
|
|
########################################################################
|
|
#
|
|
# Defines the gmock & gmock_main libraries. User tests should link
|
|
# with one of them.
|
|
|
|
# Google Mock libraries. We build them using more strict warnings than what
|
|
# are used for other targets, to ensure that Google Mock can be compiled by
|
|
# a user aggressive about warnings.
|
|
cxx_library(gmock
|
|
"${cxx_strict}"
|
|
"${gtest_dir}/src/gtest-all.cc"
|
|
src/gmock-all.cc)
|
|
|
|
cxx_library(gmock_main
|
|
"${cxx_strict}"
|
|
"${gtest_dir}/src/gtest-all.cc"
|
|
src/gmock-all.cc
|
|
src/gmock_main.cc)
|
|
|