我已将GitHub中的Google Test repo克隆到个人存储库中,然后将其作为子模块添加到我的主项目中(使用git)。
我希望能够使用#include "gtest/gtest.h"
我的文件结构中gtest的位置是:
C:\GIT\MyProj\Externals\ABCD\tests\externals\UnitTests\externals\GoogleTest\googletest\include\gtest
UnitTests
是一个子模块,GoogleTest
是该子模块内的一个子模块。
我的尝试是:
function(MyProjTestSetup)
#initiaise stuff
set(EXTERNAL_NAME Gtest)
include(ExternalProject)
set(GTEST_FORCE_SHARED_CRT ON)
set(GTEST_DISABLE_PTHREADS OFF)
if(MINGW)
set(GTEST_DISABLE_PTHREADS ON)
endif()
if(WIN32)
set(WINDOWS_CMAKE_ARGS
-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG:PATH=DebugLibs
-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE:PATH=ReleaseLibs
)
else(WIN32)
set(WINDOWS_CMAKE_ARGS )
endif(WIN32)
set(${EXTERNAL_NAME}_PROJECT ${PROJECT_NAME}_${EXTERNAL_NAME})
#------------build Gtest----------------------
#---------------------------------------------
ExternalProject_Add(Gtest
SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}
BINARY_DIR ${PROJECT_BINARY_DIR}/${EXTERNAL_NAME}
CMAKE_ARGS
${WINDOWS_CMAKE_ARGS}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_CXX_FLAGS=${MSVC_COMPILER_DEFS}
-Dgtest_force_shared_crt=${GTEST_FORCE_SHARED_CRT}
-Dgtest_disable_pthreads=${GTEST_DISABLE_PTHREADS}
-DBUILD_GTEST=ON
-DBUILD_GMOCK=OFF
PREFIX "${CMAKE_CURRENT_BINARY_DIR}"
# Disable install step
INSTALL_COMMAND ""
UPDATE_DISCONNECTED 1
)
# -----------Specify include dir--------------
#---------------------------------------------
set(${EXTERNAL_NAME}_INCLUDE_DIRS
${CMAKE_CURRENT_LIST_DIR}/tests/externals/UnitTests/externals/GoogleTest/googletest/include
)
include_directories(${${EXTERNAL_NAME}_INCLUDE_DIRS})
# ---------Specify link libraries-------------
#---------------------------------------------
set(${EXTERNAL_NAME}_LIBRARIES
${PROJECT_BINARY_DIR}
)
endfunction()
这给出了错误:
NMAKE:-1: error: U1073: don't know how to make '\gtest.lib'
我做错了什么?