xref: /phasta/CMakeLists.txt (revision e85dd27f78178cea4be54ab557d502f6f4401775)
1CMAKE_MINIMUM_REQUIRED(VERSION 2.8.5)
2#SET(CMAKE_FORTRAN_COMPILER gfortran gfortran)
3PROJECT(PHASTA Fortran C CXX )
4enable_language(Fortran)
5enable_language(C)
6enable_language(CXX)
7
8enable_testing()
9include(CTest)
10set(MPIRUN "mpirun"
11  CACHE string
12  "the mpirun or srun executable")
13set(MPIRUN_PROCFLAG "-np"
14  CACHE string
15  "the command line flag to give process count to MPIRUN")
16
17list(APPEND CMAKE_MODULE_PATH ${PHASTA_SOURCE_DIR}/CMakeFiles)
18
19#Handle Fortran name mangling
20include(FortranCInterface)
21FortranCInterface_VERIFY(CXX)
22FortranCInterface_Header(FCMangle.h SYMBOLS write_restart write_error write_displ write_field write_hessian)
23include_directories("${PHASTA_BINARY_DIR}")
24
25# Force static linking
26IF(CMAKE_SYSTEM_NAME MATCHES BlueGeneQ-static)
27  SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
28ENDIF(CMAKE_SYSTEM_NAME MATCHES BlueGeneQ-static)
29
30#MESSAGE(ERROR ${CMAKE_Fortran_SOURCE_FILE_EXTENSIONS})
31#SET(CMAKE_Fortran_SOURCE_FILE_EXTENSIONS f90 f F90 F)
32# stuff for C/C++ calls to Fortran -- still needs to be done properly...
33IF(CMAKE_Fortran_COMPILER_ID MATCHES GNU)
34  SET(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ffixed-form -ffixed-line-length-132 -cpp " )
35ENDIF(CMAKE_Fortran_COMPILER_ID MATCHES GNU)
36
37IF(CMAKE_Fortran_COMPILER_ID MATCHES Intel)
38
39SET(CMAKE_Fortran_FLAGS "-W0 -132 -fixed -fpp ${CMAKE_Fortran_FLAGS}" )
40if((CMAKE_BUILD_TYPE MATCHES "Release") OR
41	(CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo"))
42	set(CMAKE_Fortran_FLAGS "-O3 -ip ${CMAKE_Fortran_FLAGS}" )
43endif()
44message(STATUS "Found ifort")
45message(STATUS ${CMAKE_Fortran_FLAGS})
46ENDIF(CMAKE_Fortran_COMPILER_ID MATCHES Intel)
47
48if(CMAKE_Fortran_COMPILER_ID MATCHES PGI)
49	set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -Mextend")
50endif(CMAKE_Fortran_COMPILER_ID MATCHES PGI)
51
52if(CMAKE_Fortran_COMPILER_ID MATCHES XL)
53	#set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -qstrict -qnullterm -qfixed=132")
54	set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -qnullterm -qfixed=132")
55endif(CMAKE_Fortran_COMPILER_ID MATCHES XL)
56
57IF(${CMAKE_BUILD_TYPE} MATCHES "Debug" )
58  ADD_DEFINITIONS( -DDEBUG )
59ENDIF(${CMAKE_BUILD_TYPE} MATCHES "Debug" )
60
61# set archos "like" options for things like c calling fortran bindings
62# later on we may want to do it dependent on behavior (e.g.
63# C_FORTRAN_CALL == uppercase, underline, nochange)
64#OPTION(ARCHOS_OPTION "ArchOS dependent defines (e.g. -DLINUX)" )
65SET(ARCHOS_OPTION "-DLINUX" CACHE STRING "ArchOS dependent defines (e.g. -DLINUX)" )
66ADD_DEFINITIONS( ${ARCHOS_OPTION} )
67
68
69SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY
70  ${PHASTA_BINARY_DIR}/lib)
71
72SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY
73  ${PHASTA_BINARY_DIR}/bin)
74
75OPTION(PHASTA_USE_MPI "Build MPI components" ON)
76IF(PHASTA_USE_MPI)
77  ADD_DEFINITIONS( -DPARALLEL -DMPICH_SKIP_MPICXX -DOMPI_SKIP_MPICXX )
78  option(PHASTA_SKIP_MPI_CHECK "Bypass CMake MPI code. Don't use this" OFF)
79  mark_as_advanced(FORCE PHASTA_SKIP_MPI_CHECK)
80  if(NOT PHASTA_SKIP_MPI_CHECK)
81  FIND_PACKAGE(MPI REQUIRED)
82  endif()
83#  SET(CMAKE_MODULE_PATH ${PHASTA_SOURCE_DIR}/CMakeFiles)
84  # bug in FIND_PACKAGE for Threads -- ignore for now (bug has been reported)...
85  FIND_PACKAGE(Threads)
86  IF(Threads_FOUND)
87    INCLUDE(FindThreads)
88  ENDIF(Threads_FOUND)
89ENDIF(PHASTA_USE_MPI)
90
91OPTION(PHASTA_BUILD_PHASTAIO "Build PhastaIO" ON)
92if(PHASTA_BUILD_PHASTAIO)
93	add_subdirectory(phastaIO)
94	list(APPEND PHASTA_INCLUDES "${PHASTA_SOURCE_DIR}/phastaIO")
95endif(PHASTA_BUILD_PHASTAIO)
96
97OPTION(PHASTA_BUILD_SHAPEFUNCTION "Build shapeFunction" ON)
98if(PHASTA_BUILD_SHAPEFUNCTION)
99	list(APPEND PHASTA_INCLUDES "${PHASTA_SOURCE_DIR}/shapeFunction/src")
100	add_subdirectory(shapeFunction)
101endif(PHASTA_BUILD_SHAPEFUNCTION)
102
103if(EXISTS ${PHASTA_SOURCE_DIR}/phShape)
104OPTION(PHASTA_BUILD_PHSHAPE "Build phShape" OFF)
105if(PHASTA_BUILD_PHSHAPE)
106	list(APPEND PHASTA_INCLUDES "${PHASTA_SOURCE_DIR}/phShape/src")
107	add_subdirectory(phShape)
108endif(PHASTA_BUILD_PHSHAPE)
109endif(EXISTS ${PHASTA_SOURCE_DIR}/phShape)
110
111OPTION(PHASTA_USE_SVLS "Build svLS Linear Solver" OFF)
112if(PHASTA_USE_SVLS)
113	message(WARNING "\
114svLS has a non-commercial license. \n \
115by activating PHASTA_USE_SVLS in cmake \n \
116you agree to the terms outlined in \
117svLS/license.txt"
118	)
119	list(APPEND PHASTA_INCLUDES "${PHASTA_SOURCE_DIR}/svLS")
120	add_subdirectory(svLS)
121endif(PHASTA_USE_SVLS)
122
123OPTION(PHASTA_BUILD_SOLVERS "Build Solvers" ON)
124if(PHASTA_BUILD_SOLVERS)
125	set(PHASTA_BUILD_PHASTAIO ON)
126	if(PHASTA_USE_MPI)
127		set(PHASTA_BUILD_METIS ON)
128	endif(PHASTA_USE_MPI)
129	list(APPEND PHASTA_INCLUDES "${PHASTA_SOURCE_DIR}/phSolver/common")
130	include_directories(${PHASTA_INCLUDES})
131	add_subdirectory(phSolver)
132#TODO
133endif(PHASTA_BUILD_SOLVERS)
134
135OPTION(PHASTA_BUILD_CONVERTERIO "Build IO converter" ON)
136if(PHASTA_BUILD_CONVERTERIO)
137	add_subdirectory(converterIO)
138endif(PHASTA_BUILD_CONVERTERIO)
139
140OPTION(PHASTA_BUILD_ACUSTAT "Build AcuStat" ON)
141if(PHASTA_BUILD_ACUSTAT)
142	add_subdirectory(AcuStat)
143endif(PHASTA_BUILD_ACUSTAT)
144
145OPTION(PHASTA_BUILD_M2N "Build M2N" ON)
146if(PHASTA_BUILD_M2N)
147	add_subdirectory(M2N)
148endif(PHASTA_BUILD_M2N)
149
150OPTION(PHASTA_BUILD_M2NFixBnd "Build M2NFixBnd" ON)
151if(PHASTA_BUILD_M2NFixBnd)
152	add_subdirectory(M2NFixBnd)
153endif(PHASTA_BUILD_M2NFixBnd)
154
155if(EXISTS ${PHASTA_SOURCE_DIR}/phNSpre)
156	add_subdirectory(phNSpre)
157endif(EXISTS ${PHASTA_SOURCE_DIR}/phNSpre)
158
159add_subdirectory(checkphasta)
160
161