Skip to content

Commit 596e1b4

Browse files
committed
build(cmake): fix target config error
1 parent f7536b8 commit 596e1b4

File tree

2 files changed

+26
-30
lines changed

2 files changed

+26
-30
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ include(cmake/Utils.cmake)
55
#
66
# Project details
77
#
8-
project(stdsharp VERSION 0.2.7.3 LANGUAGES CXX)
8+
project(stdsharp VERSION 0.2.7.4 LANGUAGES CXX)
99

1010
config_lib(${PROJECT_NAME} INTERFACE STD 23)
1111

cmake/Utils.cmake

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ function(config_lib lib_name lib_type)
6464
)
6565

6666
if(NOT DEFINED ARG_VER)
67-
set(ARG_VER ${CMAKE_PROJECT_VERSION})
67+
set(ARG_VER "${CMAKE_PROJECT_VERSION}")
6868
endif ()
6969

70-
set_target_properties(${lib_name} PROPERTIES VERSION ${ARG_VER})
70+
set_target_properties(${lib_name} PROPERTIES VERSION "${ARG_VER}")
7171
endfunction()
7272

7373
#
@@ -79,7 +79,7 @@ function(config_exe exe_name)
7979
list(JOIN ARG_EXE_SRC "\n " exe_src_str)
8080
verbose_message("Found the following executable source files:\n ${exe_src_str}")
8181

82-
add_executable(${exe_name} ${ARG_EXE_SRC})
82+
add_executable(${exe_name} "${ARG_EXE_SRC}")
8383

8484
if(NOT DEFINED ARG_VER)
8585
set(ARG_VER ${CMAKE_PROJECT_VERSION})
@@ -121,16 +121,16 @@ function(target_install target)
121121
install(
122122
TARGETS ${target}
123123
EXPORT ${target}Targets
124-
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/${target}
124+
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/${target}"
125125
COMPONENT "${target}_Runtime"
126126
NAMELINK_COMPONENT "${target}_Development"
127-
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/${target}
127+
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}/${target}"
128128
COMPONENT "${target}_Development"
129-
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}/${target}
129+
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}/${target}"
130130
COMPONENT "${target}_Runtime"
131-
BUNDLE DESTINATION ${CMAKE_INSTALL_BINDIR}/${target}
131+
BUNDLE DESTINATION "${CMAKE_INSTALL_BINDIR}/${target}"
132132
COMPONENT "${target}_Runtime"
133-
PUBLIC_HEADER DESTINATION ${ARG_INC_DST} COMPONENT "${target}_Development"
133+
PUBLIC_HEADER DESTINATION "${ARG_INC_DST}" COMPONENT "${target}_Development"
134134
INCLUDES DESTINATION "${ARG_INC_DST}"
135135
)
136136

@@ -139,13 +139,13 @@ function(target_install target)
139139
endif()
140140

141141
set(${target}_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/${target}-${ARG_VER}")
142-
set(${target}_INSTALL_CMAKEDIR ${${target}_INSTALL_CMAKEDIR} PARENT_SCOPE)
142+
set(${target}_INSTALL_CMAKEDIR "${${target}_INSTALL_CMAKEDIR}" PARENT_SCOPE)
143143

144144
verbose_message("CMake files install directory: ${${target}_INSTALL_CMAKEDIR}")
145145

146146
install(
147147
EXPORT ${target}Targets
148-
DESTINATION ${${target}_INSTALL_CMAKEDIR}
148+
DESTINATION "${${target}_INSTALL_CMAKEDIR}"
149149
NAMESPACE ${ARG_NAMESPACE}
150150
COMPONENT "${target}_Development"
151151
)
@@ -159,41 +159,37 @@ function(target_install target)
159159

160160
write_basic_package_version_file(
161161
"${version_config}"
162-
VERSION ${ARG_VER}
163-
COMPATIBILITY ${ARG_COMPATIBILITY} ${wbpvf_extra_args}
162+
VERSION "${ARG_VER}"
163+
COMPATIBILITY ${ARG_COMPATIBILITY}
164+
${wbpvf_extra_args}
164165
)
165166

166167
if(ARG_CONFIG_FILE)
167168
configure_file("${ARG_CONFIG_FILE}" "${target_config}" @ONLY)
168169
else()
169-
file(
170-
CONFIGURE OUTPUT "${target_config}"
171-
CONTENT "
172-
include(CMakeFindDependencyMacro)
173-
174-
string(REGEX MATCHALL \"[^;]+\" SEPARATE_DEPENDENCIES \"@ARG_DEPENDENCIES@\")
175-
176-
foreach(dependency ${SEPARATE_DEPENDENCIES})
177-
string(REPLACE \" \" \";\" args \"${dependency}\")
178-
find_dependency(${args})
179-
endforeach()
180-
181-
include(\"${CMAKE_CURRENT_LIST_DIR}/@[email protected]\")
182-
"
170+
file(CONFIGURE
171+
OUTPUT "${target_config}"
172+
CONTENT "include(CMakeFindDependencyMacro)
173+
foreach(dependency ${ARG_DEPENDENCIES})
174+
find_dependency(\"$\{dependency}\")
175+
endforeach()
176+
include(\"$\{CMAKE_CURRENT_LIST_DIR}/${target}Targets.cmake\")"
177+
@ONLY
178+
ESCAPE_QUOTES
183179
)
184180
endif()
185181

186182
install(
187183
FILES "${version_config}" "${target_config}"
188-
DESTINATION ${${target}_INSTALL_CMAKEDIR}
184+
DESTINATION "${${target}_INSTALL_CMAKEDIR}"
189185
COMPONENT "${target}_Development"
190186
)
191187

192188
get_target_property(target_included ${target} INTERFACE_INCLUDE_DIRECTORIES)
193189

194190
install(
195-
DIRECTORY ${target_included}
196-
DESTINATION ${ARG_INC_DST}
191+
DIRECTORY "${target_included}"
192+
DESTINATION "${ARG_INC_DST}"
197193
COMPONENT "${target}_Development"
198194
)
199195
endfunction()

0 commit comments

Comments
 (0)