diff options
author | julie <julielangou@users.noreply.github.com> | 2011-08-15 13:26:00 +0000 |
---|---|---|
committer | julie <julielangou@users.noreply.github.com> | 2011-08-15 13:26:00 +0000 |
commit | e6e99382cbc69083c53fae5af84986f44e950fb8 (patch) | |
tree | 365433381a7c126f7af920d15041d03fe1ae2d1c /CMAKE | |
parent | 830433cc32848e050bf5776a2c2e7f016fb8b732 (diff) | |
download | lapack-e6e99382cbc69083c53fae5af84986f44e950fb8.tar.gz lapack-e6e99382cbc69083c53fae5af84986f44e950fb8.tar.bz2 lapack-e6e99382cbc69083c53fae5af84986f44e950fb8.zip |
Add missing files for GNU-built LAPACK DLLs with MS tools
Diffstat (limited to 'CMAKE')
-rw-r--r-- | CMAKE/GNUtoMS.cmake | 85 | ||||
-rw-r--r-- | CMAKE/GNUtoMS/lib.bat.in | 3 | ||||
-rw-r--r-- | CMAKE/GNUtoMS/lib.cmake | 10 | ||||
-rw-r--r-- | CMAKE/README-GNUtoMS.txt | 10 | ||||
-rw-r--r-- | CMAKE/lapack-GNUtoMS.cmake | 16 |
5 files changed, 124 insertions, 0 deletions
diff --git a/CMAKE/GNUtoMS.cmake b/CMAKE/GNUtoMS.cmake new file mode 100644 index 00000000..186b28ac --- /dev/null +++ b/CMAKE/GNUtoMS.cmake @@ -0,0 +1,85 @@ + +#============================================================================= +# GNUtoMS - CMake module for Windows import library conversion +# Copyright 2010-2011 Kitware, Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# * Neither the name of Kitware, Inc. nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +#============================================================================= + +# GNUtoMS works only for the GNU toolchain on Windows (MinGW and MSys). +set(GNUtoMS 0) +if(NOT "${CMAKE_Fortran_COMPILER_ID}" STREQUAL "GNU" OR NOT WIN32 OR CYGWIN) + return() +endif() + +# Locate auxiliary GNUtoMS files. +get_filename_component(GNUtoMS_DIR ${CMAKE_CURRENT_LIST_FILE} PATH) +set(GNUtoMS_DIR ${GNUtoMS_DIR}/GNUtoMS) + +if(NOT CMAKE_SIZEOF_VOID_P) + enable_language(C) # Find CMAKE_SIZEOF_VOID_P reliably. +endif() + +# Find MS development environment setup script for this architecture. +if("${CMAKE_SIZEOF_VOID_P}" EQUAL 4) + find_program(VCVARS32 NAMES vcvars32.bat + PATHS + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0\\Setup\\VC;ProductDir]/bin" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\9.0\\Setup\\VC;ProductDir]/bin" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0\\Setup\\VC;ProductDir]/bin" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\7.1\\Setup\\VC;ProductDir]/bin" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\6.0\\Setup\\Microsoft Visual C++;ProductDir]/bin" + ) + set(GNUtoMS_ENV "${VCVARS32}") + set(GNUtoMS_ARCH x86) +elseif("${CMAKE_SIZEOF_VOID_P}" EQUAL 8) + find_program(VCVARSAMD64 NAMES vcvarsamd64.bat + PATHS + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0\\Setup\\VC;ProductDir]/bin/amd64" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\9.0\\Setup\\VC;ProductDir]/bin/amd64" + "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\8.0\\Setup\\VC;ProductDir]/bin/amd64" + ) + set(GNUtoMS_ENV "${VCVARSAMD64}") + set(GNUtoMS_ARCH amd64) +endif() + +if(GNUtoMS_ENV) + set(GNUtoMS 1) + + # Create helper script to run lib.exe from MS environment. + string(REPLACE "/" "\\" GNUtoMS_BAT "${GNUtoMS_ENV}") + set(LIB ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/GNUtoMSlib.bat) + configure_file(${GNUtoMS_DIR}/lib.bat.in ${LIB}) + + # Teach CMake how to create a MS import library at link time. + set(CMAKE_Fortran_CREATE_SHARED_LIBRARY + "${CMAKE_Fortran_CREATE_SHARED_LIBRARY} -Wl,--output-def,<TARGET_NAME>.def" + "<CMAKE_COMMAND> -Dlib=\"${LIB}\" -Ddef=\"<TARGET_NAME>.def\" -Ddll=\"<TARGET>\" -Dimp=\"<TARGET_IMPLIB>\" -P \"${GNUtoMS_DIR}/lib.cmake\"" + ) +endif() diff --git a/CMAKE/GNUtoMS/lib.bat.in b/CMAKE/GNUtoMS/lib.bat.in new file mode 100644 index 00000000..70d5f738 --- /dev/null +++ b/CMAKE/GNUtoMS/lib.bat.in @@ -0,0 +1,3 @@ +@echo off
+call "@GNUtoMS_BAT@"
+lib /machine:"@GNUtoMS_ARCH@" %*
diff --git a/CMAKE/GNUtoMS/lib.cmake b/CMAKE/GNUtoMS/lib.cmake new file mode 100644 index 00000000..6eaba62e --- /dev/null +++ b/CMAKE/GNUtoMS/lib.cmake @@ -0,0 +1,10 @@ +# Usage: cmake -Dlib=lib.bat -Ddef=out.def -Ddll=out.dll -Dimp=out.dll.a -P lib.cmake +get_filename_component(name ${dll} NAME) # .dll file name +string(REGEX REPLACE "\\.dll\\.a$" ".lib" out "${imp}") # .dll.a -> .lib +execute_process( + COMMAND ${lib} /def:${def} /name:${name} /out:${out} + RESULT_VARIABLE res + ) +if(res) + message(FATAL_ERROR "lib failed: ${res}") +endif() diff --git a/CMAKE/README-GNUtoMS.txt b/CMAKE/README-GNUtoMS.txt new file mode 100644 index 00000000..5844aaea --- /dev/null +++ b/CMAKE/README-GNUtoMS.txt @@ -0,0 +1,10 @@ +The GNUtoMS CMake module helps LAPACK provide MS-compatible DLLs on +Windows when built with a free GNU Fortran compiler (e.g. MinGW). If +MS Visual Studio tools are installed when one configures LAPACK to +build with GNU tools the module extends the shared library link rule. +The extended rule creates both a GNU-style .dll.a import library and a +MS-format .lib import library. + +LAPACK CMake code installs the import libraries for both formats. +Applications built using CMake can be configured automatically to use +the import libraries matching the target toolchain. diff --git a/CMAKE/lapack-GNUtoMS.cmake b/CMAKE/lapack-GNUtoMS.cmake new file mode 100644 index 00000000..490700c9 --- /dev/null +++ b/CMAKE/lapack-GNUtoMS.cmake @@ -0,0 +1,16 @@ +# Skip conversion for non-GNU tools. +if(MINGW OR MSYS OR CYGWIN) + return() +endif() + +# Replace each imported target's import library. +foreach(lib blas lapack) + # Replace for all imported build configurations. + get_property(configs TARGET ${lib} PROPERTY IMPORTED_CONFIGURATIONS) + foreach(config ${configs}) + get_property(implib TARGET ${lib} PROPERTY IMPORTED_IMPLIB_${config}) + # Switch to the MS-compatible import library. + string(REGEX REPLACE "\\.dll\\.a$" ".lib" implib "${implib}") + set_property(TARGET ${lib} PROPERTY IMPORTED_IMPLIB_${config} ${implib}) + endforeach() +endforeach() |