Skip to content

Commit

Permalink
Merge 3f8715c into 67131ff
Browse files Browse the repository at this point in the history
  • Loading branch information
kengoide committed Feb 12, 2022
2 parents 67131ff + 3f8715c commit d87641c
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# create solution folder
if(BUILD_GTEST)
set_target_properties(gtest PROPERTIES FOLDER GoogleTest)
set_target_properties(gtest_main PROPERTIES FOLDER GoogleTest)
set_target_properties(gmock PROPERTIES FOLDER GoogleTest)
endif()
set_target_properties(tests1 PROPERTIES FOLDER Tests)

Expand Down
8 changes: 4 additions & 4 deletions tests/googletest.targets
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
<GoogleTestLibInstallDir Condition="'$(Platform)' == 'x64'">$(GoogleTestInstallDir)lib64</GoogleTestLibInstallDir>
<LibraryPath>$(GoogleTestLibInstallDir);$(LibraryPath)</LibraryPath>
<GTestLibName>gtest.lib</GTestLibName>
<GTestMainLibName>gtest_main.lib</GTestMainLibName>
<GTestLibPath>$(GoogleTestLibInstallDir)\$(GTestLibName)</GTestLibPath>
<GTestMainLibPath>$(GoogleTestLibInstallDir)\$(GTestMainLibName)</GTestMainLibPath>
<GMockLibName>gmock.lib</GMockLibName>
<GMockLibPath>$(GoogleTestLibInstallDir)\$(GMockLibName)</GMockLibPath>
</PropertyGroup>
<ItemDefinitionGroup Label="GoogleTest.Requirements">
<ClCompile>
Expand All @@ -20,7 +20,7 @@
<ItemDefinitionGroup Label="GoogleTest.Libs">
<Link>
<AdditionalDependencies>$(GTestLibName);%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>$(GTestMainLibName);%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>$(GMockLibName);%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<Target Name="MakeGoogleTestBuildDir" Condition="!Exists('$(GoogleTestBuildDir)')">
Expand All @@ -29,7 +29,7 @@
<Target Name="MakeGoogleTestInstallDir" Condition="!Exists('$(GoogleTestInstallDir)')">
<MakeDir Directories="$(GoogleTestInstallDir)" />
</Target>
<Target Name="BuildGoogleTest" DependsOnTargets="MakeGoogleTestBuildDir;MakeGoogleTestInstallDir" BeforeTargets="ClCompile" Condition="!Exists('$(GTestLibPath)') Or !Exists('$(GTestMainLibPath)')">
<Target Name="BuildGoogleTest" DependsOnTargets="MakeGoogleTestBuildDir;MakeGoogleTestInstallDir" BeforeTargets="ClCompile" Condition="!Exists('$(GTestLibPath)') Or !Exists('$(GMockLibPath)')">
<PropertyGroup>
<VsVersion>$([System.Text.RegularExpressions.Regex]::Replace('$(VisualStudioVersion)', '^(\d+).*', '$1'))</VsVersion>
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions tests/unittests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ endif ()
if(BUILD_GTEST)
# Build GoogleTest from source code.
target_link_libraries(${project_name} PRIVATE gtest)
target_link_libraries(${project_name} PRIVATE gtest_main)
target_link_libraries(${project_name} PRIVATE gmock)
else()
# Build without GoogleTest(use system library).
find_package(GTest REQUIRED)
target_link_libraries(${project_name} PRIVATE GTest::GTest)
target_link_libraries(${project_name} PRIVATE GTest::Main)
target_link_libraries(${project_name} PRIVATE GTest::GMock)
endif()

# link libraries
Expand Down
2 changes: 1 addition & 1 deletion tests/unittests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ LIBS= \
-lcomdlg32 \
-L$(GOOGLETEST_INSTALL_DIR)/lib \
-lgtest \
-lgtest_main \
-lgmock \
$(MYLIBS)

exe= $(or $(OUTDIR),.)/tests1.exe
Expand Down
6 changes: 4 additions & 2 deletions tests/unittests/code-main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
distribution.
*/
#include <gtest/gtest.h>
#include <gmock/gmock.h>

#ifndef NOMINMAX
#define NOMINMAX
Expand Down Expand Up @@ -106,8 +107,9 @@ int main(int argc, char **argv) {
// コマンドラインに -PROF 指定がある場合、wWinMainを起動して終了する。
InvokeWinMainIfNeeded(::GetCommandLineW());

// WinMainを起動しない場合、標準のgtest_main同様の処理を実行する
// WinMainを起動しない場合、標準のgmock_main同様の処理を実行する。
// InitGoogleMock は Google Test の初期化も行うため、InitGoogleTest を別に呼ぶ必要はない。
printf("Running main() from %s\n", __FILE__);
testing::InitGoogleTest(&argc, argv);
testing::InitGoogleMock(&argc, argv);
return RUN_ALL_TESTS();
}

0 comments on commit d87641c

Please sign in to comment.