-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathCMakeLists.txt
132 lines (117 loc) · 4.54 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
126
127
128
129
130
131
132
cmake_minimum_required(VERSION 3.10)
# Options
option(MDI_CXX "Build with CXX suport - ON (DEFAULT) or OFF)" ON)
option(MDI_Fortran "Build with Fortran support - ON (DEFAULT) or OFF)" ON)
option(MDI_Python "Build with Python support - ON (DEFAULT) or OFF)" ON)
option(MDI_Python_PACKAGE "Flag to install MDI as a Python package" OFF)
option(MDI_PLUGINS "Flag to compile with support for MDI plugins" ON)
option(MDI_Python_PLUGINS "Flag to compile with support for MDI Python plugins" ${MDI_PLUGINS})
option(MDI_TEST_CODES "Flag to compile MDI test codes" OFF)
option(MDI_TEST_DRIVERS "Flag to compile MDI test drivers" ${MDI_TEST_CODES})
option(MDI_TEST_ENGINES "Flag to compile MDI test engines" ${MDI_TEST_CODES})
option(MDI_DEBUG "Flag to compile MDI in debug mode" OFF)
set(MDI_USE_MPI "" CACHE STRING "Flag to use MPI - ON or OFF")
set(MDI_Python_VERSION "OFF" CACHE STRING "When linking against a build of Python, MDI will attempt to link against a build of Python corresponding to this version number.")
# Deprecated Options
option(language "Deprecated; use MDI_CXX, MDI_Fortran, and/or MDI_Python instead.")
option(libtype "Deprecated; use BUILD_SHARED_LIBS instead.")
set(mpi ${MDI_USE_MPI} CACHE STRING "Deprecated; use MDI_USE_MPI instead.")
set(python_package ${MDI_Python_PACKAGE} CACHE STRING "Deprecated; use MDI_Python_PACKAGE instead.")
set(plugins "" CACHE STRING "Deprecated; use MDI_PLUGINS instead.")
if ( plugins STREQUAL "" )
set(plugins ${MDI_PLUGINS})
else()
set(MDI_PLUGINS ${plugins})
set(MDI_Python_PLUGINS ${plugins})
endif()
set(python_plugins ${MDI_Python_PLUGINS} CACHE STRING "Deprecated; use MDI_Python_PLUGINS instead.")
set(python_version ${MDI_Python_VERSION} CACHE STRING "Deprecated; use MDI_Python_VERSION instead.")
set(test_codes "" CACHE STRING "Deprecated; use MDI_TEST_CODES instead.")
if( test_codes STREQUAL "" )
set(test_codes ${MDI_TEST_CODES})
else()
set(MDI_TEST_CODES ${test_codes})
set(MDI_TEST_DRIVERS ${test_codes})
set(MDI_TEST_ENGINES ${test_codes})
endif()
set(test_drivers ${MDI_TEST_DRIVERS} CACHE STRING "Deprecated; use MDI_TEST_DRIVERS instead.")
set(test_engines ${MDI_TEST_ENGINES} CACHE STRING "Deprecated; use MDI_TEST_ENGINES instead.")
set(debug ${MDI_DEBUG} CACHE STRING "Deprecated; use MDI_DEBUG instead.")
set(use_C "")
set(use_CXX "")
set(use_Fortran "")
set(use_Python "")
if( NOT language )
# By default, compile for all languages
set(use_C "C")
if( MDI_CXX )
set(use_CXX "CXX")
endif()
if( MDI_Fortran )
set(use_Fortran "Fortran")
endif()
if( MDI_Python )
set(use_Python "Python")
endif()
elseif( language STREQUAL "C" )
set(use_C "C")
elseif( language STREQUAL "CXX" )
set(use_C "C")
set(use_CXX "CXX")
elseif( language STREQUAL "Fortran" )
set(use_C "C")
set(use_Fortran "Fortran")
elseif( language STREQUAL "Python" )
set(use_C "C")
set(use_Python "Python")
else()
message( FATAL_ERROR "Language not supported. Supported languages: C, CXX, Fortran, Python" )
endif()
project(mdi
VERSION 1.4.36
LANGUAGES ${use_C} ${use_CXX} ${use_Fortran})
# Check for MPI
if ( mpi STREQUAL "ON" )
find_package(MPI REQUIRED)
elseif( NOT ( mpi STREQUAL "OFF") )
find_package(MPI)
if ( MPI_FOUND )
set( mpi "ON" )
else()
set( mpi "OFF" )
endif()
endif()
# Set a definition to enable MDI debug mode
if( ${debug} )
add_definitions(-D_MDI_DEBUG=1)
else()
add_definitions(-D_MDI_DEBUG=0)
endif()
# Check for Python developement libraries, which are used for Python plugins
if( python_plugins )
# Attempt to find a valid development version of Python
if( python_version )
# Find this specific Python version
find_package(Python ${python_version} EXACT COMPONENTS Interpreter Development)
else()
# Find the latest Python version
find_package(Python COMPONENTS Interpreter Development)
endif()
# Python plugins do not currently support PyPy
if(Python_Development_FOUND AND "${Python_INTERPRETER_ID}" STREQUAL "PyPy")
message( WARNING "Python Plugins are not currently supported for PyPy. Disabling Python Plugins." )
set(Python_Development_FOUND off)
endif()
# Python plugins do not currently support PyPy
if(Python_Development_FOUND AND WIN32)
message( WARNING "Python Plugins are not currently supported on Windows. Disabling Python Plugins." )
set(Python_Development_FOUND off)
endif()
else()
message( WARNING "Python Plugins have been disabled." )
endif()
add_subdirectory(MDI_Library)
# compile test codes
if ( test_codes )
add_subdirectory(tests)
endif()