Skip to content

Instantly share code, notes, and snippets.

@quaat
Created September 3, 2013 22:13
Show Gist options
  • Save quaat/6430296 to your computer and use it in GitHub Desktop.
Save quaat/6430296 to your computer and use it in GitHub Desktop.
qmake prf-file for mixed programming with fortran
isEmpty( fortran_compiler ) {
# gfortran.prf
# Adds gfortran as extra compiler to the qmake build system.
#
# This file must reside in the path of QMAKEFEATURES
#
# Thomas Hagelien
#
F90 = gfortran
# Define debug and relase flags
debug:FFLAGS = -O0 -g -Wall -ffree-line-length-none -g -fno-stack-protector -fbacktrace
release:FFLAGS = -ffree-line-length-none -O2 -ftree-vectorize -march=native
!isEmpty( MODULE_DIR ) {
FFLAGS += -J $${MODULE_DIR}$${DIR_SEPARATOR}
}
# release:FFLAGS = -cpp -fcray-pointer -g -J $${MODULE_DIR}$${DIR_SEPARATOR} -fdefault-real-8 -O2 -ffree-line-length-none -fno-range-check
# Set up the compiler directives
objdir =
# debug:objdir = debug$${DIR_SEPARATOR}
# release:objdir = release$${DIR_SEPARATOR}
fortran.output = $$quote($(OBJECTS_DIR))$${DIR_SEPARATOR}${QMAKE_FILE_BASE}$${QMAKE_EXT_OBJ}
fortran.input = FSOURCES
# If MODULE_DIR is specified, create if neccessary and and to INCLUDEPATH
!isEmpty( MODULE_DIR ) {
# fortran.commands = @$(CHK_DIR_EXISTS) $${MODULE_DIR} $(MKDIR) $${MODULE_DIR} $$escape_expand(\\n\\t)
INCLUDEPATH += $${MODULE_DIR}
} else {
}
fortran.obj = $(OBJECTS_DIR)
LIBS += -lgfortran
# Set up build command
fortran.commands += $$F90 -c $$FFLAGS ${QMAKE_FILE_NAME}
fortran.commands += $$MODFLAGS
fortran.commands += -o $$fortran.obj${QMAKE_FILE_OUT}
fortran.commands += $(INCPATH)
fortran.CONFIG += target_predeps
fortran.dependency_type = TYPE_C
QMAKE_EXTRA_COMPILERS += fortran
} else {
!build_pass:error(Fortran compiler ($$fortran_compiler) already defined. Please check your CONFIG settings)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment