Skip to content
Snippets Groups Projects
Commit d4bb5cdb authored by Arne Lüchow's avatar Arne Lüchow
Browse files

version with installed pFUnit

parent f33e8761
No related branches found
No related tags found
No related merge requests found
...@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.5) ...@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.5)
### options ### options
option(WARNINGS "ON - display compiler warnings, OFF - do not display compiler warnings" ON) option(WARNINGS "ON - display compiler warnings, OFF - do not display compiler warnings" ON)
option(OPENMP "ON - enables adding of OpenMP targets, OFF - disables adding of OpenMP targets" OFF) option(OPENMP "ON - enables adding of OpenMP targets, OFF - disables adding of OpenMP targets" OFF)
option(PFUNIT "ON - using pFUnit for unit tests, OFF - skip building unit tests" OFF) option(PFUNITTESTS "ON - using pFUnit for unit tests, OFF - skip building unit tests" ON)
# defines project name and used language # defines project name and used language
project(FortranTemplate Fortran) project(FortranTemplate Fortran)
......
### for the use of pFUnit ### for the use of pFUnit
if (${PFUNIT}) # this version:_
# expects standard pFUnit installation, i.e. env variables PFUNIT und F90_VENDOR set
if (${PFUNITTESTS})
enable_testing() enable_testing()
include(ExternalProject)
###include(ExternalProject)
# python is needed for the preprocessing # python is needed for the preprocessing
find_program(PYTHON python) find_program(PYTHON python)
set(PFUNIT_BUILD_PATH ${PROJECT_BINARY_DIR}/pFUnit) set(PFUNIT_BUILD_PATH $ENV{PFUNIT})
message(" using pFUnit installed at ${PFUNIT_BUILD_PATH}")
# this way, pFUnit is configured during the cmake build step # this way, pFUnit is configured during the cmake build step
ExternalProject_Add(pFUnit # ExternalProject_Add(pFUnit
PREFIX pFUnit # PREFIX pFUnit
SOURCE_DIR ${PROJECT_SOURCE_DIR}/pFUnit # SOURCE_DIR ${PROJECT_SOURCE_DIR}/pFUnit
BINARY_DIR ${PFUNIT_BUILD_PATH} # BINARY_DIR ${PFUNIT_BUILD_PATH}
TMP_DIR ${PFUNIT_BUILD_PATH}/tmp # TMP_DIR ${PFUNIT_BUILD_PATH}/tmp
STAMP_DIR ${PFUNIT_BUILD_PATH}/stamp # STAMP_DIR ${PFUNIT_BUILD_PATH}/stamp
CMAKE_ARGS # CMAKE_ARGS
"-DCMAKE_INSTALL_PREFIX=${PFUNIT_BUILD_PATH}" # "-DCMAKE_INSTALL_PREFIX=${PFUNIT_BUILD_PATH}"
"-DINSTALL_PATH=${PFUNIT_BUILD_PATH}" # "-DINSTALL_PATH=${PFUNIT_BUILD_PATH}"
"-DCMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER}" # "-DCMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER}"
) # )
add_test(NAME pFUnitTest # add_test(NAME pFUnitTest
COMMAND ${PFUNIT_BUILD_PATH}/tests/tests.x # COMMAND ${PFUNIT_BUILD_PATH}/tests/tests.x
WORKING_DIRECTORY ${PFUNIT_BUILD_PATH}) # WORKING_DIRECTORY ${PFUNIT_BUILD_PATH})
#
set_tests_properties(pFUnitTest # set_tests_properties(pFUnitTest
PROPERTIES LABELS "pFUnit;${PROJECT_NAME}") # PROPERTIES LABELS "pFUnit;${PROJECT_NAME}")
function(add_pFUnit_test moduleName libraries) function(add_pFUnit_test moduleName libraries)
# Input: # Input:
...@@ -49,7 +55,9 @@ if (${PFUNIT}) ...@@ -49,7 +55,9 @@ if (${PFUNIT})
add_custom_command( add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${test}.f90 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${test}.f90
COMMAND ${PYTHON} ${PFUNIT_BUILD_PATH}/bin/pFUnitParser.py ${CMAKE_CURRENT_LIST_DIR}/${test}.pf ${CMAKE_CURRENT_BINARY_DIR}/${test}.f90 COMMAND ${PYTHON} ${PFUNIT_BUILD_PATH}/bin/pFUnitParser.py ${CMAKE_CURRENT_LIST_DIR}/${test}.pf ${CMAKE_CURRENT_BINARY_DIR}/${test}.f90
DEPENDS pFUnit ${CMAKE_CURRENT_LIST_DIR}/${test}.pf) DEPENDS ${CMAKE_CURRENT_LIST_DIR}/${test}.pf)
#####DEPENDS pFUnit ${CMAKE_CURRENT_LIST_DIR}/${test}.pf)
# adding the test to testSuites.inc # adding the test to testSuites.inc
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/testSuites.inc "ADD_TEST_SUITE(${test}_suite)\n") file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/testSuites.inc "ADD_TEST_SUITE(${test}_suite)\n")
...@@ -59,7 +67,7 @@ if (${PFUNIT}) ...@@ -59,7 +67,7 @@ if (${PFUNIT})
endforeach() endforeach()
add_executable(${moduleName}Tests.bin add_executable(${moduleName}Tests.bin
${PROJECT_SOURCE_DIR}/pFUnit/include/driver.F90 ${PFUNIT_BUILD_PATH}/include/driver.F90
${ppSources}) ${ppSources})
target_include_directories(${moduleName}Tests.bin target_include_directories(${moduleName}Tests.bin
......
Subproject commit bb130e68bea079d71333e43222edee1d24a6d472
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment