1
1

Make it possible to let user select the Fortran compiler options that they use, so that to support different Fortran compilers on Windows. Not the best solution, but the easiest.

This commit was SVN r22540.
Этот коммит содержится в:
Shiqing Fan 2010-02-03 18:18:15 +00:00
родитель 16b7bc7a82
Коммит 1839a21db4
4 изменённых файлов: 59 добавлений и 53 удалений

Просмотреть файл

@ -20,11 +20,6 @@ MACRO(OMPI_F77_FIND_EXT_SYMBOL_CONVENTION)
SET(OMPI_F77_PLAIN 0
CACHE INTERNAL "external symbol convention - plain")
# first check if we have already detected dumpbin.exe
IF(NOT DUMPBIN_EXE)
MESSAGE(FATAL_ERROR "could not find dumpbin, cannot continue...")
ENDIF(NOT DUMPBIN_EXE)
# make sure we know our linking convention...
MESSAGE(STATUS "Check ${CMAKE_Fortran_COMPILER} external symbol convention...")
FILE(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/conftest.f
@ -34,7 +29,7 @@ MACRO(OMPI_F77_FIND_EXT_SYMBOL_CONVENTION)
"\t return \n"
"\t end \n")
EXECUTE_PROCESS(COMMAND ${F77} -c conftest.f -o conftest.lib
EXECUTE_PROCESS(COMMAND ${F77} ${OMPI_F77_OPTION_COMPILE} conftest.f ${OMPI_F77_OUTPUT_OBJ}conftest.lib
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
OUTPUT_VARIABLE OUTPUT
RESULT_VARIABLE RESULT
@ -43,12 +38,13 @@ MACRO(OMPI_F77_FIND_EXT_SYMBOL_CONVENTION)
SET(OUTPUT_OBJ_FILE "conftest.lib")
# now run dumpbin to generate an output file
EXECUTE_PROCESS(COMMAND ${DUMPBIN_EXE} ${OUTPUT_OBJ_FILE} /symbols /out:conftest_out
EXECUTE_PROCESS(COMMAND ${DUMP_UTIL} ${OUTPUT_OBJ_FILE} /symbols /out:conftest_out
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
OUTPUT_VARIABLE OUTPUT
RESULT_VARIABLE RESULT
ERROR_VARIABLE ERROR)
# find out the external symbol convention
FILE(STRINGS ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/conftest_out
DOUBLE_UNDERSCORE REGEX "foo_bar__$")
@ -104,7 +100,9 @@ MACRO(OMPI_F77_FIND_EXT_SYMBOL_CONVENTION)
"int main(){${FUNC_NAME}();return(0);}")
FILE(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CMakeLists.txt
"CMAKE_MINIMUM_REQUIRED(VERSION 2.4.6 FATAL_ERROR)\n"
"PROJECT(conftest_c C)\n"
"LINK_DIRECTORIES(\"${OMPI_F77_LIB_PATH}\")\n"
"ADD_EXECUTABLE(conftest_c conftest_c.c)\n"
"TARGET_LINK_LIBRARIES(conftest_c ${OUTPUT_OBJ_FILE})\n")

Просмотреть файл

@ -52,13 +52,23 @@ MACRO(OMPI_F77_GET_SIZEOF TYPE OUTPUT_VARIABLE)
"} \n"
"#endif \n")
EXECUTE_PROCESS(COMMAND ${CL_EXE} /c conftest.c /I${VC_INCLUDE_PATH}
# generate the C object file
EXECUTE_PROCESS(COMMAND ${CMAKE_C_COMPILER} ${OMPI_C_OPTION_COMPILE} conftest.c ${OMPI_C_OUTPUT_OBJ}conftest_c.obj
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
OUTPUT_VARIABLE OUTPUT
RESULT_VARIABLE RESULT
ERROR_VARIABLE ERROR)
EXECUTE_PROCESS(COMMAND ${F77} conftest.f conftest.obj -o conftest
# generate the Fortran object file
# some Fortran compilers don't allow to compile and link in one step. :-(
EXECUTE_PROCESS(COMMAND ${F77} ${OMPI_F77_OPTION_COMPILE} conftest.f ${OMPI_F77_OUTPUT_OBJ}conftest.obj
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
OUTPUT_VARIABLE OUTPUT
RESULT_VARIABLE RESULT
ERROR_VARIABLE ERROR)
# link the C and Fortran object files.
EXECUTE_PROCESS(COMMAND ${F77} conftest.obj conftest_c.obj ${OMPI_F77_OUTPUT_EXE}conftest.exe
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
OUTPUT_VARIABLE OUTPUT
RESULT_VARIABLE RESULT

Просмотреть файл

@ -25,45 +25,30 @@ MACRO(OMPI_MICROSOFT_COMPILER)
MESSAGE( STATUS "Start Microsoft specific detection....")
# search for Microsoft VC tools
SET(VC_BIN_PATH ${VC_BIN_PATH}
"C:/Program Files/Microsoft Visual Studio 9.0/VC/bin"
"C:/Program Files (x86)/Microsoft Visual Studio 9.0/VC/bin"
"C:/Program Files/Microsoft Visual Studio 8/VC/BIN"
"C:/Program Files (x86)/Microsoft Visual Studio 8/VC/BIN"
"C:/Program Files/Microsoft Visual Studio .NET 2003/VC7/BIN"
"C:/Program Files (x86)/Microsoft Visual Studio .NET 2003/VC7/BIN"
"$ENV{VS90COMNTOOLS}../../VC/bin"
"$ENV{VS80COMNTOOLS}../../VC/bin"
)
# Set up VS environments.
GET_FILENAME_COMPONENT(CL_EXE_PATH ${CMAKE_C_COMPILER} PATH)
GET_FILENAME_COMPONENT(SDK_ROOT_PATH
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows;CurrentInstallFolder]" ABSOLUTE CACHE)
SET(VS_ROOT_DIR ${CL_EXE_PATH}/../../)
SET(VS_COMMON_TOOLS_DIR ${VS_ROOT_DIR}/Common7/Tools)
SET(VS_IDE_DIR ${VS_ROOT_DIR}/Common7/IDE)
SET(VC_INCLUDE_DIR ${VS_ROOT_DIR}/VC/INCLUDE)
SET(VC_LIB_DIR ${VS_ROOT_DIR}/VC/LIB)
# If we are using one of the Microsoft compilers check that we are
# able to include windows.h. Most of the types that follow are defined
# in this file. If we check for it here it will get included in the
# default list of header files.
FIND_PROGRAM(CL_EXE cl PATHS ${VC_BIN_PATH})
SET(ENV{PATH} "${CL_EXE_PATH};${SDK_ROOT_PATH}/bin;$ENV{PATH}")
SET(ENV{INCLUDE} "${VC_INCLUDE_DIR};$ENV{INCLUDE}")
SET(ENV{LIB} "${VC_LIB_DIR};${SDK_ROOT_PATH}/lib;$ENV{LIB}")
SET(ENV{LIBPATH} "${VC_LIB_DIR};${SDK_ROOT_PATH}/lib;$ENV{LIBPATH}")
# set the default include path for VC
GET_FILENAME_COMPONENT(CL_EXE_PATH "${CL_EXE}" PATH)
GET_FILENAME_COMPONENT(VC_INCLUDE_PATH "${CL_EXE_PATH}/../include" ABSOLUTE CACHE)
GET_FILENAME_COMPONENT(VC_LIB_PATH "${CL_EXE_PATH}/../lib" ABSOLUTE CACHE)
# Default compiler settings.
SET(OMPI_C_OPTION_COMPILE "/c" CACHE INTERNAL
"C compiler option for compiling without linking.")
SET(OMPI_C_OUTPUT_OBJ "/Fo" CACHE INTERNAL
"C compiler option for setting object file name.")
SET(OMPI_C_OUTPUT_EXE "/Fe" CACHE INTERNAL
"C compiler option for setting executable file name.")
# the dumpbin path will be checked again when the f77 support is needed.
FIND_PROGRAM(DUMPBIN_EXE dumpbin PATHS ${VC_BIN_PATH})
# WHEN running dumpbin, it also needs the "Common7/IDE" directory in the
# PATH. It will already be in the PATH if being run from a Visual Studio
# command prompt. Add it to the PATH here in case we are running from a
# different command prompt.
GET_FILENAME_COMPONENT(DUMPBIN_EXE_DIR "${DUMPBIN_EXE}" PATH)
GET_FILENAME_COMPONENT(DUMPBIN_EXE_DLLS_DIR "${DUMPBIN_EXE_DIR}/../../Common7/IDE" ABSOLUTE)
IF(EXISTS "${DUMPBIN_EXE_DLLS_DIR}")
# only add to the path if it is not already in the path
IF(NOT "$ENV{PATH}" MATCHES "${DUMPBIN_EXE_DLLS_DIR}")
SET(ENV{PATH} "$ENV{PATH};${DUMPBIN_EXE_DLLS_DIR}")
ENDIF(NOT "$ENV{PATH}" MATCHES "${DUMPBIN_EXE_DLLS_DIR}")
ENDIF(EXISTS "${DUMPBIN_EXE_DLLS_DIR}")
SET(DUMP_UTIL "dumpbin.exe" CACHE INTERNAL "the dumpbin application.")
FILE(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/cl_test.c
"int main() {return 0;}")
@ -73,16 +58,11 @@ MACRO(OMPI_MICROSOFT_COMPILER)
IF(CL_EXE_OK)
MESSAGE( STATUS "Found Microsoft compiler: ${CL_EXE}.")
# The atomic functions are defined in a very unuasual manner.
# Some of them are intrinsic defined in windows.h others are
# exported by kernel32.dll. If we force the usage of TRY_RUN
# here we will check for both in same time: compilation and run.
# path of foo test programs
SET (FOO_SOURCE_DIR ${OpenMPI_SOURCE_DIR}/CMakeTests)
IF(${CMAKE_SYSTEM_VERSION} GREATER 5.1)
SET(FUNCTION_LIST Exchange ExchangeAcquire ExchangeRelease Exchange64)
ELSE(${CMAKE_SYSTEM_VERSION} GREATER 5.1)

Просмотреть файл

@ -18,7 +18,20 @@ SET(CMAKE_GENERATOR_FC "")
include(CMakeDetermineFortranCompiler)
include(CMakeFortranInformation)
GET_FILENAME_COMPONENT(F77 ${CMAKE_Fortran_COMPILER} NAME)
GET_FILENAME_COMPONENT(F77 ${CMAKE_Fortran_COMPILER} NAME_WE)
GET_FILENAME_COMPONENT(F77_PATH ${CMAKE_Fortran_COMPILER} PATH)
# Default compiler settings.
SET(OMPI_F77_OPTION_COMPILE "-c" CACHE STRING
"Fortran compiler option for compiling without linking.")
SET(OMPI_F77_OUTPUT_OBJ "-o" CACHE STRING
"Fortran compiler option for setting object file name.")
SET(OMPI_F77_OUTPUT_EXE "-o" CACHE STRING
"Fortran compiler option for setting executable file name.")
SET(OMPI_F77_LIB_PATH "" CACHE PATH
"Library path for the fortran compiler")
SET(OMPI_F77_INCLUDE_PATH "" CACHE PATH
"Include path for the fortran compiler")
INCLUDE(F77_find_ext_symbol_convention)
# make sure we know the linking convention
@ -27,6 +40,11 @@ OMPI_F77_FIND_EXT_SYMBOL_CONVENTION()
IF(OMPI_WANT_F77_BINDINGS AND NOT F77_SETUP_DONE)
# Export env variables for fortran compiler.
SET(ENV{PATH} "${F77_PATH};$ENV{PATH}")
SET(ENV{LIB} "${OMPI_F77_LIB_PATH};$ENV{LIB}")
SET(ENV{INCLUDE} "${OMPI_F77_INCLUDE_PATH};$ENV{INCLUDE}")
# make sure the compiler actually works, if not cross-compiling
MESSAGE(STATUS "Checking for working Fortran compiler...")
FILE(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler.f