Skip to content

Commit b2f1bcf

Browse files
committed
Use EXPORT instead of TARGETS_PROPERTY in install_basic_package_files
1 parent a4a3764 commit b2f1bcf

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ include(InstallBasicPackageFiles)
118118
install_basic_package_files(${PROJECT_NAME}
119119
VERSION ${${PROJECT_NAME}_VERSION}
120120
COMPATIBILITY AnyNewerVersion
121-
TARGETS_PROPERTY ${PROJECT_NAME}_TARGETS
121+
EXPORT ${PROJECT_NAME}
122122
VARS_PREFIX ${PROJECT_NAME}
123123
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
124124
# Add the uninstall target

src/LibTemplateCMake/CMakeLists.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@
22
# The actual file name of the library built is constructed based on conventions
33
# of the native platform, such as lib<LIBRARY_TARGET_NAME>.a,
44
# lib<LIBRARY_TARGET_NAME>.dylib or <LIBRARY_TARGET_NAME>.lib.
5-
set(LIBRARY_TARGET_NAME LibTemplateCMake)
5+
#
6+
# In order to use a library name that is not the same as the `EXPORT` (in the
7+
# `install` command), it is necessary to pass the `FIRST_TARGET` option to
8+
# `install_basic_package_files` in the main CMakeLists.txt file.
9+
# In this case the project name is used for both, therefore it is not necessary.
10+
set(LIBRARY_TARGET_NAME ${PROJECT_NAME})
611

712
# List of CPP (source) library files.
813
set(${LIBRARY_TARGET_NAME}_SRC
@@ -64,5 +69,3 @@ install(TARGETS ${LIBRARY_TARGET_NAME}
6469
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT lib
6570
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT bin
6671
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${LIBRARY_TARGET_NAME}" COMPONENT dev)
67-
68-
set_property(GLOBAL APPEND PROPERTY ${PROJECT_NAME}_TARGETS ${LIBRARY_TARGET_NAME})

0 commit comments

Comments
 (0)