Skip to content

Commit 7954bea

Browse files
this install with PROJECT_VERSION_SUFFIX (#20)
* this install with PROJECT_VERSION_SUFFIX correct my fault if expression * use option DISABLE_VERSION_SUFFIX YES instead of NO_VERSION_SUFFIX flag * revert the to version without EXPORT_HEADER * Simplify condition Co-authored-by: Lars Melchior <TheLartians@users.noreply.github.com>
1 parent 16b9cd5 commit 7954bea

2 files changed

Lines changed: 19 additions & 13 deletions

File tree

CMakeLists.txt

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,38 @@ function(packageProject)
88
include(GNUInstallDirs)
99

1010
cmake_parse_arguments(
11-
PROJECT "NO_VERSION_SUFFIX"
12-
"NAME;VERSION;INCLUDE_DIR;INCLUDE_DESTINATION;BINARY_DIR;COMPATIBILITY;VERSION_HEADER;NAMESPACE"
13-
"DEPENDENCIES" ${ARGN}
11+
PROJECT
12+
""
13+
"NAME;VERSION;INCLUDE_DIR;INCLUDE_DESTINATION;BINARY_DIR;COMPATIBILITY;VERSION_HEADER;NAMESPACE;DISABLE_VERSION_SUFFIX"
14+
"DEPENDENCIES"
15+
${ARGN}
1416
)
1517

16-
if(DEFINED PROJECT_NO_VERSION_SUFFIX)
18+
# optional feature: TRUE or FALSE or UNDEFINED! These variables will then hold the respective
19+
# value from the argument list or be undefined if the associated one_value_keyword could not be
20+
# found.
21+
if(PROJECT_DISABLE_VERSION_SUFFIX)
1722
unset(PROJECT_VERSION_SUFFIX)
1823
else()
1924
set(PROJECT_VERSION_SUFFIX -${PROJECT_VERSION})
2025
endif()
2126

22-
# handle default arguments
27+
# handle default arguments:
2328
if(NOT DEFINED PROJECT_COMPATIBILITY)
2429
set(PROJECT_COMPATIBILITY AnyNewerVersion)
2530
endif()
2631

27-
# we wanto to automatically add :: to our namespace, so only append if a namespace was given in
28-
# the first place we also provide an alias to ensure that local and installed versions have the
29-
# same name
32+
# we want to automatically add :: to our namespace, so only append if a namespace was given in the
33+
# first place we also provide an alias to ensure that local and installed versions have the same
34+
# name
3035
if(DEFINED PROJECT_NAMESPACE)
3136
set(PROJECT_NAMESPACE ${PROJECT_NAMESPACE}::)
3237
add_library(${PROJECT_NAMESPACE}${PROJECT_NAME} ALIAS ${PROJECT_NAME})
3338
endif()
3439

3540
if(DEFINED PROJECT_VERSION_HEADER)
3641
set(PROJECT_VERSION_INCLUDE_DIR ${PROJECT_BINARY_DIR}/PackageProjectInclude)
42+
3743
string(TOUPPER ${PROJECT_NAME} UPPERCASE_PROJECT_NAME)
3844
configure_file(
3945
${PACKAGE_PROJECT_ROOT_PATH}/version.h.in

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ See [here](https://github.com/TheLartians/ModernCppStarter/blob/master/CMakeList
1616
CPMAddPackage(
1717
NAME PackageProject.cmake
1818
GITHUB_REPOSITORY TheLartians/PackageProject.cmake
19-
VERSION 1.4.1
19+
VERSION 1.5.1
2020
)
2121
2222
packageProject(
@@ -33,15 +33,15 @@ packageProject(
3333
# semicolon separated list of the project's dependencies
3434
DEPENDENCIES "fmt 7.1.3;cxxopts 2.2.0"
3535
# (optional) create a header containing the version info
36-
# note that the path should be lowercase
36+
# Note: that the path to headers should be lowercase
3737
VERSION_HEADER "${PROJECT_NAME}/version.h"
38-
# (optional) install your library with a namespace (do NOT add extra '::')
38+
# (optional) install your library with a namespace (Note: do NOT add extra '::')
3939
NAMESPACE ${PROJECT_NAMESPACE}
4040
# (optional) define the project's version compatibility, defaults to `AnyNewerVersion`
4141
# supported values: `AnyNewerVersion|SameMajorVersion|SameMinorVersion|ExactVersion`
4242
COMPATIBILITY AnyNewerVersion
43-
# (optional) flag to disable the versioning of install destinations
44-
NO_VERSION_SUFFIX
43+
# (optional) option to disable the versioning of install destinations
44+
DISABLE_VERSION_SUFFIX YES
4545
)
4646
```
4747

0 commit comments

Comments
 (0)