Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
yangql
googletest
Commits
f5260ae7
Commit
f5260ae7
authored
Oct 02, 2018
by
Matthieu
Committed by
Gennadiy Civil
Oct 02, 2018
Browse files
Merge c798e39a4f96f5a985126cc3fab4738b6412cfc1 into
e93da239
Closes #1836 PiperOrigin-RevId: 215461025
parent
e93da239
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
99 additions
and
19 deletions
+99
-19
googlemock/CMakeLists.txt
googlemock/CMakeLists.txt
+14
-0
googletest/CMakeLists.txt
googletest/CMakeLists.txt
+14
-0
googletest/cmake/internal_utils.cmake
googletest/cmake/internal_utils.cmake
+71
-19
No files found.
googlemock/CMakeLists.txt
View file @
f5260ae7
...
@@ -145,6 +145,20 @@ if (gmock_build_tests)
...
@@ -145,6 +145,20 @@ if (gmock_build_tests)
# 'make test' or ctest.
# 'make test' or ctest.
enable_testing
()
enable_testing
()
if
(
WIN32
)
file
(
GENERATE OUTPUT
"
${
CMAKE_CURRENT_BINARY_DIR
}
/$<CONFIG>/RunTest.ps1"
CONTENT
"$project_bin =
\"
${
CMAKE_BINARY_DIR
}
/bin/$<CONFIG>
\"
$env:Path =
\"
$project_bin;$env:Path
\"
& $args"
)
elseif
(
MINGW
)
file
(
GENERATE OUTPUT
"
${
CMAKE_CURRENT_BINARY_DIR
}
/RunTest.ps1"
CONTENT
"$project_bin = (cygpath --windows
${
CMAKE_BINARY_DIR
}
/bin)
$env:Path =
\"
$project_bin;$env:Path
\"
& $args"
)
endif
()
############################################################
############################################################
# C++ tests built with standard compiler flags.
# C++ tests built with standard compiler flags.
...
...
googletest/CMakeLists.txt
View file @
f5260ae7
...
@@ -187,6 +187,20 @@ if (gtest_build_tests)
...
@@ -187,6 +187,20 @@ if (gtest_build_tests)
# 'make test' or ctest.
# 'make test' or ctest.
enable_testing
()
enable_testing
()
if
(
WIN32
)
file
(
GENERATE OUTPUT
"
${
CMAKE_CURRENT_BINARY_DIR
}
/$<CONFIG>/RunTest.ps1"
CONTENT
"$project_bin =
\"
${
CMAKE_BINARY_DIR
}
/bin/$<CONFIG>
\"
$env:Path =
\"
$project_bin;$env:Path
\"
& $args"
)
elseif
(
MINGW
)
file
(
GENERATE OUTPUT
"
${
CMAKE_CURRENT_BINARY_DIR
}
/RunTest.ps1"
CONTENT
"$project_bin = (cygpath --windows
${
CMAKE_BINARY_DIR
}
/bin)
$env:Path =
\"
$project_bin;$env:Path
\"
& $args"
)
endif
()
############################################################
############################################################
# C++ tests built with standard compiler flags.
# C++ tests built with standard compiler flags.
...
...
googletest/cmake/internal_utils.cmake
View file @
f5260ae7
...
@@ -167,6 +167,22 @@ function(cxx_library_with_type name type cxx_flags)
...
@@ -167,6 +167,22 @@ function(cxx_library_with_type name type cxx_flags)
set_target_properties
(
${
name
}
set_target_properties
(
${
name
}
PROPERTIES
PROPERTIES
DEBUG_POSTFIX
"d"
)
DEBUG_POSTFIX
"d"
)
# Set the output directory for build artifacts
set_target_properties
(
${
name
}
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY
"
${
CMAKE_BINARY_DIR
}
/bin"
LIBRARY_OUTPUT_DIRECTORY
"
${
CMAKE_BINARY_DIR
}
/lib"
ARCHIVE_OUTPUT_DIRECTORY
"
${
CMAKE_BINARY_DIR
}
/lib"
PDB_OUTPUT_DIRECTORY
"
${
CMAKE_BINARY_DIR
}
/bin"
)
# make PDBs match library name
get_target_property
(
pdb_debug_postfix
${
name
}
DEBUG_POSTFIX
)
set_target_properties
(
${
name
}
PROPERTIES
PDB_NAME
"
${
name
}
"
PDB_NAME_DEBUG
"
${
name
}${
pdb_debug_postfix
}
"
COMPILE_PDB_NAME
"
${
name
}
"
COMPILE_PDB_NAME_DEBUG
"
${
name
}${
pdb_debug_postfix
}
"
)
if
(
BUILD_SHARED_LIBS OR type STREQUAL
"SHARED"
)
if
(
BUILD_SHARED_LIBS OR type STREQUAL
"SHARED"
)
set_target_properties
(
${
name
}
set_target_properties
(
${
name
}
PROPERTIES
PROPERTIES
...
@@ -244,7 +260,13 @@ find_package(PythonInterp)
...
@@ -244,7 +260,13 @@ find_package(PythonInterp)
# from the given source files with the given compiler flags.
# from the given source files with the given compiler flags.
function
(
cxx_test_with_flags name cxx_flags libs
)
function
(
cxx_test_with_flags name cxx_flags libs
)
cxx_executable_with_flags
(
${
name
}
"
${
cxx_flags
}
"
"
${
libs
}
"
${
ARGN
}
)
cxx_executable_with_flags
(
${
name
}
"
${
cxx_flags
}
"
"
${
libs
}
"
${
ARGN
}
)
add_test
(
NAME
${
name
}
COMMAND
${
name
}
)
if
(
WIN32 OR MINGW
)
add_test
(
NAME
${
name
}
COMMAND
"powershell"
"-Command"
"
${
CMAKE_CURRENT_BINARY_DIR
}
/$<CONFIG>/RunTest.ps1"
"$<TARGET_FILE:
${
name
}
>"
)
else
()
add_test
(
NAME
${
name
}
COMMAND
"$<TARGET_FILE:
${
name
}
>"
)
endif
()
endfunction
()
endfunction
()
# cxx_test(name libs srcs...)
# cxx_test(name libs srcs...)
...
@@ -263,33 +285,51 @@ endfunction()
...
@@ -263,33 +285,51 @@ endfunction()
# test/name.py. It does nothing if Python is not installed.
# test/name.py. It does nothing if Python is not installed.
function
(
py_test name
)
function
(
py_test name
)
if
(
PYTHONINTERP_FOUND
)
if
(
PYTHONINTERP_FOUND
)
if
(
${
CMAKE_MAJOR_VERSION
}
.
${
CMAKE_MINOR_VERSION
}
GREATER 3.1
)
if
(
"
${
CMAKE_MAJOR_VERSION
}
.
${
CMAKE_MINOR_VERSION
}
"
VERSION_
GREATER 3.1
)
if
(
CMAKE_CONFIGURATION_TYPES
)
if
(
CMAKE_CONFIGURATION_TYPES
)
# Multi-configuration build generators as for Visual Studio save
# Multi-configuration build generators as for Visual Studio save
# output in a subdirectory of CMAKE_CURRENT_BINARY_DIR (Debug,
# output in a subdirectory of CMAKE_CURRENT_BINARY_DIR (Debug,
# Release etc.), so we have to provide it here.
# Release etc.), so we have to provide it here.
add_test
(
if
(
WIN32 OR MINGW
)
NAME
${
name
}
add_test
(
NAME
${
name
}
COMMAND
${
PYTHON_EXECUTABLE
}
${
CMAKE_CURRENT_SOURCE_DIR
}
/test/
${
name
}
.py
COMMAND powershell -Command
${
CMAKE_CURRENT_BINARY_DIR
}
/$<CONFIG>/RunTest.ps1
${
PYTHON_EXECUTABLE
}
${
CMAKE_CURRENT_SOURCE_DIR
}
/test/
${
name
}
.py
--build_dir=
${
CMAKE_CURRENT_BINARY_DIR
}
/$<CONFIG>
${
ARGN
}
)
--build_dir=
${
CMAKE_CURRENT_BINARY_DIR
}
/$<CONFIG>
${
ARGN
}
)
else
()
add_test
(
NAME
${
name
}
COMMAND
${
PYTHON_EXECUTABLE
}
${
CMAKE_CURRENT_SOURCE_DIR
}
/test/
${
name
}
.py
--build_dir=
${
CMAKE_CURRENT_BINARY_DIR
}
/$<CONFIG>
${
ARGN
}
)
endif
()
else
(
CMAKE_CONFIGURATION_TYPES
)
else
(
CMAKE_CONFIGURATION_TYPES
)
# Single-configuration build generators like Makefile generators
# Single-configuration build generators like Makefile generators
# don't have subdirs below CMAKE_CURRENT_BINARY_DIR.
# don't have subdirs below CMAKE_CURRENT_BINARY_DIR.
add_test
(
if
(
WIN32 OR MINGW
)
NAME
${
name
}
add_test
(
NAME
${
name
}
COMMAND
${
PYTHON_EXECUTABLE
}
${
CMAKE_CURRENT_SOURCE_DIR
}
/test/
${
name
}
.py
COMMAND powershell -Command
${
CMAKE_CURRENT_BINARY_DIR
}
/RunTest.ps1
${
PYTHON_EXECUTABLE
}
${
CMAKE_CURRENT_SOURCE_DIR
}
/test/
${
name
}
.py
--build_dir=
${
CMAKE_CURRENT_BINARY_DIR
}
${
ARGN
}
)
--build_dir=
${
CMAKE_CURRENT_BINARY_DIR
}
${
ARGN
}
)
else
()
add_test
(
NAME
${
name
}
COMMAND
${
PYTHON_EXECUTABLE
}
${
CMAKE_CURRENT_SOURCE_DIR
}
/test/
${
name
}
.py
--build_dir=
${
CMAKE_CURRENT_BINARY_DIR
}
${
ARGN
}
)
endif
()
endif
(
CMAKE_CONFIGURATION_TYPES
)
endif
(
CMAKE_CONFIGURATION_TYPES
)
else
(
${
CMAKE_MAJOR_VERSION
}
.
${
CMAKE_MINOR_VERSION
}
GREATER 3.1
)
else
(
)
# ${CMAKE_CURRENT_BINARY_DIR} is known at configuration time, so we can
# ${CMAKE_CURRENT_BINARY_DIR} is known at configuration time, so we can
# directly bind it from cmake. ${CTEST_CONFIGURATION_TYPE} is known
# directly bind it from cmake. ${CTEST_CONFIGURATION_TYPE} is known
# only at ctest runtime (by calling ctest -c <Configuration>), so
# only at ctest runtime (by calling ctest -c <Configuration>), so
# we have to escape $ to delay variable substitution here.
# we have to escape $ to delay variable substitution here.
add_test
(
if
(
WIN32 OR MINGW
)
${
name
}
add_test
(
NAME
${
name
}
${
PYTHON_EXECUTABLE
}
${
CMAKE_CURRENT_SOURCE_DIR
}
/test/
${
name
}
.py
COMMAND powershell -Command
${
CMAKE_CURRENT_BINARY_DIR
}
/RunTest.ps1
--build_dir=
${
CMAKE_CURRENT_BINARY_DIR
}
/\
${
CTEST_CONFIGURATION_TYPE
}
${
ARGN
}
)
${
PYTHON_EXECUTABLE
}
${
CMAKE_CURRENT_SOURCE_DIR
}
/test/
${
name
}
.py
endif
(
${
CMAKE_MAJOR_VERSION
}
.
${
CMAKE_MINOR_VERSION
}
GREATER 3.1
)
--build_dir=
${
CMAKE_CURRENT_BINARY_DIR
}
/\
${
CTEST_CONFIGURATION_TYPE
}
${
ARGN
}
)
else
()
add_test
(
NAME
${
name
}
COMMAND
${
PYTHON_EXECUTABLE
}
${
CMAKE_CURRENT_SOURCE_DIR
}
/test/
${
name
}
.py
--build_dir=
${
CMAKE_CURRENT_BINARY_DIR
}
/\
${
CTEST_CONFIGURATION_TYPE
}
${
ARGN
}
)
endif
()
endif
()
endif
(
PYTHONINTERP_FOUND
)
endif
(
PYTHONINTERP_FOUND
)
endfunction
()
endfunction
()
...
@@ -306,6 +346,18 @@ function(install_project)
...
@@ -306,6 +346,18 @@ function(install_project)
RUNTIME DESTINATION
"
${
CMAKE_INSTALL_BINDIR
}
"
RUNTIME DESTINATION
"
${
CMAKE_INSTALL_BINDIR
}
"
ARCHIVE DESTINATION
"
${
CMAKE_INSTALL_LIBDIR
}
"
ARCHIVE DESTINATION
"
${
CMAKE_INSTALL_LIBDIR
}
"
LIBRARY DESTINATION
"
${
CMAKE_INSTALL_LIBDIR
}
"
)
LIBRARY DESTINATION
"
${
CMAKE_INSTALL_LIBDIR
}
"
)
if
(
CMAKE_CXX_COMPILER_ID MATCHES
"MSVC"
)
# Install PDBs
foreach
(
t
${
ARGN
}
)
get_target_property
(
t_pdb_name
${
t
}
COMPILE_PDB_NAME
)
get_target_property
(
t_pdb_name_debug
${
t
}
COMPILE_PDB_NAME_DEBUG
)
get_target_property
(
t_pdb_output_directory
${
t
}
PDB_OUTPUT_DIRECTORY
)
install
(
FILES
"
${
t_pdb_output_directory
}
/
\$
{CMAKE_INSTALL_CONFIG_NAME}/$<IF:$<CONFIG:Debug>,
${
t_pdb_name_debug
}
,
${
t_pdb_name
}
>.pdb"
DESTINATION
${
CMAKE_INSTALL_LIBDIR
}
OPTIONAL
)
endforeach
()
endif
()
# Configure and install pkgconfig files.
# Configure and install pkgconfig files.
foreach
(
t
${
ARGN
}
)
foreach
(
t
${
ARGN
}
)
set
(
configured_pc
"
${
generated_dir
}
/
${
t
}
.pc"
)
set
(
configured_pc
"
${
generated_dir
}
/
${
t
}
.pc"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment