diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2011-12-09 23:04:19 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2012-02-09 13:33:57 (GMT) |
commit | 538c3452ad660a45c3d6ca32f8c09ee7c93a8b84 (patch) | |
tree | 411effeac65ff00e7dfc2d22da9f74906f4f5e52 /Tests/VSGNUFortran/CMakeLists.txt | |
parent | 3c6af5ff33a12b3c5603cba06e575fe62e234ce0 (diff) | |
download | CMake-538c3452ad660a45c3d6ca32f8c09ee7c93a8b84.zip CMake-538c3452ad660a45c3d6ca32f8c09ee7c93a8b84.tar.gz CMake-538c3452ad660a45c3d6ca32f8c09ee7c93a8b84.tar.bz2 |
Add CMakeAddFortranSubdirectory to use MinGW gfortran in VS
This patch adds a new module that allows for easy integration of MinGW
gfortran and the Visual Studio compiler. It is done in a function called
cmake_add_fortran_subdirectory. The patch also includes a test for this
feature.
Diffstat (limited to 'Tests/VSGNUFortran/CMakeLists.txt')
-rw-r--r-- | Tests/VSGNUFortran/CMakeLists.txt | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/Tests/VSGNUFortran/CMakeLists.txt b/Tests/VSGNUFortran/CMakeLists.txt new file mode 100644 index 0000000..2e527f9 --- /dev/null +++ b/Tests/VSGNUFortran/CMakeLists.txt @@ -0,0 +1,39 @@ +cmake_minimum_required(VERSION 2.8) +project(VSGNUFortran) +# force the executable to be put out of Debug/Release dir +# because gmake build of fortran will not be in a config +# directory, and for easier testing we want the exe and .dll +# to be in the same directory. +if(CMAKE_CONFIGURATION_TYPES) + foreach(config ${CMAKE_CONFIGURATION_TYPES}) + string(TOUPPER "${config}" config) + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${config} + "${PROJECT_BINARY_DIR}/bin") + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${config} + "${PROJECT_BINARY_DIR}/bin") + endforeach() +else() + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin) + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin) +endif() + +include(CMakeAddFortranSubdirectory) +# add the fortran subdirectory as a fortran project +# the subdir is fortran, the project is FortranHello +cmake_add_fortran_subdirectory(fortran + PROJECT FortranHello # project name in toplevel CMakeLists.txt + ARCHIVE_DIR ../bin # .lib location relative to root binary tree + RUNTIME_DIR ../bin # .dll location relative to root binary tree + LIBRARIES hello world # target libraries created + CMAKE_COMMAND_LINE -DEXECUTABLE_OUTPUT_PATH=../bin + -DLIBRARY_OUTPUT_PATH=../bin + LINK_LIBRARIES # link interface libraries + LINK_LIBS hello world # hello needs world to link + ) + +include_directories(${VSGNUFortran_BINARY_DIR}/fortran) +add_subdirectory(c_code) +# use a cmake script to run the executable so that PATH +# can be set with the MinGW/bin in it, and the fortran +# runtime libraries can be found. +configure_file(runtest.cmake.in runtest.cmake @ONLY) |