-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from DavidingPlus/feature-liuzx-unit-test
Use Conan To Add GoogleTest For Unit Test
- Loading branch information
Showing
9 changed files
with
80 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
.vscode/ | ||
build/ | ||
CMakeUserPresets.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from conan import ConanFile | ||
from conan.tools.cmake import cmake_layout, CMakeToolchain | ||
|
||
|
||
class ExampleRecipe(ConanFile): | ||
name = "cmake-project" | ||
description = "C/C++ 项目的 CMake 模板。" | ||
languages = "C++" | ||
author = "DavidingPlus" | ||
homepage = "https://github.com/DavidingPlus/cmake-project-template" | ||
|
||
settings = "os", "compiler", "build_type", "arch" | ||
generators = "CMakeDeps" | ||
|
||
def requirements(self): | ||
self.requires("gtest/1.12.1") | ||
|
||
def layout(self): | ||
cmake_layout(self) | ||
|
||
def generate(self): | ||
tc = CMakeToolchain(self) | ||
tc.presets_prefix = "cmake-project" | ||
tc.generate() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
add_executable (TestClassTest main.cpp) | ||
target_link_libraries (TestClassTest cmakeproject) | ||
target_link_libraries (TestClassTest cmake-project) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,11 @@ | ||
message ("-- Checking if GoogleTest is installed ...") | ||
|
||
find_package (GTest REQUIRED) | ||
if (NOT GTest_FOUND) | ||
message (WARNING "-- GoogleTest not installed") | ||
return () | ||
|
||
endif () | ||
|
||
include (GoogleTest) | ||
|
||
|
||
aux_source_directory (${CMAKE_CURRENT_SOURCE_DIR} SRC_GTEST) | ||
add_executable (gtest_testrun EXCLUDE_FROM_ALL ${SRC_GTEST}) | ||
target_link_libraries (gtest_testrun gtest gtest_main cmakeproject) | ||
add_executable (gtest-testrun EXCLUDE_FROM_ALL ${SRC_GTEST}) | ||
target_link_libraries (gtest-testrun gtest::gtest cmake-project) | ||
|
||
add_custom_target (tests) | ||
add_dependencies (tests gtest_testrun) | ||
add_dependencies (tests gtest-testrun) | ||
|
||
|
||
message ("-- Done configuring gtest") |