-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathCMakeLists.txt
126 lines (111 loc) · 4.86 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# cmake file for the cross-platform configure of the
# software package SPECFEM3D_GEOTECH
# AUTHOR
# Hom Nath Gharti
# REVISION:
# HNG, Apr,2017; HNG, Sep 06,2011;
# required cmake version
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.4 FATAL_ERROR)
# define project
PROJECT(semgeotech Fortran C)
# Disallow in-source build
IF("${semgeotech_SOURCE_DIR}" STREQUAL "${semgeotech_BINARY_DIR}")
MESSAGE(FATAL_ERROR "SPECFEM3D_GEOTECH requires an out-of-source build. \
Please create a separate binary directory and run CMake there.")
ENDIF("${semgeotech_SOURCE_DIR}" STREQUAL "${semgeotech_BINARY_DIR}")
# Test Fortran compiler
TRY_COMPILE(TEST_F90 ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/src/testf90.f90)
IF(NOT TEST_F90)
MESSAGE(FATAL_ERROR "Fortran compiler: ${CMAKE_Fortran_COMPILER} doesn't \
work! Please set working CMAKE_Fortran_COMPILER!")
ENDIF(NOT TEST_F90)
# build directories
SET(BDIR ${CMAKE_BINARY_DIR}/bin)
SET(DDIR ${CMAKE_BINARY_DIR}/doc)
SET(IDIR ${CMAKE_BINARY_DIR}/input)
SET(LDIR ${CMAKE_BINARY_DIR}/lib)
SET(ODIR ${CMAKE_BINARY_DIR}/output)
SET(PDIR ${CMAKE_BINARY_DIR}/partition)
SET(SDIR ${CMAKE_SOURCE_DIR})
FILE(MAKE_DIRECTORY ${BDIR})
#FILE(MAKE_DIRECTORY ${DDIR})
FILE(MAKE_DIRECTORY ${IDIR})
FILE(MAKE_DIRECTORY ${ODIR})
FILE(MAKE_DIRECTORY ${PDIR})
# set paths to executable and libraries
SET(EXECUTABLE_OUTPUT_PATH ${BDIR})
SET(LIBRARY_OUTPUT_PATH ${LDIR})
# set internal default logical variables
SET(ISDOCUMENTATION OFF)
SET(ISPARTMESH OFF)
SET(ISPARALLEL OFF)
# build documentation option
SET(BUILD_DOCUMENTATION OFF CACHE BOOL "Build documentation for
SPECFEM3D_GEOTECH")
IF(BUILD_DOCUMENTATION)
SET(ISDOCUMENTATION ON)
FIND_PACKAGE(LATEX REQUIRED)
IF(NOT PDFLATEX_COMPILER OR NOT BIBTEX_COMPILER)
MESSAGE(WARNING "LaTeX compiler/s not found! DOCUMENTATION cannot be \
built!")
SET(ISDOCUMENTATION OFF)
ENDIF(NOT PDFLATEX_COMPILER OR NOT BIBTEX_COMPILER)
ENDIF(BUILD_DOCUMENTATION)
#SET(BUILD_SLOPE ON CACHE BOOL "Build slope stability program")
#SET(BUILD_EXCAVATION ON CACHE BOOL "Build excavation program")
# build partmesh option
SET(BUILD_PARTMESH OFF CACHE BOOL "Build mesh partitioning program")
IF(BUILD_PARTMESH)
SET(ISPARTMESH ON)
# find library
FIND_PATH(SCOTCH_LIBRARY_PATH NAMES libscotch.a libscotcherr.a
PATHS /usr/lib /usr/local/lib ENV LD_LIBRARY_PATH)
IF(NOT SCOTCH_LIBRARY_PATH)
MESSAGE(WARNING "SCOTCH library not found! Please set correct \
SCOTCH_LIBRARY_PATH manually!")
SET(ISPARTMESH OFF)
ENDIF(NOT SCOTCH_LIBRARY_PATH)
# find include
FIND_PATH(SCOTCH_INCLUDE_PATH NAMES scotch.h ptscotch.h
PATHS /usr/include /usr/local/include ENV LD_INCLUDE_PATH)
IF(NOT SCOTCH_INCLUDE_PATH)
MESSAGE(WARNING "SCOTCH include not found! Please set correct \
SCOTCH_INCLUDE_PATH manually!")
SET(ISPARTMESH OFF)
ENDIF(NOT SCOTCH_INCLUDE_PATH)
ENDIF(BUILD_PARTMESH)
SET(BUILD_EXODUS2SEMGEOTECH OFF CACHE BOOL "Build exodus2semgeotech program")
SET(BUILD_GID2SEMGEOTECH OFF CACHE BOOL "Build gid2semgeotech program")
SET(BUILD_WRITE_SOS OFF CACHE BOOL "Build write_sos program")
# MPI for parallel processing
SET(ENABLE_MPI OFF CACHE BOOL "Build semgeotech with MPI support")
IF(ENABLE_MPI)
SET(ISPARALLEL ON)
FIND_PACKAGE(MPI COMPONENTS Fortran REQUIRED)
IF(NOT MPI_FOUND)
MESSAGE(WARNING "MPI Fortran compiler not found! Parallel semgeotech \
cannot be built!")
SET(ISPARALLEL OFF)
ENDIF(NOT MPI_FOUND)
# Test MPI Fortran compiler
#include_directories(${MPI_Fortran_INCLUDE_PATH})
TRY_COMPILE(TEST_MPI ${CMAKE_BINARY_DIR}/CMakeTmp
${CMAKE_SOURCE_DIR}/src/testmpi.f90
#COMPILE_DEFINITIONS ${MPI_Fortran_LINK_FLAGS}
#CMAKE_FLAGS "-DINCLUDE_DIRECTORIES=${MPI_Fortran_INCLUDE_PATH}"
#"-DLINK_LIBRARIES=${MPI_Fortran_LIBRARIES}"
LINK_LIBRARIES ${MPI_Fortran_LIBRARIES}
OUTPUT_VARIABLE test)
IF(NOT TEST_MPI)
MESSAGE(WARNING "MPI Fortran compiler: ${MPI_Fortran_COMPILER} doesn't \
work! Parallel semgeotech cannot be built!")
SET(ISPARALLEL OFF)
ENDIF(NOT TEST_MPI)
INCLUDE_DIRECTORIES(${MPI_Fortran_INCLUDE_DIRS})
ENDIF(ENABLE_MPI)
# process CMakeLists.txt in other subdirectories
ADD_SUBDIRECTORY(doc)
ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(util)
# notes
#SET_SOURCE_FILES_PROPERTIES(${SRC} PROPERTIES LANGUAGE "C")