2013-11-29 13:36:06 -05:00
|
|
|
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
|
2017-02-24 15:19:31 -06:00
|
|
|
project(openmc Fortran C CXX)
|
2013-11-29 13:36:06 -05:00
|
|
|
|
2013-12-01 22:09:35 -05:00
|
|
|
# Setup output directories
|
|
|
|
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
|
|
|
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
|
|
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
|
|
|
|
set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/include)
|
|
|
|
|
|
2015-08-31 11:13:21 +07:00
|
|
|
# Set module path
|
|
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules)
|
|
|
|
|
|
2015-08-29 16:31:29 +07:00
|
|
|
# Make sure Fortran module directory is included when building
|
|
|
|
|
include_directories(${CMAKE_BINARY_DIR}/include)
|
|
|
|
|
|
2014-05-05 18:47:19 -04:00
|
|
|
#===============================================================================
|
|
|
|
|
# Architecture specific definitions
|
|
|
|
|
#===============================================================================
|
|
|
|
|
|
|
|
|
|
if (${UNIX})
|
|
|
|
|
add_definitions(-DUNIX)
|
|
|
|
|
endif()
|
|
|
|
|
|
2013-11-29 13:36:06 -05:00
|
|
|
#===============================================================================
|
|
|
|
|
# Command line options
|
|
|
|
|
#===============================================================================
|
|
|
|
|
|
2017-04-10 07:32:51 -05:00
|
|
|
option(openmp "Enable shared-memory parallelism with OpenMP" ON)
|
2013-11-29 13:36:06 -05:00
|
|
|
option(profile "Compile with profiling flags" OFF)
|
|
|
|
|
option(debug "Compile with debug flags" OFF)
|
|
|
|
|
option(optimize "Turn on all compiler optimization flags" OFF)
|
2015-07-06 08:12:34 +07:00
|
|
|
option(coverage "Compile with coverage analysis flags" OFF)
|
2015-04-17 17:19:34 -05:00
|
|
|
option(mpif08 "Use Fortran 2008 MPI interface" OFF)
|
2013-12-01 20:03:31 -05:00
|
|
|
|
2015-07-06 07:45:21 +07:00
|
|
|
# Maximum number of nested coordinates levels
|
|
|
|
|
set(maxcoord 10 CACHE STRING "Maximum number of nested coordinate levels")
|
|
|
|
|
add_definitions(-DMAX_COORD=${maxcoord})
|
|
|
|
|
|
2013-11-29 13:36:06 -05:00
|
|
|
#===============================================================================
|
2015-08-31 11:13:21 +07:00
|
|
|
# MPI for distributed-memory parallelism
|
2013-11-29 13:36:06 -05:00
|
|
|
#===============================================================================
|
|
|
|
|
|
2014-02-24 18:06:14 -05:00
|
|
|
set(MPI_ENABLED FALSE)
|
2015-08-31 11:13:21 +07:00
|
|
|
if($ENV{FC} MATCHES "mpi[^/]*$")
|
|
|
|
|
message("-- Detected MPI wrapper: $ENV{FC}")
|
2015-07-16 21:58:17 +04:00
|
|
|
add_definitions(-DMPI)
|
2014-02-24 18:06:14 -05:00
|
|
|
set(MPI_ENABLED TRUE)
|
2013-11-29 13:36:06 -05:00
|
|
|
endif()
|
|
|
|
|
|
2015-04-17 17:19:34 -05:00
|
|
|
# Check for Fortran 2008 MPI interface
|
|
|
|
|
if(MPI_ENABLED AND mpif08)
|
2015-07-06 14:30:29 +07:00
|
|
|
message("-- Using Fortran 2008 MPI bindings")
|
2015-04-17 17:19:34 -05:00
|
|
|
add_definitions(-DMPIF08)
|
|
|
|
|
endif()
|
|
|
|
|
|
2015-08-31 11:13:21 +07:00
|
|
|
#===============================================================================
|
|
|
|
|
# HDF5 for binary output
|
|
|
|
|
#===============================================================================
|
|
|
|
|
|
|
|
|
|
# Unfortunately FindHDF5.cmake will always prefer a serial HDF5 installation
|
|
|
|
|
# over a parallel installation if both appear on the user's PATH. To get around
|
|
|
|
|
# this, we check for the environment variable HDF5_ROOT and if it exists, use it
|
|
|
|
|
# to check whether its a parallel version.
|
|
|
|
|
|
|
|
|
|
if(DEFINED ENV{HDF5_ROOT} AND EXISTS $ENV{HDF5_ROOT}/bin/h5pcc)
|
|
|
|
|
set(HDF5_PREFER_PARALLEL TRUE)
|
|
|
|
|
else()
|
|
|
|
|
set(HDF5_PREFER_PARALLEL FALSE)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
find_package(HDF5 COMPONENTS Fortran_HL)
|
|
|
|
|
if(NOT HDF5_FOUND)
|
|
|
|
|
message(FATAL_ERROR "Could not find HDF5")
|
|
|
|
|
endif()
|
|
|
|
|
if(HDF5_IS_PARALLEL)
|
|
|
|
|
if(NOT MPI_ENABLED)
|
|
|
|
|
message(FATAL_ERROR "Parallel HDF5 must be used with MPI.")
|
|
|
|
|
endif()
|
|
|
|
|
add_definitions(-DPHDF5)
|
|
|
|
|
message("-- Using parallel HDF5")
|
|
|
|
|
endif()
|
|
|
|
|
|
2013-11-29 13:36:06 -05:00
|
|
|
#===============================================================================
|
|
|
|
|
# Set compile/link flags based on which compiler is being used
|
|
|
|
|
#===============================================================================
|
|
|
|
|
|
2015-08-29 16:32:02 +07:00
|
|
|
# Support for Fortran in FindOpenMP was added in CMake 3.1. To support lower
|
|
|
|
|
# versions, we manually add the flags. However, at some point in time, the
|
|
|
|
|
# manual logic can be removed in favor of the block below
|
|
|
|
|
|
|
|
|
|
#if(NOT (CMAKE_VERSION VERSION_LESS 3.1))
|
|
|
|
|
# if(openmp)
|
|
|
|
|
# find_package(OpenMP)
|
|
|
|
|
# if(OPENMP_FOUND)
|
|
|
|
|
# list(APPEND f90flags ${OpenMP_Fortran_FLAGS})
|
|
|
|
|
# list(APPEND ldflags ${OpenMP_Fortran_FLAGS})
|
|
|
|
|
# endif()
|
|
|
|
|
# endif()
|
|
|
|
|
#endif()
|
|
|
|
|
|
|
|
|
|
if(CMAKE_Fortran_COMPILER_ID STREQUAL GNU)
|
2015-05-13 15:41:48 +07:00
|
|
|
# Make sure version is sufficient
|
|
|
|
|
execute_process(COMMAND ${CMAKE_Fortran_COMPILER} -dumpversion
|
|
|
|
|
OUTPUT_VARIABLE GCC_VERSION)
|
2017-03-01 10:48:32 -06:00
|
|
|
if(GCC_VERSION VERSION_LESS 4.8)
|
|
|
|
|
message(FATAL_ERROR "gfortran version must be 4.8 or higher")
|
2015-05-13 15:41:48 +07:00
|
|
|
endif()
|
|
|
|
|
|
2016-02-01 12:27:51 -06:00
|
|
|
# GCC compiler options
|
2017-04-06 13:14:23 -05:00
|
|
|
list(APPEND f90flags -cpp -std=f2008 -fbacktrace -O2)
|
|
|
|
|
list(APPEND cflags -cpp -std=c99 -O2)
|
2013-11-29 13:36:06 -05:00
|
|
|
if(debug)
|
2017-04-07 12:08:10 -05:00
|
|
|
list(REMOVE_ITEM f90flags -O2)
|
|
|
|
|
list(REMOVE_ITEM cflags -O2)
|
2017-03-01 10:48:32 -06:00
|
|
|
list(APPEND f90flags -g -Wall -pedantic -fbounds-check
|
2015-08-29 16:32:02 +07:00
|
|
|
-ffpe-trap=invalid,overflow,underflow)
|
2017-03-01 10:48:32 -06:00
|
|
|
list(APPEND cflags -g -Wall -pedantic -fbounds-check)
|
2015-08-29 16:32:02 +07:00
|
|
|
list(APPEND ldflags -g)
|
2013-11-29 13:36:06 -05:00
|
|
|
endif()
|
|
|
|
|
if(profile)
|
2015-08-29 16:32:02 +07:00
|
|
|
list(APPEND f90flags -pg)
|
2016-01-15 19:30:10 -05:00
|
|
|
list(APPEND cflags -pg)
|
2015-08-29 16:32:02 +07:00
|
|
|
list(APPEND ldflags -pg)
|
2013-11-29 13:36:06 -05:00
|
|
|
endif()
|
|
|
|
|
if(optimize)
|
2017-04-06 13:14:23 -05:00
|
|
|
list(REMOVE_ITEM f90flags -O2)
|
|
|
|
|
list(REMOVE_ITEM cflags -O2)
|
2016-07-21 09:52:47 -05:00
|
|
|
list(APPEND f90flags -O3)
|
2016-02-16 13:53:12 -05:00
|
|
|
list(APPEND cflags -O3)
|
2013-11-29 13:36:06 -05:00
|
|
|
endif()
|
|
|
|
|
if(openmp)
|
2015-08-29 16:32:02 +07:00
|
|
|
list(APPEND f90flags -fopenmp)
|
2016-01-15 19:30:10 -05:00
|
|
|
list(APPEND cflags -fopenmp)
|
2015-08-29 16:32:02 +07:00
|
|
|
list(APPEND ldflags -fopenmp)
|
2013-11-29 13:36:06 -05:00
|
|
|
endif()
|
2014-03-06 16:46:19 -05:00
|
|
|
if(coverage)
|
2015-08-29 16:32:02 +07:00
|
|
|
list(APPEND f90flags -coverage)
|
2016-01-15 19:30:10 -05:00
|
|
|
list(APPEND cflags -coverage)
|
2015-08-29 16:32:02 +07:00
|
|
|
list(APPEND ldflags -coverage)
|
2014-03-06 16:46:19 -05:00
|
|
|
endif()
|
2013-11-29 13:36:06 -05:00
|
|
|
|
2015-08-29 16:32:02 +07:00
|
|
|
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL Intel)
|
2016-02-01 12:27:51 -06:00
|
|
|
# Intel compiler options
|
2015-08-29 16:32:02 +07:00
|
|
|
list(APPEND f90flags -fpp -std08 -assume byterecl -traceback)
|
2016-01-15 19:30:10 -05:00
|
|
|
list(APPEND cflags -std=c99)
|
2013-11-29 13:36:06 -05:00
|
|
|
if(debug)
|
2015-08-29 16:32:02 +07:00
|
|
|
list(APPEND f90flags -g -warn -ftrapuv -fp-stack-check
|
2017-04-07 12:08:10 -05:00
|
|
|
"-check all" -fpe0 -O0)
|
|
|
|
|
list(APPEND cflags -g -w3 -ftrapuv -fp-stack-check -O0)
|
2015-08-29 16:32:02 +07:00
|
|
|
list(APPEND ldflags -g)
|
2013-11-29 13:36:06 -05:00
|
|
|
endif()
|
|
|
|
|
if(profile)
|
2015-08-29 16:32:02 +07:00
|
|
|
list(APPEND f90flags -pg)
|
2016-01-15 19:30:10 -05:00
|
|
|
list(APPEND cflags -pg)
|
2015-08-29 16:32:02 +07:00
|
|
|
list(APPEND ldflags -pg)
|
2013-11-29 13:36:06 -05:00
|
|
|
endif()
|
|
|
|
|
if(optimize)
|
2015-08-29 16:32:02 +07:00
|
|
|
list(APPEND f90flags -O3)
|
2016-01-15 19:30:10 -05:00
|
|
|
list(APPEND cflags -O3)
|
2013-11-29 13:36:06 -05:00
|
|
|
endif()
|
|
|
|
|
if(openmp)
|
2016-07-01 13:20:47 +07:00
|
|
|
list(APPEND f90flags -qopenmp)
|
|
|
|
|
list(APPEND cflags -qopenmp)
|
|
|
|
|
list(APPEND ldflags -qopenmp)
|
2013-11-29 13:36:06 -05:00
|
|
|
endif()
|
|
|
|
|
|
2015-08-29 16:32:02 +07:00
|
|
|
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL PGI)
|
2013-11-29 13:36:06 -05:00
|
|
|
# PGI Fortran compiler options
|
2015-08-29 16:32:02 +07:00
|
|
|
list(APPEND f90flags -Mpreprocess -Minform=inform -traceback)
|
2013-11-29 13:36:06 -05:00
|
|
|
add_definitions(-DNO_F2008)
|
|
|
|
|
if(debug)
|
2015-08-29 16:32:02 +07:00
|
|
|
list(APPEND f90flags -g -Mbounds -Mchkptr -Mchkstk)
|
|
|
|
|
list(APPEND ldflags -g)
|
2013-11-29 13:36:06 -05:00
|
|
|
endif()
|
|
|
|
|
if(profile)
|
2015-08-29 16:32:02 +07:00
|
|
|
list(APPEND f90flags -pg)
|
|
|
|
|
list(APPEND ldflags -pg)
|
2013-11-29 13:36:06 -05:00
|
|
|
endif()
|
|
|
|
|
if(optimize)
|
2015-08-29 16:32:02 +07:00
|
|
|
list(APPEND f90flags -fast -Mipa)
|
2013-11-29 13:36:06 -05:00
|
|
|
endif()
|
|
|
|
|
|
2015-08-29 16:32:02 +07:00
|
|
|
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL XL)
|
2013-11-29 13:36:06 -05:00
|
|
|
# IBM XL compiler options
|
2015-08-29 16:32:02 +07:00
|
|
|
list(APPEND f90flags -O2)
|
2015-04-26 10:03:53 +00:00
|
|
|
add_definitions(-DNO_F2008)
|
2013-11-29 13:36:06 -05:00
|
|
|
if(debug)
|
2017-04-07 12:08:10 -05:00
|
|
|
list(REMOVE_ITEM f90flags -O2)
|
|
|
|
|
list(APPEND f90flags -g -C -qflag=i:i -u -O0)
|
2015-08-29 16:32:02 +07:00
|
|
|
list(APPEND ldflags -g)
|
2013-11-29 13:36:06 -05:00
|
|
|
endif()
|
|
|
|
|
if(profile)
|
2015-08-29 16:32:02 +07:00
|
|
|
list(APPEND f90flags -p)
|
|
|
|
|
list(APPEND ldflags -p)
|
2013-11-29 13:36:06 -05:00
|
|
|
endif()
|
|
|
|
|
if(optimize)
|
2017-04-06 13:14:23 -05:00
|
|
|
list(REMOVE_ITEM f90flags -O2)
|
2015-08-29 16:32:02 +07:00
|
|
|
list(APPEND f90flags -O3)
|
2013-11-29 13:36:06 -05:00
|
|
|
endif()
|
|
|
|
|
if(openmp)
|
2015-08-29 16:32:02 +07:00
|
|
|
list(APPEND f90flags -qsmp=omp)
|
|
|
|
|
list(APPEND ldflags -qsmp=omp)
|
2013-11-29 13:36:06 -05:00
|
|
|
endif()
|
|
|
|
|
|
2015-08-29 16:32:02 +07:00
|
|
|
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL Cray)
|
2013-11-29 13:36:06 -05:00
|
|
|
# Cray Fortran compiler options
|
2015-08-29 16:32:02 +07:00
|
|
|
list(APPEND f90flags -e Z -m 0)
|
2013-11-29 13:36:06 -05:00
|
|
|
if(debug)
|
2015-08-29 16:32:02 +07:00
|
|
|
list(APPEND f90flags -g -R abcnsp -O0)
|
|
|
|
|
list(APPEND ldflags -g)
|
2013-11-29 13:36:06 -05:00
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
endif()
|
|
|
|
|
|
2017-04-10 07:26:48 -05:00
|
|
|
# Show flags being used
|
|
|
|
|
message(STATUS "Fortran flags: ${f90flags}")
|
|
|
|
|
message(STATUS "C flags: ${cflags}")
|
|
|
|
|
message(STATUS "Linker flags: ${ldflags}")
|
|
|
|
|
|
2014-01-29 22:54:17 -05:00
|
|
|
#===============================================================================
|
|
|
|
|
# git SHA1 hash
|
|
|
|
|
#===============================================================================
|
|
|
|
|
|
2014-04-23 08:12:18 -07:00
|
|
|
execute_process(COMMAND git rev-parse HEAD
|
2014-01-29 22:54:17 -05:00
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
|
RESULT_VARIABLE GIT_SHA1_SUCCESS
|
|
|
|
|
OUTPUT_VARIABLE GIT_SHA1
|
|
|
|
|
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
|
|
|
if(GIT_SHA1_SUCCESS EQUAL 0)
|
2014-03-11 23:49:12 -04:00
|
|
|
add_definitions(-DGIT_SHA1="${GIT_SHA1}")
|
2014-01-29 22:54:17 -05:00
|
|
|
endif()
|
2014-08-13 19:38:44 -04:00
|
|
|
|
2013-11-29 13:36:06 -05:00
|
|
|
#===============================================================================
|
2017-02-24 15:19:31 -06:00
|
|
|
# pugixml library
|
2013-11-29 13:36:06 -05:00
|
|
|
#===============================================================================
|
|
|
|
|
|
2017-02-24 15:19:31 -06:00
|
|
|
add_library(pugixml src/pugixml/pugixml_c.cpp src/pugixml/pugixml.cpp)
|
|
|
|
|
add_library(pugixml_fortran src/pugixml/pugixml_f.F90)
|
|
|
|
|
target_link_libraries(pugixml_fortran pugixml)
|
2013-11-29 13:36:06 -05:00
|
|
|
|
2015-12-04 21:39:00 -05:00
|
|
|
#===============================================================================
|
|
|
|
|
# RPATH information
|
|
|
|
|
#===============================================================================
|
|
|
|
|
|
|
|
|
|
# add the automatically determined parts of the RPATH
|
|
|
|
|
# which point to directories outside the build tree to the install RPATH
|
|
|
|
|
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
|
|
|
|
|
2016-02-01 12:27:51 -06:00
|
|
|
#===============================================================================
|
|
|
|
|
# Build faddeeva library
|
|
|
|
|
#===============================================================================
|
|
|
|
|
|
2017-03-03 09:20:36 -06:00
|
|
|
add_library(faddeeva STATIC src/faddeeva/Faddeeva.c)
|
2016-02-01 12:27:51 -06:00
|
|
|
|
2013-11-29 13:36:06 -05:00
|
|
|
#===============================================================================
|
|
|
|
|
# Build OpenMC executable
|
|
|
|
|
#===============================================================================
|
|
|
|
|
|
|
|
|
|
set(program "openmc")
|
2017-01-16 19:58:15 -06:00
|
|
|
set(LIBOPENMC_FORTRAN_SRC
|
|
|
|
|
src/algorithm.F90
|
|
|
|
|
src/angle_distribution.F90
|
|
|
|
|
src/angleenergy_header.F90
|
|
|
|
|
src/bank_header.F90
|
|
|
|
|
src/cmfd_data.F90
|
|
|
|
|
src/cmfd_execute.F90
|
|
|
|
|
src/cmfd_header.F90
|
|
|
|
|
src/cmfd_input.F90
|
|
|
|
|
src/cmfd_loss_operator.F90
|
|
|
|
|
src/cmfd_prod_operator.F90
|
|
|
|
|
src/cmfd_solver.F90
|
|
|
|
|
src/constants.F90
|
|
|
|
|
src/cross_section.F90
|
|
|
|
|
src/dict_header.F90
|
|
|
|
|
src/distribution_multivariate.F90
|
|
|
|
|
src/distribution_univariate.F90
|
|
|
|
|
src/doppler.F90
|
|
|
|
|
src/eigenvalue.F90
|
|
|
|
|
src/endf.F90
|
|
|
|
|
src/endf_header.F90
|
|
|
|
|
src/energy_distribution.F90
|
|
|
|
|
src/energy_grid.F90
|
|
|
|
|
src/error.F90
|
|
|
|
|
src/finalize.F90
|
|
|
|
|
src/geometry.F90
|
|
|
|
|
src/geometry_header.F90
|
|
|
|
|
src/global.F90
|
|
|
|
|
src/hdf5_interface.F90
|
|
|
|
|
src/initialize.F90
|
|
|
|
|
src/input_xml.F90
|
|
|
|
|
src/list_header.F90
|
|
|
|
|
src/material_header.F90
|
|
|
|
|
src/math.F90
|
|
|
|
|
src/matrix_header.F90
|
|
|
|
|
src/mesh.F90
|
|
|
|
|
src/mesh_header.F90
|
|
|
|
|
src/message_passing.F90
|
|
|
|
|
src/mgxs_data.F90
|
|
|
|
|
src/mgxs_header.F90
|
|
|
|
|
src/multipole.F90
|
|
|
|
|
src/multipole_header.F90
|
|
|
|
|
src/nuclide_header.F90
|
|
|
|
|
src/output.F90
|
|
|
|
|
src/particle_header.F90
|
|
|
|
|
src/particle_restart.F90
|
|
|
|
|
src/particle_restart_write.F90
|
|
|
|
|
src/physics_common.F90
|
|
|
|
|
src/physics.F90
|
|
|
|
|
src/physics_mg.F90
|
|
|
|
|
src/plot.F90
|
|
|
|
|
src/plot_header.F90
|
|
|
|
|
src/product_header.F90
|
|
|
|
|
src/progress_header.F90
|
|
|
|
|
src/random_lcg.F90
|
|
|
|
|
src/reaction_header.F90
|
|
|
|
|
src/relaxng
|
|
|
|
|
src/sab_header.F90
|
|
|
|
|
src/scattdata_header.F90
|
|
|
|
|
src/secondary_correlated.F90
|
|
|
|
|
src/secondary_kalbach.F90
|
|
|
|
|
src/secondary_nbody.F90
|
|
|
|
|
src/secondary_uncorrelated.F90
|
|
|
|
|
src/set_header.F90
|
|
|
|
|
src/simulation.F90
|
|
|
|
|
src/source.F90
|
|
|
|
|
src/source_header.F90
|
|
|
|
|
src/state_point.F90
|
|
|
|
|
src/stl_vector.F90
|
|
|
|
|
src/string.F90
|
|
|
|
|
src/summary.F90
|
|
|
|
|
src/surface_header.F90
|
|
|
|
|
src/tally.F90
|
|
|
|
|
src/tally_filter.F90
|
|
|
|
|
src/tally_filter_header.F90
|
|
|
|
|
src/tally_header.F90
|
|
|
|
|
src/tally_initialize.F90
|
|
|
|
|
src/timer_header.F90
|
|
|
|
|
src/tracking.F90
|
|
|
|
|
src/track_output.F90
|
|
|
|
|
src/trigger.F90
|
|
|
|
|
src/trigger_header.F90
|
|
|
|
|
src/urr_header.F90
|
|
|
|
|
src/vector_header.F90
|
|
|
|
|
src/volume_calc.F90
|
|
|
|
|
src/volume_header.F90
|
2017-02-24 15:19:31 -06:00
|
|
|
src/xml_interface.F90)
|
2017-01-16 19:58:15 -06:00
|
|
|
add_library(libopenmc STATIC ${LIBOPENMC_FORTRAN_SRC})
|
|
|
|
|
set_target_properties(libopenmc PROPERTIES OUTPUT_NAME openmc)
|
|
|
|
|
add_executable(${program} src/main.F90)
|
2017-02-24 15:19:31 -06:00
|
|
|
set_property(TARGET ${program} libopenmc pugixml_fortran
|
|
|
|
|
PROPERTY LINKER_LANGUAGE Fortran)
|
2015-08-29 16:32:02 +07:00
|
|
|
|
2015-08-31 11:13:21 +07:00
|
|
|
# target_include_directories was added in CMake 2.8.11 and is the recommended
|
|
|
|
|
# way to set include directories. For lesser versions, we revert to set_property
|
|
|
|
|
if(CMAKE_VERSION VERSION_LESS 2.8.11)
|
|
|
|
|
include_directories(${HDF5_INCLUDE_DIRS})
|
|
|
|
|
else()
|
2017-01-16 19:58:15 -06:00
|
|
|
target_include_directories(libopenmc PUBLIC ${HDF5_INCLUDE_DIRS})
|
2015-08-31 11:13:21 +07:00
|
|
|
endif()
|
|
|
|
|
|
2015-08-29 16:32:02 +07:00
|
|
|
# target_compile_options was added in CMake 2.8.12 and is the recommended way to
|
2016-02-01 12:27:51 -06:00
|
|
|
# set compile flags. Note that this sets the COMPILE_OPTIONS property (also
|
|
|
|
|
# available only in 2.8.12+) rather than the COMPILE_FLAGS property, which is
|
|
|
|
|
# deprecated. The former can handle lists whereas the latter cannot.
|
|
|
|
|
if (CMAKE_VERSION VERSION_LESS 2.8.12)
|
2015-08-29 16:32:02 +07:00
|
|
|
string(REPLACE ";" " " f90flags "${f90flags}")
|
2016-02-01 12:27:51 -06:00
|
|
|
string(REPLACE ";" " " cflags "${cflags}")
|
|
|
|
|
set_property(TARGET ${program} PROPERTY COMPILE_FLAGS "${f90flags}")
|
|
|
|
|
set_property(TARGET faddeeva PROPERTY COMPILE_FLAGS "${cflags}")
|
|
|
|
|
else()
|
|
|
|
|
target_compile_options(${program} PUBLIC ${f90flags})
|
2017-01-16 19:58:15 -06:00
|
|
|
target_compile_options(libopenmc PUBLIC ${f90flags})
|
2016-02-01 12:27:51 -06:00
|
|
|
target_compile_options(faddeeva PRIVATE ${cflags})
|
|
|
|
|
endif()
|
2015-09-14 20:36:51 +07:00
|
|
|
|
|
|
|
|
# Add HDF5 library directories to link line with -L
|
|
|
|
|
foreach(LIBDIR ${HDF5_LIBRARY_DIRS})
|
|
|
|
|
list(APPEND ldflags "-L${LIBDIR}")
|
|
|
|
|
endforeach()
|
2015-08-29 16:32:02 +07:00
|
|
|
|
|
|
|
|
# target_link_libraries treats any arguments starting with - but not -l as
|
|
|
|
|
# linker flags. Thus, we can pass both linker flags and libraries together.
|
2017-02-24 15:19:31 -06:00
|
|
|
target_link_libraries(libopenmc ${ldflags} ${HDF5_LIBRARIES} pugixml_fortran faddeeva)
|
2017-01-16 19:58:15 -06:00
|
|
|
target_link_libraries(${program} ${ldflags} libopenmc)
|
2013-12-05 23:32:08 -05:00
|
|
|
|
|
|
|
|
#===============================================================================
|
|
|
|
|
# Install executable, scripts, manpage, license
|
|
|
|
|
#===============================================================================
|
|
|
|
|
|
|
|
|
|
install(TARGETS ${program} RUNTIME DESTINATION bin)
|
2015-05-31 15:22:30 +07:00
|
|
|
install(DIRECTORY src/relaxng DESTINATION share/openmc)
|
2015-05-22 13:43:29 +07:00
|
|
|
install(FILES man/man1/openmc.1 DESTINATION share/man/man1)
|
2015-12-04 10:38:27 -06:00
|
|
|
install(FILES LICENSE DESTINATION "share/doc/${program}" RENAME copyright)
|
2014-01-20 19:58:59 -05:00
|
|
|
|
|
|
|
|
find_package(PythonInterp)
|
|
|
|
|
if(PYTHONINTERP_FOUND)
|
2015-12-04 10:38:27 -06:00
|
|
|
if(debian)
|
|
|
|
|
install(CODE "execute_process(
|
|
|
|
|
COMMAND ${PYTHON_EXECUTABLE} setup.py install
|
|
|
|
|
--root=debian/openmc --install-layout=deb
|
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})")
|
|
|
|
|
else()
|
2016-07-19 08:45:28 -05:00
|
|
|
install(CODE "set(ENV{PYTHONPATH} \"${CMAKE_INSTALL_PREFIX}/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages\")")
|
2015-12-04 10:38:27 -06:00
|
|
|
install(CODE "execute_process(
|
|
|
|
|
COMMAND ${PYTHON_EXECUTABLE} setup.py install
|
|
|
|
|
--prefix=${CMAKE_INSTALL_PREFIX}
|
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})")
|
|
|
|
|
endif()
|
2014-02-24 17:21:48 -05:00
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
#===============================================================================
|
|
|
|
|
# Regression tests
|
|
|
|
|
#===============================================================================
|
|
|
|
|
|
2014-03-06 13:20:46 -05:00
|
|
|
# This allows for dashboard configuration
|
|
|
|
|
include(CTest)
|
2014-02-24 17:21:48 -05:00
|
|
|
|
2014-02-24 18:06:14 -05:00
|
|
|
# Get a list of all the tests to run
|
2015-05-22 13:43:29 +07:00
|
|
|
file(GLOB_RECURSE TESTS ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_*.py)
|
2014-02-24 22:52:00 -05:00
|
|
|
|
2014-02-24 18:06:14 -05:00
|
|
|
# Loop through all the tests
|
2014-02-24 17:21:48 -05:00
|
|
|
foreach(test ${TESTS})
|
2014-02-24 22:52:00 -05:00
|
|
|
# Get test information
|
|
|
|
|
get_filename_component(TEST_NAME ${test} NAME)
|
2014-08-13 19:38:44 -04:00
|
|
|
get_filename_component(TEST_PATH ${test} PATH)
|
2014-02-24 22:52:00 -05:00
|
|
|
|
2016-01-20 07:15:11 -06:00
|
|
|
if (DEFINED ENV{MEM_CHECK})
|
|
|
|
|
# Generate input files if needed
|
|
|
|
|
if (NOT EXISTS "${TEST_PATH}/geometry.xml")
|
|
|
|
|
execute_process(COMMAND ${PYTHON_EXECUTABLE} ${TEST_NAME} --build-inputs
|
|
|
|
|
WORKING_DIRECTORY ${TEST_PATH})
|
|
|
|
|
endif()
|
2014-02-24 18:06:14 -05:00
|
|
|
|
2016-01-20 07:15:11 -06:00
|
|
|
# Add serial test
|
2016-01-19 10:37:25 -06:00
|
|
|
add_test(NAME ${TEST_NAME}
|
|
|
|
|
WORKING_DIRECTORY ${TEST_PATH}
|
2016-01-20 07:15:11 -06:00
|
|
|
COMMAND $<TARGET_FILE:openmc>)
|
2016-01-19 08:39:36 -06:00
|
|
|
else()
|
2014-03-06 15:23:18 -05:00
|
|
|
# Check serial/parallel
|
|
|
|
|
if (${MPI_ENABLED})
|
|
|
|
|
# Preform a parallel test
|
2014-08-13 19:38:44 -04:00
|
|
|
add_test(NAME ${TEST_NAME}
|
|
|
|
|
WORKING_DIRECTORY ${TEST_PATH}
|
2014-03-06 15:23:18 -05:00
|
|
|
COMMAND ${PYTHON_EXECUTABLE} ${TEST_NAME} --exe $<TARGET_FILE:openmc>
|
|
|
|
|
--mpi_exec $ENV{MPI_DIR}/bin/mpiexec)
|
2016-01-20 07:15:11 -06:00
|
|
|
else()
|
2014-03-06 15:23:18 -05:00
|
|
|
# Perform a serial test
|
2014-08-13 19:38:44 -04:00
|
|
|
add_test(NAME ${TEST_NAME}
|
2014-03-06 15:23:18 -05:00
|
|
|
WORKING_DIRECTORY ${TEST_PATH}
|
|
|
|
|
COMMAND ${PYTHON_EXECUTABLE} ${TEST_NAME} --exe $<TARGET_FILE:openmc>)
|
2016-01-20 07:15:11 -06:00
|
|
|
endif()
|
2016-01-19 08:39:36 -06:00
|
|
|
endif()
|
2014-02-24 17:21:48 -05:00
|
|
|
endforeach(test)
|