Skip to content

Commit 45e3aa0

Browse files
committed
add PACKAGE_VERSION
1 parent d62438b commit 45e3aa0

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@ set (CMAKE_CXX_STANDARD 11)
44
set (CMAKE_CXX_STANDARD_REQUIRED true)
55

66

7+
if (NOT DEFINED PACKAGE_VERSION)
8+
message ("-- WARNING: Package version is not defined, set as 0.0.0")
9+
set (PACKAGE_VERSION "0.0.0")
10+
endif ()
11+
12+
message ("-- Package version: ${PACKAGE_VERSION}")
13+
14+
project ("CMake Project"
15+
VERSION ${PACKAGE_VERSION}
16+
DESCRIPTION "C/C++ 项目的 CMake 模板。"
17+
)
18+
19+
720
# configure unit test
821
option (WITH_GTEST "Enable unit tests by GoogleTest" OFF)
922

conanfile.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
class ExampleRecipe(ConanFile):
66
name = "cmake-project"
7+
version = "1.1.1"
78
description = "C/C++ 项目的 CMake 模板。"
89
languages = "C++"
910
author = "DavidingPlus"
@@ -29,5 +30,6 @@ def layout(self):
2930
def generate(self):
3031
tc = CMakeToolchain(self)
3132
tc.presets_prefix = "cmake-project"
33+
tc.cache_variables["PACKAGE_VERSION"] = self.version
3234
tc.cache_variables["with_gtest"] = self.options.with_gtest
3335
tc.generate()

0 commit comments

Comments
 (0)