Skip to content

Commit

Permalink
[cmake] Slight fix ups to make robust to the full range of GNUInstall…
Browse files Browse the repository at this point in the history
…Dirs

See https://cmake.org/cmake/help/v3.14/module/GNUInstallDirs.html#result-variables for `CMAKE_INSTALL_FULL_*`

Reviewed By: sebastian-ne

Differential Revision: https://reviews.llvm.org/D130545
  • Loading branch information
Ericson2314 committed Jul 26, 2022
1 parent 0a412b3 commit 28e665f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 10 deletions.
4 changes: 3 additions & 1 deletion clang/tools/clang-linker-wrapper/CMakeLists.txt
@@ -1,3 +1,5 @@
include(GNUInstallDirs)

set(LLVM_LINK_COMPONENTS
${LLVM_TARGETS_TO_BUILD}
BitWriter
Expand Down Expand Up @@ -42,4 +44,4 @@ target_link_libraries(clang-linker-wrapper
${CLANG_LINKER_WRAPPER_LIB_DEPS}
)

install(TARGETS clang-linker-wrapper RUNTIME DESTINATION bin)
install(TARGETS clang-linker-wrapper RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
5 changes: 3 additions & 2 deletions llvm-libgcc/lib/CMakeLists.txt
@@ -1,5 +1,6 @@
include(CheckLibraryExists)
include(GNUInstallDirs)
include(ExtendPath)

string(REPLACE "-Wl,-z,defs" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")

Expand Down Expand Up @@ -41,13 +42,13 @@ target_link_libraries(libgcc_s PRIVATE
c
)

get_filename_component(LLVM_LIBGCC_LIBUNWIND_STATIC_ROOT "${CMAKE_INSTALL_PREFIX}/${LIBUNWIND_INSTALL_LIBRARY_DIR}" ABSOLUTE)
extend_path(LLVM_LIBGCC_LIBUNWIND_STATIC_ROOT "${CMAKE_INSTALL_PREFIX}" "${LIBUNWIND_INSTALL_LIBRARY_DIR}")
#string(REPLACE "${CMAKE_INSTALL_FULL_LIBDIR}/" "" LLVM_LIBGCC_LIBUNWIND_STATIC_ROOT "${LLVM_LIBGCC_LIBUNWIND_STATIC_ROOT}")

install(TARGETS libgcc_s
LIBRARY DESTINATION "${LLVM_LIBGCC_LIBUNWIND_STATIC_ROOT}" COMPONENT unwind
ARCHIVE DESTINATION "${LLVM_LIBGCC_LIBUNWIND_STATIC_ROOT}" COMPONENT unwind
RUNTIME DESTINATION bin COMPONENT unwind)
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT unwind)

get_compiler_rt_install_dir(${LLVM_LIBGCC_TARGET_ARCH} install_dir_builtins)
string(REGEX REPLACE "^lib/" "" install_dir_builtins "${install_dir_builtins}")
Expand Down
1 change: 1 addition & 0 deletions llvm/cmake/modules/CMakeLists.txt
Expand Up @@ -137,6 +137,7 @@ list(REMOVE_DUPLICATES LLVM_CONFIG_LIBRARY_DIRS)

set(LLVM_CONFIG_BINARY_DIR "\${LLVM_INSTALL_PREFIX}")
extend_path(LLVM_CONFIG_CMAKE_DIR "\${LLVM_INSTALL_PREFIX}" "${LLVM_INSTALL_PACKAGE_DIR}")
extend_path(LLVM_CONFIG_TOOLS_BINARY_DIR "\${LLVM_INSTALL_PREFIX}" "${LLVM_TOOLS_INSTALL_DIR}")

# Generate a default location for lit
if (LLVM_INSTALL_UTILS AND LLVM_BUILD_UTILS)
Expand Down
9 changes: 7 additions & 2 deletions openmp/CMakeLists.txt
@@ -1,7 +1,12 @@
cmake_minimum_required(VERSION 3.13.4)

# Add cmake directory to search for custom cmake functions.
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)

# Add path for custom modules
list(INSERT CMAKE_MODULE_PATH 0
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
"${LLVM_COMMON_CMAKE_UTILS}/Modules"
)

# llvm/runtimes/ will set OPENMP_STANDALONE_BUILD.
if (OPENMP_STANDALONE_BUILD OR "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
Expand Down
14 changes: 9 additions & 5 deletions openmp/runtime/src/CMakeLists.txt
Expand Up @@ -8,6 +8,8 @@
#//===----------------------------------------------------------------------===//
#

include(ExtendPath)

# Configure omp.h, kmp_config.h and omp-tools.h if necessary
configure_file(${LIBOMP_INC_DIR}/omp.h.var omp.h @ONLY)
configure_file(kmp_config.h.cmake kmp_config.h @ONLY)
Expand Down Expand Up @@ -347,8 +349,8 @@ endif()
add_dependencies(libomp-micro-tests libomp-test-deps)

# Install rules
# We want to install libomp in DESTDIR/CMAKE_INSTALL_PREFIX/lib
# We want to install headers in DESTDIR/CMAKE_INSTALL_PREFIX/include
# We want to install libomp in ${DESTDIR}/${CMAKE_INSTALL_FULL_LIBDIR}
# We want to install headers in ${DESTDIR}/${CMAKE_INSTALL_FULL_INCLUDEDIR}
if(${OPENMP_STANDALONE_BUILD})
set(LIBOMP_HEADERS_INSTALL_PATH "${CMAKE_INSTALL_INCLUDEDIR}")
else()
Expand All @@ -362,9 +364,10 @@ if(WIN32)
set(LIBOMP_ALIASES "libiomp5md")
foreach(alias IN LISTS LIBOMP_ALIASES)
install(CODE "execute_process(COMMAND \"\${CMAKE_COMMAND}\" -E copy \"${LIBOMP_LIB_FILE}\"
\"${alias}${LIBOMP_LIBRARY_SUFFIX}\" WORKING_DIRECTORY \"\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}\")")
\"${alias}${LIBOMP_LIBRARY_SUFFIX}\" WORKING_DIRECTORY \"${CMAKE_INSTALL_FULL_BINDIR}\")")
extend_path(outdir "${CMAKE_INSTALL_PREFIX}" "${OPENMP_INSTALL_LIBDIR}")
install(CODE "execute_process(COMMAND \"\${CMAKE_COMMAND}\" -E copy \"${LIBOMP_IMP_LIB_FILE}\"
\"${alias}${CMAKE_STATIC_LIBRARY_SUFFIX}\" WORKING_DIRECTORY \"\${CMAKE_INSTALL_PREFIX}/${OPENMP_INSTALL_LIBDIR}\")")
\"${alias}${CMAKE_STATIC_LIBRARY_SUFFIX}\" WORKING_DIRECTORY \"${outdir}\")")
endforeach()
else()

Expand All @@ -374,9 +377,10 @@ else()
# Create aliases (symlinks) of the library for backwards compatibility
set(LIBOMP_ALIASES "libgomp;libiomp5")
foreach(alias IN LISTS LIBOMP_ALIASES)
extend_path(outdir "${CMAKE_INSTALL_PREFIX}" "${OPENMP_INSTALL_LIBDIR}")
install(CODE "execute_process(COMMAND \"\${CMAKE_COMMAND}\" -E create_symlink \"${LIBOMP_LIB_FILE}\"
\"${alias}${LIBOMP_LIBRARY_SUFFIX}\" WORKING_DIRECTORY
\"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${OPENMP_INSTALL_LIBDIR}\")")
\"\$ENV{DESTDIR}\${outdir}\")")
endforeach()
endif()
endif()
Expand Down

0 comments on commit 28e665f

Please sign in to comment.