1
1
# Keep this in sync with llvm/cmake/CMakeLists.txt!
2
2
3
+ include (FindPrefixFromConfig)
4
+
3
5
set (LLVM_INSTALL_PACKAGE_DIR "lib${LLVM_LIBDIR_SUFFIX} /cmake/llvm" )
4
6
set (POLLY_INSTALL_PACKAGE_DIR "lib${LLVM_LIBDIR_SUFFIX} /cmake/polly" )
5
7
if (CMAKE_CONFIGURATION_TYPES )
@@ -46,6 +48,7 @@ endif()")
46
48
endif ()
47
49
48
50
# Generate PollyConfig.cmake for the build tree.
51
+ set (POLLY_CONFIG_CODE "" )
49
52
set (POLLY_CONFIG_CMAKE_DIR "${CMAKE_BINARY_DIR} /${POLLY_INSTALL_PACKAGE_DIR} " )
50
53
set (POLLY_CONFIG_INCLUDE_DIRS
51
54
${POLLY_SOURCE_DIR} /include
@@ -79,24 +82,31 @@ file(GENERATE
79
82
80
83
# Generate PollyConfig.cmake for the install tree.
81
84
unset (POLLY_EXPORTS)
82
- set ( POLLY_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX } " )
83
- set (POLLY_CONFIG_LLVM_CMAKE_DIR "${LLVM_BINARY_DIR } /${LLVM_INSTALL_PACKAGE_DIR} " )
84
- set (POLLY_CONFIG_CMAKE_DIR "${POLLY_INSTALL_PREFIX} /${POLLY_INSTALL_PACKAGE_DIR} " )
85
- set (POLLY_CONFIG_LIBRARY_DIRS "${POLLY_INSTALL_PREFIX} /lib${LLVM_LIBDIR_SUFFIX} " )
85
+ find_prefix_from_config(POLLY_CONFIG_CODE POLLY_INSTALL_PREFIX "${POLLY_INSTALL_PACKAGE_DIR } " )
86
+ set (POLLY_CONFIG_LLVM_CMAKE_DIR "\$ {POLLY_INSTALL_PREFIX }/${LLVM_INSTALL_PACKAGE_DIR} " )
87
+ set (POLLY_CONFIG_CMAKE_DIR "\ $ {POLLY_INSTALL_PREFIX}/${POLLY_INSTALL_PACKAGE_DIR} " )
88
+ set (POLLY_CONFIG_LIBRARY_DIRS "\ $ {POLLY_INSTALL_PREFIX}/lib${LLVM_LIBDIR_SUFFIX} " )
86
89
if (POLLY_BUNDLED_ISL)
87
90
set (POLLY_CONFIG_INCLUDE_DIRS
88
- "${POLLY_INSTALL_PREFIX} /include"
89
- "${POLLY_INSTALL_PREFIX} /include/polly"
91
+ "\ $ {POLLY_INSTALL_PREFIX}/include"
92
+ "\ $ {POLLY_INSTALL_PREFIX}/include/polly"
90
93
)
91
94
else ()
92
95
set (POLLY_CONFIG_INCLUDE_DIRS
93
- "${POLLY_INSTALL_PREFIX} /include"
96
+ "\ $ {POLLY_INSTALL_PREFIX}/include"
94
97
${ISL_INCLUDE_DIRS}
95
98
)
96
99
endif ()
97
100
98
- # set locations for imported targets. The path is constructed to be relative to
99
- # the config file
101
+ # Set locations for imported targets. The path is constructed to be relative to
102
+ # the config file.
103
+ #
104
+ # Include the config code of PollyConfig.cmake to define POLLY_INSTALL_PREFIX
105
+ # anew in case the export file is included alone rather than from that file.
106
+ set (POLLY_EXPORTS
107
+ "${POLLY_CONFIG_CODE}
108
+
109
+ " )
100
110
foreach (tgt IN LISTS POLLY_CONFIG_EXPORTED_TARGETS)
101
111
get_target_property (tgt_type ${tgt} TYPE )
102
112
if (tgt_type STREQUAL "EXECUTABLE" )
@@ -105,13 +115,12 @@ foreach(tgt IN LISTS POLLY_CONFIG_EXPORTED_TARGETS)
105
115
set (tgt_prefix "lib/" )
106
116
endif ()
107
117
108
- set (tgt_path "${CMAKE_INSTALL_PREFIX} /${tgt_prefix} $<TARGET_FILE_NAME:${tgt} >" )
109
- file (RELATIVE_PATH tgt_path ${POLLY_CONFIG_CMAKE_DIR} ${tgt_path} )
118
+ set (tgt_path "\$ {POLLY_INSTALL_PREFIX}/${tgt_prefix} $<TARGET_FILE_NAME:${tgt} >" )
110
119
111
120
if (NOT tgt_type STREQUAL "INTERFACE_LIBRARY" )
112
121
set (POLLY_EXPORTS
113
122
"set_target_properties(${tgt} PROPERTIES
114
- IMPORTED_LOCATION$<$<NOT:$<CONFIG:>>:_$<UPPER_CASE:$<CONFIG>>> \$ {CMAKE_CURRENT_LIST_DIR}/ ${ tgt_path} )
123
+ IMPORTED_LOCATION$<$<NOT:$<CONFIG:>>:_$<UPPER_CASE:$<CONFIG>>> \" ${ tgt_path}\" )
115
124
${POLLY_EXPORTS} " )
116
125
endif ()
117
126
endforeach (tgt)
0 commit comments