vcpkg/ports/vcpkg-gfortran/portfile.cmake
Alexander Neumann f3b96f339c
[lapack-reference|fortran] Add new port (#12805)
* [vcpkg/script] add vcpkg_find_fortran

* [openblas] add pkg-config fixes

* [lapack] add lapack-reference and reduce dependency on clapack

* fix build issues

* dont touch any main files

* move toolchain var into parent scope

* fix a few more issues

* create link in the noblas case

* removed unnecessary check handled by vcpkg_find_fortran.

* move dumpbin check

* fix last issue

* depend on openblas

* set cmake_binary_dir so that compiler id run gets put into buildtree.

* more paths

* add missing PARENT_SCOPE

* ws change

* [mlpack] remove dep on clapack

* comment out patches

* remove openblas again

* Install lapack wrapper since it is missing linkage against -lm and -lgfortran

* PREPEND mingw path to make sure cmake picks it up correctly

* depend on openblas also on osx

* add clapack on windows to skip due to conflicting library installs

* add clapack to skip on linux

* add -fPIC as a fortran compiler flag

* do not add the flag on windows

* add gcc explicitly to the cmake args.

* ws change

* applyrequested changes from CR

* fix the failing patch
2020-08-12 10:28:41 -07:00

53 lines
2.5 KiB
CMake

vcpkg_fail_port_install(ON_ARCH "arm" ON_TARGET "linux" "osx")
include(vcpkg_find_fortran)
vcpkg_find_fortran(FORTRAN_CMAKE)
if(VCPKG_USE_INTERNAL_Fortran)
set(VCPKG_CRT_LINKAGE dynamic) # Will always be dynamic no way to overwrite internal CRT linkage here
vcpkg_check_linkage(ONLY_DYNAMIC_LIBRARY)
if(DEFINED ENV{PROCESSOR_ARCHITEW6432})
set(HOST_ARCH $ENV{PROCESSOR_ARCHITEW6432})
else()
set(HOST_ARCH $ENV{PROCESSOR_ARCHITECTURE})
endif()
if(HOST_ARCH MATCHES "(amd|AMD)64")
set(MINGW_W w64)
set(MSYS_HOST x86_64)
elseif(HOST_ARCH MATCHES "(x|X)86")
set(MINGW_W w32)
set(MSYS_HOST i686)
else()
message(FATAL_ERROR "Unsupported host architecture ${HOST_ARCH}!" )
endif()
if(VCPKG_TARGET_ARCHITECTURE MATCHES "(x|X)64")
set(MSYS_TARGET x86_64)
set(MINGW_W_TARGET 64)
set(GCC_LIB_SUFFIX s_seh-1)
elseif(VCPKG_TARGET_ARCHITECTURE MATCHES "(x|X)86")
set(MSYS_TARGET i686)
set(MINGW_W_TARGET 32)
set(GCC_LIB_SUFFIX s_dw2-1)
else()
message(FATAL_ERROR "Unsupported target architecture ${VCPKG_TARGET_ARCHITECTURE}!" )
endif()
vcpkg_acquire_msys(MSYS_ROOT PACKAGES "mingw-w64-${MSYS_TARGET}-gcc-fortran") # TODO: make x86 work
set(MINGW_BIN "${MSYS_ROOT}/mingw${MINGW_W_TARGET}/bin/")
set(MINGW_Fortran_DLLS "${MINGW_BIN}/libgfortran-5.dll"
"${MINGW_BIN}/libquadmath-0.dll"
"${MINGW_BIN}/libwinpthread-1.dll"
"${MINGW_BIN}/libgcc_${GCC_LIB_SUFFIX}.dll")
file(INSTALL ${MINGW_Fortran_DLLS} DESTINATION "${CURRENT_PACKAGES_DIR}/bin")
file(INSTALL ${MINGW_Fortran_DLLS} DESTINATION "${CURRENT_PACKAGES_DIR}/debug/bin")
set(VCPKG_POLICY_SKIP_DUMPBIN_CHECKS enabled) # due to outdated msvcrt
set(VCPKG_POLICY_DLLS_WITHOUT_LIBS enabled)
set(VCPKG_POLICY_EMPTY_INCLUDE_FOLDER enabled)
file(INSTALL "${MSYS_ROOT}/mingw${MINGW_W_TARGET}/share/licenses/winpthreads" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}/license")
file(INSTALL "${MSYS_ROOT}/mingw${MINGW_W_TARGET}/share/licenses/gcc-libs" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}/license")
file(INSTALL "${MSYS_ROOT}/mingw${MINGW_W_TARGET}/share/licenses/crt/COPYING.MinGW-w64-runtime.txt" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
else()
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
endif()