Index: openmp/runtime/cmake/LibompMicroTests.cmake =================================================================== --- openmp/runtime/cmake/LibompMicroTests.cmake +++ openmp/runtime/cmake/LibompMicroTests.cmake @@ -40,7 +40,7 @@ # get library location if(WIN32) get_target_property(LIBOMP_OUTPUT_DIRECTORY omp RUNTIME_OUTPUT_DIRECTORY) - get_target_property(LIBOMPIMP_OUTPUT_DIRECTORY ${LIBOMP_IMP_LIB_TARGET} ARCHIVE_OUTPUT_DIRECTORY) + get_target_property(LIBOMPIMP_OUTPUT_DIRECTORY ompimp ARCHIVE_OUTPUT_DIRECTORY) if(NOT LIBOMPIMP_OUTPUT_DIRECTORY) set(LIBOMPIMP_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) endif() Index: openmp/runtime/src/CMakeLists.txt =================================================================== --- openmp/runtime/src/CMakeLists.txt +++ openmp/runtime/src/CMakeLists.txt @@ -250,10 +250,6 @@ set_source_files_properties(thirdparty/ittnotify/ittnotify_static.cpp PROPERTIES COMPILE_DEFINITIONS "UNICODE") # Create Windows import library - # the import library is "re-linked" to include kmp_import.cpp which prevents - # linking of both Visual Studio OpenMP and newly built OpenMP - set_source_files_properties(kmp_import.cpp PROPERTIES COMPILE_FLAGS "${LIBOMP_CONFIGURED_CXXFLAGS}") - # On debug LIBOMP_IMP_LIB_FILE should be LIBOMP_IMP_LIB_FILE_DBG = ${LIBOMP_DEFAULT_LIB_NAME_DBG}${CMAKE_STATIC_LIBRARY_SUFFIX} # ${LIBOMP_DEFAULT_LIB_NAME}d${CMAKE_STATIC_LIBRARY_SUFFIX} # and the ARCHIVE_OUTPUT_NAME of ompdbg should be ${LIBOMP_DEFAULT_LIB_NAME_DBG}${LIBOMP_LIBRARY_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX} @@ -276,36 +272,35 @@ ARCHIVE_OUTPUT_NAME ${LIBOMP_GENERATED_IMP_LIB_FILENAME} ) - if(MSVC) - # Get generated import library from creating omp - get_target_property(LIBOMP_IMPORT_LIB_DIRECTORY omp ARCHIVE_OUTPUT_DIRECTORY) - if(LIBOMP_IMPORT_LIB_DIRECTORY) - set(LIBOMP_GENERATED_IMP_LIB ${LIBOMP_IMPORT_LIB_DIRECTORY}/${LIBOMP_GENERATED_IMP_LIB_FILENAME}) - else() - set(LIBOMP_GENERATED_IMP_LIB ${CMAKE_CURRENT_BINARY_DIR}/${LIBOMP_GENERATED_IMP_LIB_FILENAME}) - endif() - set_source_files_properties(${LIBOMP_GENERATED_IMP_LIB} PROPERTIES GENERATED TRUE EXTERNAL_OBJECT TRUE) - # Create new import library that is just the previously created one + kmp_import.cpp - add_library(ompimp STATIC ${LIBOMP_GENERATED_IMP_LIB} kmp_import.cpp) - set_target_properties(ompimp PROPERTIES - PREFIX "" SUFFIX "" OUTPUT_NAME "${LIBOMP_IMP_LIB_FILE}" - LINKER_LANGUAGE C - ) - add_dependencies(ompimp omp) # ensure generated import library is created first - set(LIBOMP_IMP_LIB_TARGET ompimp) - else() - set(LIBOMP_IMP_LIB_TARGET omp) - endif() - - # Create def file to designate exported functions + # Create def files to designate exported functions libomp_get_gdflags(LIBOMP_GDFLAGS) # generate-def.pl flags (Windows only) libomp_string_to_list("${LIBOMP_GDFLAGS}" LIBOMP_GDFLAGS) + set(LIBOMP_GENERATED_DEF_FILE ${LIBOMP_LIB_NAME}.def) + set(LIBOMPIMP_GENERATED_DEF_FILE_IMP ${LIBOMP_LIB_NAME}.imp.def) add_custom_command( OUTPUT ${LIBOMP_LIB_NAME}.def - COMMAND ${PERL_EXECUTABLE} ${LIBOMP_TOOLS_DIR}/generate-def.pl ${LIBOMP_GDFLAGS} - -o ${LIBOMP_LIB_NAME}.def ${CMAKE_CURRENT_SOURCE_DIR}/dllexports + # one with ordinals to use for building the runtime dll to maintain backwads compatible exports order + COMMAND ${PERL_EXECUTABLE} ${LIBOMP_TOOLS_DIR}/generate-def.pl ${LIBOMP_GDFLAGS} -D NAME=${LIBOMP_LIB_FILE} + -o ${LIBOMP_GENERATED_DEF_FILE} ${CMAKE_CURRENT_SOURCE_DIR}/dllexports + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/dllexports ${LIBOMP_TOOLS_DIR}/generate-def.pl + # one without ordinals to use for building the import library to remove ordinal dependency going forward + COMMAND ${PERL_EXECUTABLE} ${LIBOMP_TOOLS_DIR}/generate-def.pl ${LIBOMP_GDFLAGS} -D NAME=${LIBOMP_LIB_FILE} -D NOORDINALS + -o ${LIBOMPIMP_GENERATED_DEF_FILE_IMP} ${CMAKE_CURRENT_SOURCE_DIR}/dllexports DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/dllexports ${LIBOMP_TOOLS_DIR}/generate-def.pl ) + + # Regenerate the import library to import by name, not ordinal + add_library(ompimp STATIC ${LIBOMP_SOURCE_FILES}) + set_target_properties(ompimp PROPERTIES + PREFIX "" SUFFIX "" OUTPUT_NAME "${LIBOMP_IMP_LIB_FILE}" + LINKER_LANGUAGE C + ) + set_target_properties(ompimp PROPERTIES STATIC_LIBRARY_OPTIONS + "${CMAKE_LINK_DEF_FILE_FLAG}${CMAKE_CURRENT_BINARY_DIR}/${LIBOMPIMP_GENERATED_DEF_FILE_IMP}" + ) + add_dependencies(ompimp libomp-needed-headers) + + endif() # Building the Fortran module files @@ -362,7 +357,7 @@ # We want to install headers in ${DESTDIR}/${CMAKE_INSTALL_FULL_INCLUDEDIR} if(WIN32) install(TARGETS omp RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") - install(TARGETS ${LIBOMP_IMP_LIB_TARGET} ARCHIVE DESTINATION "${OPENMP_INSTALL_LIBDIR}") + install(TARGETS ompimp ARCHIVE DESTINATION "${OPENMP_INSTALL_LIBDIR}") # Create aliases (regular copies) of the library for backwards compatibility set(LIBOMP_ALIASES "libiomp5md") foreach(alias IN LISTS LIBOMP_ALIASES) Index: openmp/runtime/tools/generate-def.pl =================================================================== --- openmp/runtime/tools/generate-def.pl +++ openmp/runtime/tools/generate-def.pl @@ -128,12 +128,16 @@ }; # sub process -sub generate_output(\%$) { +sub generate_output(\%$\%) { - my ( $entries, $output ) = @_; + my ( $entries, $output, $defs ) = @_; + my $lib = %$defs {'NAME'}; my $bulk; - $bulk = "EXPORTS\n"; + if (defined($lib)) { + $bulk = sprintf("NAME %s\n", $lib); + } + $bulk .= sprintf("EXPORTS\n"); foreach my $entry ( sort( keys( %$entries ) ) ) { if ( not $entries->{ $entry }->{ obsolete } ) { $bulk .= sprintf( " %-40s ", $entry ); @@ -142,7 +146,9 @@ if ( $ordinal eq "DATA" ) { $bulk .= "DATA"; } else { - $bulk .= "\@" . $ordinal; + if (not %$defs {'NOORDINALS'}) { + $bulk .= "\@" . $ordinal; + } }; # if }; # if $bulk .= "\n"; @@ -193,7 +199,7 @@ my %data = parse_input( $input, %defs ); %data = process( %data ); -generate_output( %data, $output ); +generate_output( %data, $output, %defs ); exit( 0 ); __END__