@@ -182,8 +182,7 @@ endfunction()
182
182
183
183
function (add_delay_importlibs MODULE )
184
184
foreach (LIB ${ARGN} )
185
- target_link_libraries (${MODULE} ${CMAKE_BINARY_DIR} /importlibs/lib${LIB}_delayed.a )
186
- add_dependencies (${MODULE} lib${LIB}_delayed )
185
+ target_link_libraries (${MODULE} lib${LIB}_delayed )
187
186
endforeach ()
188
187
target_link_libraries (${MODULE} delayimp )
189
188
endfunction ()
@@ -192,50 +191,32 @@ if(NOT ARCH MATCHES i386)
192
191
set (DECO_OPTION "-@" )
193
192
endif ()
194
193
194
+ # Cute little hack to produce import libs
195
+ set (CMAKE_IMPLIB_CREATE_STATIC_LIBRARY "${CMAKE_DLLTOOL} --def <OBJECTS> --kill-at --output-lib=<TARGET>" )
196
+ set (CMAKE_IMPLIB_DELAYED_CREATE_STATIC_LIBRARY "${CMAKE_DLLTOOL} --def <OBJECTS> --kill-at --output-delaylib=<TARGET>" )
195
197
function (add_importlib_target _exports_file _implib_name )
196
-
197
198
get_filename_component (_name ${_exports_file} NAME_WE )
198
199
get_filename_component (_extension ${_exports_file} EXT )
199
200
200
201
if (${_extension} STREQUAL ".spec" )
201
202
202
- # Normal importlib creation
203
+ # generate .def
203
204
add_custom_command (
204
- OUTPUT ${CMAKE_BINARY_DIR} /importlibs/lib ${_name}.a
205
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR} / ${_name}_implib.def
205
206
COMMAND native-spec2def -n=${_implib_name} -a=${ARCH2} -d=${CMAKE_CURRENT_BINARY_DIR}/${_name}_implib.def ${CMAKE_CURRENT_SOURCE_DIR} /${_exports_file}
206
- COMMAND ${CMAKE_DLLTOOL} --def ${CMAKE_CURRENT_BINARY_DIR} /${_name}_implib.def --kill-at --output-lib=${CMAKE_BINARY_DIR}/importlibs/lib${_name}.a
207
207
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR} /${_exports_file} native-spec2def )
208
-
209
- # Delayed importlib creation
210
- add_custom_command (
211
- OUTPUT ${CMAKE_BINARY_DIR} /importlibs/lib${_name}_delayed.a
212
- COMMAND native-spec2def -n=${_implib_name} -a=${ARCH2} -d=${CMAKE_CURRENT_BINARY_DIR}/${_name}_delayed_implib.def ${CMAKE_CURRENT_SOURCE_DIR} /${_exports_file}
213
- COMMAND ${CMAKE_DLLTOOL} --def ${CMAKE_CURRENT_BINARY_DIR} /${_name}_delayed_implib.def --kill-at --output-delaylib ${CMAKE_BINARY_DIR} /importlibs/lib${_name}_delayed.a
214
- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR} /${_exports_file} native-spec2def )
215
-
216
- elseif (${_extension} STREQUAL ".def" )
217
- message ("Use of def files for import libs is deprecated: ${_exports_file} " )
218
- add_custom_command (
219
- OUTPUT ${CMAKE_BINARY_DIR} /importlibs/lib${_name}.a
220
- COMMAND ${CMAKE_DLLTOOL} --def ${CMAKE_CURRENT_SOURCE_DIR} /${_exports_file} --kill-at --output-lib=${CMAKE_BINARY_DIR}/importlibs/lib${_name}.a
221
- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR} /${_exports_file} )
222
- add_custom_command (
223
- OUTPUT ${CMAKE_BINARY_DIR} /importlibs/lib${_name}_delayed.a
224
- COMMAND ${CMAKE_DLLTOOL} --def ${CMAKE_CURRENT_SOURCE_DIR} /${_exports_file} --kill-at --output-delaylib ${CMAKE_BINARY_DIR} /importlibs/lib${_name}_delayed.a
225
- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR} /${_exports_file} )
208
+ set_source_files_properties (${CMAKE_CURRENT_BINARY_DIR} /${_name}_implib.def PROPERTIES EXTERNAL_OBJECT TRUE )
209
+
210
+ #create normal importlib
211
+ add_library (lib${_name} STATIC EXCLUDE_FROM_ALL ${CMAKE_CURRENT_BINARY_DIR} /${_name}_implib.def )
212
+ set_target_properties (lib${_name} PROPERTIES LINKER_LANGUAGE "IMPLIB" PREFIX "" )
213
+
214
+ #create delayed importlib
215
+ add_library (lib${_name}_delayed STATIC EXCLUDE_FROM_ALL ${CMAKE_CURRENT_BINARY_DIR} /${_name}_implib.def )
216
+ set_target_properties (lib${_name}_delayed PROPERTIES LINKER_LANGUAGE "IMPLIB" PREFIX "" )
226
217
else ()
227
218
message (FATAL_ERROR "Unsupported exports file extension: ${_extension} " )
228
219
endif ()
229
-
230
- # Normal importlib target
231
- add_custom_target (
232
- lib${_name}
233
- DEPENDS ${CMAKE_BINARY_DIR} /importlibs/lib${_name}.a )
234
- # Delayed importlib target
235
- add_custom_target (
236
- lib${_name}_delayed
237
- DEPENDS ${CMAKE_BINARY_DIR} /importlibs/lib${_name}_delayed.a )
238
-
239
220
endfunction ()
240
221
241
222
function (spec2def _dllname _spec_file )
0 commit comments