[Openmp-commits] [openmp] 9f15cac - [OpenMP] Allow building libomp using Microsoft Visual C++ naming scheme
Jonathan Peyton via Openmp-commits
openmp-commits at lists.llvm.org
Thu Nov 11 11:12:13 PST 2021
Author: Bran Hagger
Date: 2021-11-11T13:11:56-06:00
New Revision: 9f15cacc2ecd2eb1dda8ca0b8ae984286fb4135f
URL: https://github.com/llvm/llvm-project/commit/9f15cacc2ecd2eb1dda8ca0b8ae984286fb4135f
DIFF: https://github.com/llvm/llvm-project/commit/9f15cacc2ecd2eb1dda8ca0b8ae984286fb4135f.diff
LOG: [OpenMP] Allow building libomp using Microsoft Visual C++ naming scheme
Differential Revision: https://reviews.llvm.org/D110354
Added:
Modified:
openmp/CMakeLists.txt
openmp/runtime/CMakeLists.txt
openmp/runtime/src/CMakeLists.txt
Removed:
################################################################################
diff --git a/openmp/CMakeLists.txt b/openmp/CMakeLists.txt
index b48c5d4a8e9c5..c164f47681988 100644
--- a/openmp/CMakeLists.txt
+++ b/openmp/CMakeLists.txt
@@ -97,6 +97,7 @@ if (OPENMP_ENABLE_OMPT_TOOLS)
add_subdirectory(tools)
endif()
+option(OPENMP_MSVC_NAME_SCHEME "Build dll with MSVC naming scheme." OFF)
# Build documentation
add_subdirectory(docs)
diff --git a/openmp/runtime/CMakeLists.txt b/openmp/runtime/CMakeLists.txt
index 136cd6018dd39..c9dbcb2ab22c0 100644
--- a/openmp/runtime/CMakeLists.txt
+++ b/openmp/runtime/CMakeLists.txt
@@ -355,6 +355,11 @@ if(${STUBS_LIBRARY})
set(LIBOMP_DEFAULT_LIB_NAME ${LIBOMP_DEFAULT_LIB_NAME}stubs)
endif()
set(LIBOMP_LIB_NAME ${LIBOMP_DEFAULT_LIB_NAME} CACHE STRING "Base OMP library name")
+if (OPENMP_MSVC_NAME_SCHEME)
+ # MSVC_TOOLS_VERSION corresponds to the version of the VC++ toolset.
+ set(MSVC_TOOLS_VERSION 140)
+ set(LIBOMP_LIB_NAME ${LIBOMP_LIB_NAME}${MSVC_TOOLS_VERSION}.${LIBOMP_ARCH})
+endif()
if(${LIBOMP_ENABLE_SHARED})
set(LIBOMP_LIBRARY_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX})
diff --git a/openmp/runtime/src/CMakeLists.txt b/openmp/runtime/src/CMakeLists.txt
index bdb867e352f78..60f97bd3d2ae3 100644
--- a/openmp/runtime/src/CMakeLists.txt
+++ b/openmp/runtime/src/CMakeLists.txt
@@ -158,11 +158,33 @@ else()
set(LIBOMP_LINKER_LANGUAGE CXX)
endif()
-set_target_properties(omp PROPERTIES
- PREFIX "" SUFFIX "" OUTPUT_NAME "${LIBOMP_LIB_FILE}"
- LINK_FLAGS "${LIBOMP_CONFIGURED_LDFLAGS}"
- LINKER_LANGUAGE ${LIBOMP_LINKER_LANGUAGE}
-)
+if(OPENMP_MSVC_NAME_SCHEME)
+ if(uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
+ set(LIBOMP_PDB_NAME ${LIBOMP_DEFAULT_LIB_NAME}${MSVC_TOOLS_VERSION}d.${LIBOMP_ARCH})
+ set(LIBOMP_LIB_FILE ${LIBOMP_PDB_NAME}${LIBOMP_LIBRARY_SUFFIX})
+ else()
+ # ${LIBOMP_LIB_NAME} is ${LIBOMP_DEFAULT_LIB_NAME}${MSVC_TOOLS_VERSION}.${LIBOMP_ARCH}
+ set(LIBOMP_PDB_NAME ${LIBOMP_LIB_NAME})
+ endif()
+
+ # in debug
+ # LIBOMP_LIB_FILE should be LIBOMP_LIB_FILE_DBG = ${LIBOMP_LIB_NAME_DBG}${LIBOMP_LIBRARY_SUFFIX}
+ # = ${LIBOMP_DEFAULT_LIB_NAME}${MSVC_TOOLS_VERSION}d.${LIBOMP_ARCH}${LIBOMP_LIBRARY_SUFFIX}
+ # COMPILE_PDB_NAME/PDB_NAME should be LIBOMP_LIB_NAME_DBG = ${LIBOMP_DEFAULT_LIB_NAME}${MSVC_TOOLS_VERSION}d.${LIBOMP_ARCH}
+ set_target_properties(omp PROPERTIES
+ PREFIX "" SUFFIX "" OUTPUT_NAME "${LIBOMP_LIB_FILE}"
+ PDB_NAME "${LIBOMP_PDB_NAME}"
+ COMPILE_PDB_NAME "${LIBOMP_PDB_NAME}"
+ LINK_FLAGS "${LIBOMP_CONFIGURED_LDFLAGS}"
+ LINKER_LANGUAGE ${LIBOMP_LINKER_LANGUAGE}
+ )
+else()
+ set_target_properties(omp PROPERTIES
+ PREFIX "" SUFFIX "" OUTPUT_NAME "${LIBOMP_LIB_FILE}"
+ LINK_FLAGS "${LIBOMP_CONFIGURED_LDFLAGS}"
+ LINKER_LANGUAGE ${LIBOMP_LINKER_LANGUAGE}
+ )
+endif()
# Get the library's location within the build tree for the unit tester
if(NOT WIN32)
@@ -216,8 +238,23 @@ if(WIN32)
# 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}")
- set(LIBOMP_IMP_LIB_FILE ${LIBOMP_LIB_NAME}${CMAKE_IMPORT_LIBRARY_SUFFIX})
- set(LIBOMP_GENERATED_IMP_LIB_FILENAME ${LIBOMP_LIB_FILE}${CMAKE_STATIC_LIBRARY_SUFFIX})
+
+ # 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}
+
+ if(OPENMP_MSVC_NAME_SCHEME)
+ if(uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
+ set(LIBOMP_IMP_LIB_FILE ${LIBOMP_DEFAULT_LIB_NAME}d${CMAKE_STATIC_LIBRARY_SUFFIX})
+ set(LIBOMP_GENERATED_IMP_LIB_FILENAME ${LIBOMP_DEFAULT_LIB_NAME}d${LIBOMP_LIBRARY_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX})
+ else()
+ set(LIBOMP_IMP_LIB_FILE ${LIBOMP_DEFAULT_LIB_NAME}${CMAKE_IMPORT_LIBRARY_SUFFIX})
+ set(LIBOMP_GENERATED_IMP_LIB_FILENAME ${LIBOMP_DEFAULT_LIB_NAME}${LIBOMP_LIBRARY_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX})
+ endif()
+ else()
+ set(LIBOMP_IMP_LIB_FILE ${LIBOMP_LIB_NAME}${CMAKE_IMPORT_LIBRARY_SUFFIX})
+ set(LIBOMP_GENERATED_IMP_LIB_FILENAME ${LIBOMP_LIB_FILE}${CMAKE_STATIC_LIBRARY_SUFFIX})
+ endif()
set_target_properties(omp PROPERTIES
VERSION ${LIBOMP_VERSION_MAJOR}.${LIBOMP_VERSION_MINOR} # uses /version flag
IMPORT_PREFIX "" IMPORT_SUFFIX "" # control generated import library name when building omp
More information about the Openmp-commits
mailing list