@@ -235,10 +235,6 @@ add_dependencies(omp libomp-needed-headers)
235
235
# Windows specific build rules
236
236
if (WIN32 )
237
237
configure_file (libomp.rc.var libomp.rc @ONLY )
238
-
239
- # Create .def and .rc file before compiling any sources
240
- add_custom_target (libomp-needed-windows-files DEPENDS ${LIBOMP_LIB_NAME} .def )
241
- add_dependencies (omp libomp-needed-windows-files )
242
238
# z_Windows_NT-586_asm.asm requires definitions to be sent via command line
243
239
# It only needs the architecture macro and OMPT_SUPPORT=0|1
244
240
libomp_append (LIBOMP_MASM_DEFINITIONS "-D_M_IA32" IF_TRUE IA32 )
@@ -272,54 +268,42 @@ if(WIN32)
272
268
ARCHIVE_OUTPUT_NAME ${LIBOMP_GENERATED_IMP_LIB_FILENAME}
273
269
)
274
270
275
- if (MSVC )
276
- set (LIBOMP_IMP_LIB_TARGET ompimp )
277
- else ()
278
- set (LIBOMP_IMP_LIB_TARGET omp )
279
- endif ()
280
-
281
- # Create def files to designate exported functions
282
- libomp_get_gdflags (LIBOMP_GDFLAGS ) # generate-def.pl flags (Windows only)
283
- libomp_string_to_list ("${LIBOMP_GDFLAGS} " LIBOMP_GDFLAGS )
271
+ set (LIBOMP_IMP_LIB_TARGET omp )
284
272
set (LIBOMP_GENERATED_DEF_FILE ${LIBOMP_LIB_NAME} .def )
285
- set (LIBOMPIMP_GENERATED_DEF_FILE_IMP ${LIBOMP_LIB_NAME} .imp.def )
273
+ add_custom_target (libomp-needed-def-file DEPENDS ${LIBOMP_GENERATED_DEF_FILE} )
274
+ add_dependencies (omp libomp-needed-def-file )
275
+
276
+ # Create the main def file with ordinals to use for building the runtime dll to maintain backwards compatible exports order
277
+ libomp_get_gdflags (LIBOMP_GDFLAGS )
278
+ libomp_string_to_list ("${LIBOMP_GDFLAGS} " LIBOMP_GDFLAGS )
286
279
add_custom_command (
287
- OUTPUT ${LIBOMP_LIB_NAME} .def
288
- # one with ordinals to use for building the runtime dll to maintain backwads compatible exports order
280
+ OUTPUT ${LIBOMP_GENERATED_DEF_FILE}
289
281
COMMAND ${PERL_EXECUTABLE} ${LIBOMP_TOOLS_DIR} /generate-def.pl ${LIBOMP_GDFLAGS} -D NAME =${LIBOMP_LIB_FILE}
290
282
-o ${LIBOMP_GENERATED_DEF_FILE} ${CMAKE_CURRENT_SOURCE_DIR} /dllexports
291
283
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR} /dllexports ${LIBOMP_TOOLS_DIR} /generate-def.pl
292
- # one without ordinals to use for building the import library to remove ordinal dependency going forward
293
- COMMAND ${PERL_EXECUTABLE} ${LIBOMP_TOOLS_DIR} /generate-def.pl ${LIBOMP_GDFLAGS} -D NAME =${LIBOMP_LIB_FILE} -D NOORDINALS
294
- -o ${LIBOMPIMP_GENERATED_DEF_FILE_IMP} ${CMAKE_CURRENT_SOURCE_DIR} /dllexports
295
- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR} /dllexports ${LIBOMP_TOOLS_DIR} /generate-def.pl
296
284
)
297
285
298
- if (MSVC )
299
- # Regenerate the import library to import by name, not ordinal.
300
- #
301
- # For mingw, we can't regenerate an import library by passing
302
- # CMAKE_LINK_DEF_FILE_FLAG to the static library archiver; that just
303
- # ends up creating a regular static library that contains the def file.
304
- # For mingw, we would have to call the suitable dlltool for regenerating
305
- # an import library. However, neither GNU nor LLVM based mingw tools
306
- # generate import libraries that actually link by ordinal, so this step
307
- # isn't strictly necessary.
308
- #
309
- # Also, in mingw builds, LIBOMP_GENERATED_IMP_LIB_FILENAME and
310
- # LIBOMP_IMP_LIB_FILE currently end up equal, while they need to differ
311
- # for this second step to work.
312
- add_library (ompimp STATIC ${LIBOMP_SOURCE_FILES} )
313
- set_target_properties (ompimp PROPERTIES
314
- PREFIX "" SUFFIX "" OUTPUT_NAME "${LIBOMP_IMP_LIB_FILE} "
315
- LINKER_LANGUAGE C
316
- )
317
- set_target_properties (ompimp PROPERTIES STATIC_LIBRARY_OPTIONS
318
- "${CMAKE_LINK_DEF_FILE_FLAG}${CMAKE_CURRENT_BINARY_DIR} /${LIBOMPIMP_GENERATED_DEF_FILE_IMP} "
286
+ if (MSVC )
287
+ # For toolchains that generated the import library importing by ordinal, re-generate it to import by name
288
+ set (LIBOMP_IMP_LIB_TARGET ompimp )
289
+ # Create the auxiliary def file without ordinals to use for building the import library to import by name
290
+ set (LIBOMPIMP_GENERATED_DEF_FILE ${LIBOMP_LIB_NAME} .imp.def )
291
+ add_custom_target (libompimp-needed-def-file DEPENDS ${LIBOMPIMP_GENERATED_DEF_FILE} )
292
+ add_custom_command (
293
+ OUTPUT ${LIBOMPIMP_GENERATED_DEF_FILE}
294
+ COMMAND ${PERL_EXECUTABLE} ${LIBOMP_TOOLS_DIR} /generate-def.pl ${LIBOMP_GDFLAGS} -D NAME =${LIBOMP_LIB_FILE} -D NOORDINALS
295
+ -o ${LIBOMPIMP_GENERATED_DEF_FILE} ${CMAKE_CURRENT_SOURCE_DIR} /dllexports
296
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR} /dllexports ${LIBOMP_TOOLS_DIR} /generate-def.pl
319
297
)
320
- add_dependencies (ompimp libomp-needed-headers )
298
+ # while this is merely generating an import library off the one generated with the runtime dll,
299
+ # kmp_global.cpp will satisfy the librarian's apparent ask to see the actual exported DATA items
300
+ set_source_files_properties (${LIBOMP_GENERATED_IMP_LIB_FILENAME} PROPERTIES GENERATED TRUE EXTERNAL_OBJECT TRUE )
301
+ add_library (${LIBOMP_IMP_LIB_TARGET} STATIC ${LIBOMP_GENERATED_IMP_LIB_FILENAME} kmp_global.cpp )
302
+ set_target_properties (${LIBOMP_IMP_LIB_TARGET} PROPERTIES
303
+ PREFIX "" SUFFIX "" OUTPUT_NAME "${LIBOMP_IMP_LIB_FILE} " LINKER_LANGUAGE C
304
+ STATIC_LIBRARY_OPTIONS "${CMAKE_LINK_DEF_FILE_FLAG}${CMAKE_CURRENT_BINARY_DIR} /${LIBOMPIMP_GENERATED_DEF_FILE} " )
305
+ add_dependencies (${LIBOMP_IMP_LIB_TARGET} omp libompimp-needed-def-file )
321
306
endif ()
322
-
323
307
endif ()
324
308
325
309
# Building the Fortran module files
0 commit comments