File tree 6 files changed +14
-11
lines changed
6 files changed +14
-11
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ if(BUILD_TESTING)
20
20
include (cmake/osrf_testing_tools_cpp_require_googletest.cmake)
21
21
# ensures target gtest_main exists
22
22
osrf_testing_tools_cpp_require_googletest(VERSION_GTE 1.8
23
- VENDOR_DIR "${CMAKE_SOURCE_DIR } /vendor" )
23
+ VENDOR_DIR "${PROJECT_SOURCE_DIR } /vendor" )
24
24
25
25
add_subdirectory (test )
26
26
endif ()
Original file line number Diff line number Diff line change @@ -48,14 +48,14 @@ macro(osrf_testing_tools_cpp_extract_and_build_googletest
48
48
49
49
execute_process (COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR} " .
50
50
RESULT_VARIABLE result
51
- WORKING_DIRECTORY ${CMAKE_BINARY_DIR } /googletest-${GOOGLETEST_VERSION} -extracted)
51
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR } /googletest-${GOOGLETEST_VERSION} -extracted)
52
52
if (result)
53
53
message (FATAL_ERROR "CMake step for googletest failed: ${result} " )
54
54
endif ()
55
55
56
56
execute_process (COMMAND ${CMAKE_COMMAND} --build .
57
57
RESULT_VARIABLE result
58
- WORKING_DIRECTORY ${CMAKE_BINARY_DIR } /googletest-${GOOGLETEST_VERSION} -extracted)
58
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR } /googletest-${GOOGLETEST_VERSION} -extracted)
59
59
if (result)
60
60
message (FATAL_ERROR "Build step for googletest failed: ${result} " )
61
61
endif ()
@@ -74,13 +74,13 @@ macro(osrf_testing_tools_cpp_extract_and_build_googletest
74
74
# add the -pthread flag for Linux machines so it will always work
75
75
execute_process (COMMAND bash "-c" "sed -i 's@\$ {CMAKE_THREAD_LIBS_INIT}@\$ {CMAKE_THREAD_LIBS_INIT} -pthread@' ${__prefix} -src/googletest/cmake/internal_utils.cmake"
76
76
RESULT_VARIABLE result
77
- WORKING_DIRECTORY ${CMAKE_BINARY_DIR } /${__prefix} -extracted)
77
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR } /${__prefix} -extracted)
78
78
endif ()
79
79
# Add googletest directly to our build. This defines
80
80
# the gtest and gtest_main targets.
81
81
add_subdirectory (
82
- ${CMAKE_BINARY_DIR } /${__prefix} -extracted/${__prefix} -src
83
- ${CMAKE_BINARY_DIR } /${__prefix} -extracted/${__prefix} -build
82
+ ${CMAKE_CURRENT_BINARY_DIR } /${__prefix} -extracted/${__prefix} -src
83
+ ${CMAKE_CURRENT_BINARY_DIR } /${__prefix} -extracted/${__prefix} -build
84
84
EXCLUDE_FROM_ALL
85
85
)
86
86
unset (__prefix)
Original file line number Diff line number Diff line change @@ -45,6 +45,9 @@ set(OSRF_TESTING_TOOLS_CPP_REQUIRE_GOOGLETEST_VERSION_SETUP)
45
45
# @public
46
46
#
47
47
macro (osrf_testing_tools_cpp_require_googletest)
48
+ if (TARGET gtest OR TARGET gtest_main)
49
+ return ()
50
+ endif ()
48
51
# Make sure this was only called once.
49
52
if (OSRF_TESTING_TOOLS_CPP_REQUIRE_GOOGLETEST_VERSION_SETUP)
50
53
set (error_msg "osrf_testing_tools_cpp_require_googletest():" )
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ add_library(memory_tools SHARED
13
13
14
14
target_include_directories (memory_tools
15
15
PUBLIC
16
- $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR } /include >
16
+ $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR } /include >
17
17
$<INSTALL_INTERFACE:include >
18
18
)
19
19
@@ -97,4 +97,4 @@ install(EXPORT memory_tools_interpose
97
97
set (memory_tools_extra_test_env "${memory_tools_extra_test_env} " PARENT_SCOPE)
98
98
set (memory_tools_is_available "${memory_tools_is_available} " PARENT_SCOPE)
99
99
set (memory_tools_src_dir_internal_testing_only
100
- "$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR } /src>" PARENT_SCOPE)
100
+ "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR } /src>" PARENT_SCOPE)
Original file line number Diff line number Diff line change @@ -3,5 +3,5 @@ add_test(
3
3
NAME "test_osrf_testing_tools_cpp_filter_versions_cmake"
4
4
COMMAND
5
5
${CMAKE_COMMAND} -P
6
- "${CMAKE_SOURCE_DIR } /test/cmake/test_osrf_testing_tools_cpp_filter_versions.cmake"
6
+ "${PROJECT_SOURCE_DIR } /test/cmake/test_osrf_testing_tools_cpp_filter_versions.cmake"
7
7
)
Original file line number Diff line number Diff line change @@ -9,8 +9,8 @@ include(ExternalProject)
9
9
ExternalProject_Add(googletest
10
10
URL "@GOOGLETEST_ARCHIVE_LOCATION@"
11
11
URL_MD5 "@GOOGLETEST_MD5SUM@"
12
- SOURCE_DIR "${CMAKE_BINARY_DIR } /googletest-@GOOGLETEST_VERSION@-src"
13
- BINARY_DIR "${CMAKE_BINARY_DIR } /googletest-@GOOGLETEST_VERSION@-build"
12
+ SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR } /googletest-@GOOGLETEST_VERSION@-src"
13
+ BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR } /googletest-@GOOGLETEST_VERSION@-build"
14
14
CONFIGURE_COMMAND ""
15
15
BUILD_COMMAND ""
16
16
INSTALL_COMMAND ""
You can’t perform that action at this time.
0 commit comments