From 71402eb25244e5805df54c2f6e62ddd36201dbd6 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 8 Sep 2011 14:56:48 -0400 Subject: FortranCInterface: Compile separate Fortran lib in VerifyC[XX] The Intel Fortran plugin for Visual Studio requires Fortran source files to be compiled in a separate target from C and C++ code. Compile the VerifyFortran.f source file in a separate library and link the main VerifyFortanC executable to it. --- Modules/FortranCInterface/Verify/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Modules/FortranCInterface/Verify/CMakeLists.txt b/Modules/FortranCInterface/Verify/CMakeLists.txt index 052dd59..e969f24 100644 --- a/Modules/FortranCInterface/Verify/CMakeLists.txt +++ b/Modules/FortranCInterface/Verify/CMakeLists.txt @@ -24,7 +24,9 @@ include(FortranCInterface) FortranCInterface_HEADER(VerifyFortran.h SYMBOLS VerifyFortran) include_directories(${VerifyFortranC_BINARY_DIR}) -add_executable(VerifyFortranC main.c VerifyC.c VerifyFortran.f ${VerifyCXX}) +add_library(VerifyFortran STATIC VerifyFortran.f) +add_executable(VerifyFortranC main.c VerifyC.c ${VerifyCXX}) +target_link_libraries(VerifyFortranC VerifyFortran) if(NOT VERIFY_CXX) # The entry point (main) is defined in C; link with the C compiler. -- cgit v0.12 From 555f589a5a3e9387956d451dc253fa1e3f35adff Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Thu, 8 Sep 2011 17:42:49 -0400 Subject: For VS Intel Fortran IDE builds, add a check to find the Fortran library PATH. To use VS C and Fotran in the same solution, it is required that VS be able to find the Fortran run time libraries as they will be implicitly linked by any Fortran library used by VS C programs. This adds a check into CMakeDetermineCompilerABI using a try-compile to find the correct PATH. --- Modules/CMakeDetermineCompilerABI.cmake | 26 ++++++++++++++++++++++ .../IntelVSImplicitPath/CMakeLists.txt | 11 +++++++++ .../IntelVSImplicitPath/extract.cmake | 12 ++++++++++ .../FortranCInterface/IntelVSImplicitPath/hello.f | 0 4 files changed, 49 insertions(+) create mode 100644 Modules/FortranCInterface/IntelVSImplicitPath/CMakeLists.txt create mode 100644 Modules/FortranCInterface/IntelVSImplicitPath/extract.cmake create mode 100644 Modules/FortranCInterface/IntelVSImplicitPath/hello.f diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake index 39d1f17..528c327 100644 --- a/Modules/CMakeDetermineCompilerABI.cmake +++ b/Modules/CMakeDetermineCompilerABI.cmake @@ -83,6 +83,32 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ABI lang src) FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Parsed ${lang} implicit link information from above output:\n${log}\n\n") ENDIF() + # for VS IDE Intel Fortran we have to figure out the + # implicit link path for the fortran run time using + # a try-compile + IF("${lang}" MATCHES "Fortran" + AND "${CMAKE_GENERATOR}" MATCHES "Visual Studio") + SET(_desc "Determine Intel Fortran Compiler Implicit Link Path") + MESSAGE(STATUS "${_desc}") + # Build a sample project which reports symbols. + TRY_COMPILE(IFORT_LIB_PATH_COMPILED + ${CMAKE_BINARY_DIR}/CMakeFiles/IntelVSImplicitPath + ${CMAKE_ROOT}/Modules/FortranCInterface/IntelVSImplicitPath + IntelFortranImplicit + CMAKE_FLAGS + "-DCMAKE_Fortran_FLAGS:STRING=${CMAKE_Fortran_FLAGS}" + OUTPUT_VARIABLE _output) + FILE(READ + ${CMAKE_BINARY_DIR}/CMakeFiles/IntelVSImplicitPath/implict_link.txt + dir) + LIST(APPEND implicit_dirs "${dir}") + FILE(WRITE + "${CMAKE_BINARY_DIR}/CMakeFiles/IntelVSImplicitPath/output.txt" + "${_output}") + SET(_desc "Determine Intel Fortran Compiler Implicit Link Path -- done") + MESSAGE(STATUS "${_desc}") + ENDIF() + SET(CMAKE_${lang}_IMPLICIT_LINK_LIBRARIES "${implicit_libs}" PARENT_SCOPE) SET(CMAKE_${lang}_IMPLICIT_LINK_DIRECTORIES "${implicit_dirs}" PARENT_SCOPE) diff --git a/Modules/FortranCInterface/IntelVSImplicitPath/CMakeLists.txt b/Modules/FortranCInterface/IntelVSImplicitPath/CMakeLists.txt new file mode 100644 index 0000000..e2a4b3f --- /dev/null +++ b/Modules/FortranCInterface/IntelVSImplicitPath/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required (VERSION 2.8) +project(IntelFortranImplicit Fortran) +add_custom_command(OUTPUT ${IntelFortranImplicit_BINARY_DIR}/env.txt + COMMAND set > ${IntelFortranImplicit_BINARY_DIR}/env.txt) +add_library(FortranLib hello.f + ${IntelFortranImplicit_BINARY_DIR}/env.txt) +add_custom_target(ExtractLibPath ALL + COMMAND ${CMAKE_COMMAND} -P ${IntelFortranImplicit_SOURCE_DIR}/extract.cmake + WORKING_DIRECTORY ${IntelFortranImplicit_BINARY_DIR} +) +add_dependencies(ExtractLibPath FortranLib) diff --git a/Modules/FortranCInterface/IntelVSImplicitPath/extract.cmake b/Modules/FortranCInterface/IntelVSImplicitPath/extract.cmake new file mode 100644 index 0000000..055247c --- /dev/null +++ b/Modules/FortranCInterface/IntelVSImplicitPath/extract.cmake @@ -0,0 +1,12 @@ +file(STRINGS env.txt LIB REGEX "^LIB=.*$") +string(REPLACE "LIB=" "" LIB "${LIB}" ) +# change LIB from a string to a ; separated list of paths +set(LIB ${LIB}) +# look at each path and try to find ifconsol.lib +foreach( dir ${LIB}) + file(TO_CMAKE_PATH "${dir}" dir) + if(EXISTS "${dir}/ifconsol.lib") + file(WRITE implict_link.txt ${dir}) + return() + endif() +endforeach() diff --git a/Modules/FortranCInterface/IntelVSImplicitPath/hello.f b/Modules/FortranCInterface/IntelVSImplicitPath/hello.f new file mode 100644 index 0000000..e69de29 -- cgit v0.12 From 539a822c8c541143ab954d8d355cb9643235d231 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Fri, 9 Sep 2011 17:11:57 -0400 Subject: Enable Fortran tests for IDE builds. --- Tests/CMakeLists.txt | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 9f4e8a3..a3d1cbf 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1926,29 +1926,36 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ ENDIF ("${PREVIOUS_TIMEOUT}" MATCHES NOTFOUND) ENDIF() - # fortran does not work for IDE builds because - # CMAKE_STANDARD_LIBRARIES needs to be per language - IF(CMAKE_TEST_GENERATOR MATCHES "Make|KDevelop") - IF(CMAKE_Fortran_COMPILER) - ADD_TEST(Fortran ${CMAKE_CTEST_COMMAND} + IF(CMAKE_Fortran_COMPILER) + ADD_TEST(Fortran ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/Fortran" + "${CMake_BINARY_DIR}/Tests/Fortran" + --build-generator ${CMAKE_TEST_GENERATOR} + --build-project testf + --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} + --build-two-config + --test-command testf) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Fortran") + + # FortranCInterface tests. + IF(UNIX) + CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/FortranC/Flags.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/FortranC/Flags.cmake @ONLY) + ADD_TEST(FortranC.Flags ${CMAKE_CMAKE_COMMAND} -P + ${CMAKE_CURRENT_BINARY_DIR}/FortranC/Flags.cmake) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/FortranC/Flags") + ELSE() + ADD_TEST(FortranC ${CMAKE_CTEST_COMMAND} --build-and-test - "${CMake_SOURCE_DIR}/Tests/Fortran" - "${CMake_BINARY_DIR}/Tests/Fortran" + "${CMake_SOURCE_DIR}/Tests/FortranC" + "${CMake_BINARY_DIR}/Tests/FortranC" --build-generator ${CMAKE_TEST_GENERATOR} - --build-project testf + --build-project FortranC --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-two-config - --test-command testf) - LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Fortran") - - # FortranCInterface tests. - IF(UNIX) - CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/FortranC/Flags.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/FortranC/Flags.cmake @ONLY) - ADD_TEST(FortranC.Flags ${CMAKE_CMAKE_COMMAND} -P - ${CMAKE_CURRENT_BINARY_DIR}/FortranC/Flags.cmake) - LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/FortranC/Flags") - ENDIF() + --test-command CMakeFiles/FortranCInterface/FortranCInterface) + LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/FortranC") ENDIF() ENDIF() -- cgit v0.12 From a7ce26d837b1c6465c995519ee91e3e0d9190826 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 14 Sep 2011 13:49:40 -0400 Subject: Move IntelVSImplicitPath project to better location This project is not part of the FortranCInterface module. Make it a sibling instead of a child directory. --- Modules/CMakeDetermineCompilerABI.cmake | 2 +- Modules/FortranCInterface/IntelVSImplicitPath/CMakeLists.txt | 11 ----------- Modules/FortranCInterface/IntelVSImplicitPath/extract.cmake | 12 ------------ Modules/FortranCInterface/IntelVSImplicitPath/hello.f | 0 Modules/IntelVSImplicitPath/CMakeLists.txt | 11 +++++++++++ Modules/IntelVSImplicitPath/extract.cmake | 12 ++++++++++++ Modules/IntelVSImplicitPath/hello.f | 0 7 files changed, 24 insertions(+), 24 deletions(-) delete mode 100644 Modules/FortranCInterface/IntelVSImplicitPath/CMakeLists.txt delete mode 100644 Modules/FortranCInterface/IntelVSImplicitPath/extract.cmake delete mode 100644 Modules/FortranCInterface/IntelVSImplicitPath/hello.f create mode 100644 Modules/IntelVSImplicitPath/CMakeLists.txt create mode 100644 Modules/IntelVSImplicitPath/extract.cmake create mode 100644 Modules/IntelVSImplicitPath/hello.f diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake index 528c327..6792b7a 100644 --- a/Modules/CMakeDetermineCompilerABI.cmake +++ b/Modules/CMakeDetermineCompilerABI.cmake @@ -93,7 +93,7 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ABI lang src) # Build a sample project which reports symbols. TRY_COMPILE(IFORT_LIB_PATH_COMPILED ${CMAKE_BINARY_DIR}/CMakeFiles/IntelVSImplicitPath - ${CMAKE_ROOT}/Modules/FortranCInterface/IntelVSImplicitPath + ${CMAKE_ROOT}/Modules/IntelVSImplicitPath IntelFortranImplicit CMAKE_FLAGS "-DCMAKE_Fortran_FLAGS:STRING=${CMAKE_Fortran_FLAGS}" diff --git a/Modules/FortranCInterface/IntelVSImplicitPath/CMakeLists.txt b/Modules/FortranCInterface/IntelVSImplicitPath/CMakeLists.txt deleted file mode 100644 index e2a4b3f..0000000 --- a/Modules/FortranCInterface/IntelVSImplicitPath/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -cmake_minimum_required (VERSION 2.8) -project(IntelFortranImplicit Fortran) -add_custom_command(OUTPUT ${IntelFortranImplicit_BINARY_DIR}/env.txt - COMMAND set > ${IntelFortranImplicit_BINARY_DIR}/env.txt) -add_library(FortranLib hello.f - ${IntelFortranImplicit_BINARY_DIR}/env.txt) -add_custom_target(ExtractLibPath ALL - COMMAND ${CMAKE_COMMAND} -P ${IntelFortranImplicit_SOURCE_DIR}/extract.cmake - WORKING_DIRECTORY ${IntelFortranImplicit_BINARY_DIR} -) -add_dependencies(ExtractLibPath FortranLib) diff --git a/Modules/FortranCInterface/IntelVSImplicitPath/extract.cmake b/Modules/FortranCInterface/IntelVSImplicitPath/extract.cmake deleted file mode 100644 index 055247c..0000000 --- a/Modules/FortranCInterface/IntelVSImplicitPath/extract.cmake +++ /dev/null @@ -1,12 +0,0 @@ -file(STRINGS env.txt LIB REGEX "^LIB=.*$") -string(REPLACE "LIB=" "" LIB "${LIB}" ) -# change LIB from a string to a ; separated list of paths -set(LIB ${LIB}) -# look at each path and try to find ifconsol.lib -foreach( dir ${LIB}) - file(TO_CMAKE_PATH "${dir}" dir) - if(EXISTS "${dir}/ifconsol.lib") - file(WRITE implict_link.txt ${dir}) - return() - endif() -endforeach() diff --git a/Modules/FortranCInterface/IntelVSImplicitPath/hello.f b/Modules/FortranCInterface/IntelVSImplicitPath/hello.f deleted file mode 100644 index e69de29..0000000 diff --git a/Modules/IntelVSImplicitPath/CMakeLists.txt b/Modules/IntelVSImplicitPath/CMakeLists.txt new file mode 100644 index 0000000..e2a4b3f --- /dev/null +++ b/Modules/IntelVSImplicitPath/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required (VERSION 2.8) +project(IntelFortranImplicit Fortran) +add_custom_command(OUTPUT ${IntelFortranImplicit_BINARY_DIR}/env.txt + COMMAND set > ${IntelFortranImplicit_BINARY_DIR}/env.txt) +add_library(FortranLib hello.f + ${IntelFortranImplicit_BINARY_DIR}/env.txt) +add_custom_target(ExtractLibPath ALL + COMMAND ${CMAKE_COMMAND} -P ${IntelFortranImplicit_SOURCE_DIR}/extract.cmake + WORKING_DIRECTORY ${IntelFortranImplicit_BINARY_DIR} +) +add_dependencies(ExtractLibPath FortranLib) diff --git a/Modules/IntelVSImplicitPath/extract.cmake b/Modules/IntelVSImplicitPath/extract.cmake new file mode 100644 index 0000000..055247c --- /dev/null +++ b/Modules/IntelVSImplicitPath/extract.cmake @@ -0,0 +1,12 @@ +file(STRINGS env.txt LIB REGEX "^LIB=.*$") +string(REPLACE "LIB=" "" LIB "${LIB}" ) +# change LIB from a string to a ; separated list of paths +set(LIB ${LIB}) +# look at each path and try to find ifconsol.lib +foreach( dir ${LIB}) + file(TO_CMAKE_PATH "${dir}" dir) + if(EXISTS "${dir}/ifconsol.lib") + file(WRITE implict_link.txt ${dir}) + return() + endif() +endforeach() diff --git a/Modules/IntelVSImplicitPath/hello.f b/Modules/IntelVSImplicitPath/hello.f new file mode 100644 index 0000000..e69de29 -- cgit v0.12 From 67fcc838d9e857de2697c2fbe34e40ac095973dc Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 14 Sep 2011 13:59:23 -0400 Subject: Simplify IntelVSImplicitPath detection project Use the ENV{LIB} variable directly instead of parsing the output of the whole environment from "set". Store the output in a .cmake script and include it from CMakeDetermineCompilerABI instead of using file(READ). --- Modules/CMakeDetermineCompilerABI.cmake | 5 +---- Modules/IntelVSImplicitPath/CMakeLists.txt | 14 +++++--------- Modules/IntelVSImplicitPath/detect.cmake | 9 +++++++++ Modules/IntelVSImplicitPath/extract.cmake | 12 ------------ 4 files changed, 15 insertions(+), 25 deletions(-) create mode 100644 Modules/IntelVSImplicitPath/detect.cmake delete mode 100644 Modules/IntelVSImplicitPath/extract.cmake diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake index 6792b7a..a808a28 100644 --- a/Modules/CMakeDetermineCompilerABI.cmake +++ b/Modules/CMakeDetermineCompilerABI.cmake @@ -98,13 +98,10 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ABI lang src) CMAKE_FLAGS "-DCMAKE_Fortran_FLAGS:STRING=${CMAKE_Fortran_FLAGS}" OUTPUT_VARIABLE _output) - FILE(READ - ${CMAKE_BINARY_DIR}/CMakeFiles/IntelVSImplicitPath/implict_link.txt - dir) - LIST(APPEND implicit_dirs "${dir}") FILE(WRITE "${CMAKE_BINARY_DIR}/CMakeFiles/IntelVSImplicitPath/output.txt" "${_output}") + INCLUDE(${CMAKE_BINARY_DIR}/CMakeFiles/IntelVSImplicitPath/output.cmake OPTIONAL) SET(_desc "Determine Intel Fortran Compiler Implicit Link Path -- done") MESSAGE(STATUS "${_desc}") ENDIF() diff --git a/Modules/IntelVSImplicitPath/CMakeLists.txt b/Modules/IntelVSImplicitPath/CMakeLists.txt index e2a4b3f..96dc4e6 100644 --- a/Modules/IntelVSImplicitPath/CMakeLists.txt +++ b/Modules/IntelVSImplicitPath/CMakeLists.txt @@ -1,11 +1,7 @@ cmake_minimum_required (VERSION 2.8) project(IntelFortranImplicit Fortran) -add_custom_command(OUTPUT ${IntelFortranImplicit_BINARY_DIR}/env.txt - COMMAND set > ${IntelFortranImplicit_BINARY_DIR}/env.txt) -add_library(FortranLib hello.f - ${IntelFortranImplicit_BINARY_DIR}/env.txt) -add_custom_target(ExtractLibPath ALL - COMMAND ${CMAKE_COMMAND} -P ${IntelFortranImplicit_SOURCE_DIR}/extract.cmake - WORKING_DIRECTORY ${IntelFortranImplicit_BINARY_DIR} -) -add_dependencies(ExtractLibPath FortranLib) +add_custom_command( + OUTPUT output.cmake + COMMAND ${CMAKE_COMMAND} -P ${IntelFortranImplicit_SOURCE_DIR}/detect.cmake + ) +add_library(FortranLib hello.f output.cmake) diff --git a/Modules/IntelVSImplicitPath/detect.cmake b/Modules/IntelVSImplicitPath/detect.cmake new file mode 100644 index 0000000..20753be --- /dev/null +++ b/Modules/IntelVSImplicitPath/detect.cmake @@ -0,0 +1,9 @@ +# look at each path and try to find ifconsol.lib +set(LIB "$ENV{LIB}") +foreach(dir ${LIB}) + file(TO_CMAKE_PATH "${dir}" dir) + if(EXISTS "${dir}/ifconsol.lib") + file(WRITE output.cmake "list(APPEND implicit_dirs \"${dir}\")\n") + break() + endif() +endforeach() diff --git a/Modules/IntelVSImplicitPath/extract.cmake b/Modules/IntelVSImplicitPath/extract.cmake deleted file mode 100644 index 055247c..0000000 --- a/Modules/IntelVSImplicitPath/extract.cmake +++ /dev/null @@ -1,12 +0,0 @@ -file(STRINGS env.txt LIB REGEX "^LIB=.*$") -string(REPLACE "LIB=" "" LIB "${LIB}" ) -# change LIB from a string to a ; separated list of paths -set(LIB ${LIB}) -# look at each path and try to find ifconsol.lib -foreach( dir ${LIB}) - file(TO_CMAKE_PATH "${dir}" dir) - if(EXISTS "${dir}/ifconsol.lib") - file(WRITE implict_link.txt ${dir}) - return() - endif() -endforeach() -- cgit v0.12