From cc246ecb5675983a879af97b0b466c6d7d64d308 Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Wed, 30 Aug 2017 11:59:36 +0200 Subject: [PATCH 1/6] use build type set in .travis.yml The BUILD_TYPE variable of .travis.yml was ignored up to now. --- travis.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/travis.sh b/travis.sh index 1b23a3d4..819e366c 100755 --- a/travis.sh +++ b/travis.sh @@ -9,6 +9,7 @@ cmake -Dgtest_build_samples=ON \ -Dgtest_build_tests=ON \ -Dgmock_build_tests=ON \ -DCMAKE_CXX_FLAGS=$CXX_FLAGS \ + -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ .. make CTEST_OUTPUT_ON_FAILURE=1 make test From dae044d4b9869db985f32eeec78889440f646fb7 Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Wed, 30 Aug 2017 12:00:24 +0200 Subject: [PATCH 2/6] use upper-case build type While cmake does not complain on build type 'debug', the cmake documentation always spells it 'Debug', so take this. --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index c155e571..417d2c51 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,8 +36,8 @@ compiler: script: ./travis.sh env: matrix: - - SHARED_LIB=OFF STATIC_LIB=ON CMAKE_PKG=OFF BUILD_TYPE=debug VERBOSE=1 - - SHARED_LIB=OFF STATIC_LIB=ON CMAKE_PKG=OFF BUILD_TYPE=debug VERBOSE=1 CXX_FLAGS=-std=c++11 + - SHARED_LIB=OFF STATIC_LIB=ON CMAKE_PKG=OFF BUILD_TYPE=Debug VERBOSE=1 + - SHARED_LIB=OFF STATIC_LIB=ON CMAKE_PKG=OFF BUILD_TYPE=Debug VERBOSE=1 CXX_FLAGS=-std=c++11 notifications: email: false sudo: false From 7529c8aa05c281d51db4e22a533d9b201f461993 Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Wed, 30 Aug 2017 12:48:28 +0200 Subject: [PATCH 3/6] remove obsolete comment regarding python tests on linux --- googletest/cmake/internal_utils.cmake | 2 -- 1 file changed, 2 deletions(-) diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake index f0f54d02..fb1fb683 100644 --- a/googletest/cmake/internal_utils.cmake +++ b/googletest/cmake/internal_utils.cmake @@ -236,8 +236,6 @@ endfunction() # creates a Python test with the given name whose main module is in # test/name.py. It does nothing if Python is not installed. function(py_test name) - # We are not supporting Python tests on Linux yet as they consider - # all Linux environments to be google3 and try to use google3 features. if (PYTHONINTERP_FOUND) # ${CMAKE_BINARY_DIR} is known at configuration time, so we can # directly bind it from cmake. ${CTEST_CONFIGURATION_TYPE} is known From 73d58dd4c83883b46697798e978d576b28b1d24e Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Wed, 30 Aug 2017 12:59:06 +0200 Subject: [PATCH 4/6] ask cmake for per-configuration output subdir On single-configuration build systems as Makefile Generators, there is no subdirectory for the configuration in the build tree - therefore ask cmake for the subdir by using CMAKE_CFG_INTDIR, which is just '.' on single-configuration build systems (Linux et al.). --- googletest/cmake/internal_utils.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake index fb1fb683..cdaeb7a1 100644 --- a/googletest/cmake/internal_utils.cmake +++ b/googletest/cmake/internal_utils.cmake @@ -245,7 +245,7 @@ function(py_test name) add_test( NAME ${name} COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py - --build_dir=${CMAKE_CURRENT_BINARY_DIR}/$) + --build_dir=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}) else (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.1) add_test( ${name} From 47ad2993b68250d8fd5eb604d5a88ff976bb1a3e Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Wed, 30 Aug 2017 15:14:34 +0200 Subject: [PATCH 5/6] Revert "ask cmake for per-configuration output subdir" This reverts commit 73d58dd4c83883b46697798e978d576b28b1d24e. Unfortunately, ${CMAKE_CFG_INTDIR} is set during build only and doesn't help here. --- googletest/cmake/internal_utils.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake index cdaeb7a1..fb1fb683 100644 --- a/googletest/cmake/internal_utils.cmake +++ b/googletest/cmake/internal_utils.cmake @@ -245,7 +245,7 @@ function(py_test name) add_test( NAME ${name} COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py - --build_dir=${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}) + --build_dir=${CMAKE_CURRENT_BINARY_DIR}/$) else (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.1) add_test( ${name} From 9ba7946bde6349d9fd8621d527137c226f69bd83 Mon Sep 17 00:00:00 2001 From: Herbert Thielen Date: Wed, 30 Aug 2017 19:17:26 +0200 Subject: [PATCH 6/6] create different python based tests for single and multi configuration build generators --- googletest/cmake/internal_utils.cmake | 30 +++++++++++++++++++-------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake index fb1fb683..ec5d08c0 100644 --- a/googletest/cmake/internal_utils.cmake +++ b/googletest/cmake/internal_utils.cmake @@ -237,20 +237,32 @@ endfunction() # test/name.py. It does nothing if Python is not installed. function(py_test name) if (PYTHONINTERP_FOUND) - # ${CMAKE_BINARY_DIR} is known at configuration time, so we can - # directly bind it from cmake. ${CTEST_CONFIGURATION_TYPE} is known - # only at ctest runtime (by calling ctest -c ), so - # we have to escape $ to delay variable substitution here. if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.1) - add_test( - NAME ${name} - COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py - --build_dir=${CMAKE_CURRENT_BINARY_DIR}/$) + if (CMAKE_CONFIGURATION_TYPES) + # Multi-configuration build generators as for Visual Studio save + # output in a subdirectory of CMAKE_CURRENT_BINARY_DIR (Debug, + # Release etc.), so we have to provide it here. + add_test( + NAME ${name} + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py + --build_dir=${CMAKE_CURRENT_BINARY_DIR}/$) + else (CMAKE_CONFIGURATION_TYPES) + # Single-configuration build generators like Makefile generators + # don't have subdirs below CMAKE_CURRENT_BINARY_DIR. + add_test( + NAME ${name} + COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py + --build_dir=${CMAKE_CURRENT_BINARY_DIR}) + endif (CMAKE_CONFIGURATION_TYPES) else (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.1) + # ${CMAKE_CURRENT_BINARY_DIR} is known at configuration time, so we can + # directly bind it from cmake. ${CTEST_CONFIGURATION_TYPE} is known + # only at ctest runtime (by calling ctest -c ), so + # we have to escape $ to delay variable substitution here. add_test( ${name} ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test/${name}.py --build_dir=${CMAKE_CURRENT_BINARY_DIR}/\${CTEST_CONFIGURATION_TYPE}) endif (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.1) - endif() + endif(PYTHONINTERP_FOUND) endfunction()