diff --git a/.github/build-ci/manifests/intel.spack.yaml.j2 b/.github/build-ci/manifests/intel.spack.yaml.j2 index 6f9552c..6625415 100644 --- a/.github/build-ci/manifests/intel.spack.yaml.j2 +++ b/.github/build-ci/manifests/intel.spack.yaml.j2 @@ -4,7 +4,7 @@ spack: packages: access3-share: require: - '@git.{{ ref }}=stable' + '@git.{{ ref }}' all: require: - '%{{ intel_compiler }} target={{ target }}' diff --git a/.github/build-ci/manifests/oneapi.spack.yaml.j2 b/.github/build-ci/manifests/oneapi.spack.yaml.j2 index af5dfea..e6fe871 100644 --- a/.github/build-ci/manifests/oneapi.spack.yaml.j2 +++ b/.github/build-ci/manifests/oneapi.spack.yaml.j2 @@ -1,6 +1,6 @@ spack: specs: - - access3 @git.{{ ref }} configurations={{ all_configurations }} + - access3 @git.{{ ref }}=stable configurations={{ all_configurations }} packages: access3-share: require: diff --git a/CMakeLists.txt b/CMakeLists.txt index b76f41e..cf95f53 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,6 +42,9 @@ include(GNUInstallDirs) include(FortranLib) include(AddPatchedSource) +# Use llvm-ar for IntelLLVM Fortran compiler +include(UseLlvmArchive) + # Common compiler flags and definitions if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fbacktrace -fconvert=big-endian -ffree-line-length-none -ffixed-line-length-none") diff --git a/cmake/UseLlvmArchive.cmake b/cmake/UseLlvmArchive.cmake new file mode 100644 index 0000000..71ae0fa --- /dev/null +++ b/cmake/UseLlvmArchive.cmake @@ -0,0 +1,35 @@ +# Use llvm-ar with `rcs` so we dont need to setup a separate ranlib. + +# Identify compiler is IntelLLVM +# https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER_ID.html +if (NOT (CMAKE_Fortran_COMPILER_ID MATCHES "IntelLLVM")) + return() +endif() + +# set a temp variable to hold the Fortran compiler path +set(_TMP_VAR "") +if (CMAKE_Fortran_COMPILER) + set(_TMP_VAR "${CMAKE_Fortran_COMPILER}") +endif() + +# try to discover full paths to llvm-ar +# https://cmake.org/cmake/help/latest/command/execute_process.html +if (_TMP_VAR) + execute_process( + COMMAND "${_TMP_VAR}" -print-prog-name=llvm-ar + OUTPUT_VARIABLE LLVM_AR_PATH + OUTPUT_STRIP_TRAILING_WHITESPACE + ) +endif() + +# enforce llvm-ar +set(CMAKE_AR "${LLVM_AR_PATH}" CACHE FILEPATH "" FORCE) + +# write index table via `s` flag, which disables separate ranlib step. +# https://github.com/Kitware/CMake/blob/1c7fe4dc0b47de90bec6918b33f0aca47d688887/Modules/CMakeCInformation.cmake#L152-L162 +# https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_ARCHIVE_FINISH.html +# +set(CMAKE_Fortran_ARCHIVE_CREATE " rcs ") +set(CMAKE_Fortran_ARCHIVE_FINISH "") + +unset(_TMP_VAR)