-
Notifications
You must be signed in to change notification settings - Fork 247
/
CMakeLists.txt
126 lines (100 loc) · 6.01 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
set(CMAKE_INCLUDE_CURRENT_DIR ON)
message("**** Configuring KratosTrilinosApplication ****")
include(pybind11Tools)
if(${TRILINOS_EXCLUDE_ML_SOLVER} MATCHES ON)
add_definitions(-DTRILINOS_EXCLUDE_ML_SOLVER)
message("**** WARNING: Manually disabled ML-Solver ****")
endif(${TRILINOS_EXCLUDE_ML_SOLVER} MATCHES ON)
if(${TRILINOS_EXCLUDE_AZTEC_SOLVER} MATCHES ON)
add_definitions(-DTRILINOS_EXCLUDE_AZTEC_SOLVER)
message("**** WARNING: Manually disabled Aztec-Solver ****")
endif(${TRILINOS_EXCLUDE_AZTEC_SOLVER} MATCHES ON)
if(${TRILINOS_EXCLUDE_AMESOS_SOLVER} MATCHES ON)
add_definitions(-DTRILINOS_EXCLUDE_AMESOS_SOLVER)
message("**** WARNING: Manually disabled Amesos-Solver ****")
endif(${TRILINOS_EXCLUDE_AMESOS_SOLVER} MATCHES ON)
include_directories( ${KRATOS_SOURCE_DIR}/kratos )
# Find trilinos solver package -- this is our own find package!!
IF(NOT TRILINOS_FOUND)
MESSAGE( FATAL_ERROR "Could not find Trilinos or one of its packages. Please set the cmake var TRILINOS_ROOT or the environment vars TRILINOS_INCLUDE_DIR and TRILINOS_LIBRARY_DIR, note also that if in your system the library have a prefix, like \"libtrilinos_epetra.so\" instead of \"libepetra.so\" you can specify the prefix by the variable -DTRILINOS_LIBRARY_PREFIX=\"trilinos_\" " )
ENDIF(NOT TRILINOS_FOUND)
# Amesos2 is currenlty under development and is disabled by default. This can be removed in the future to enable it by default.
OPTION ( TRILINOS_EXCLUDE_AMESOS2_SOLVER "Exclude Amesos2 Solver" ON )
if(${TRILINOS_EXCLUDE_AMESOS2_SOLVER} MATCHES ON)
add_definitions(-DTRILINOS_EXCLUDE_AMESOS2_SOLVER)
message("**** WARNING: Manually disabled Amesos2-Solver ****")
elseif(NOT HAVE_AMESOS2)
add_definitions(-DTRILINOS_EXCLUDE_AMESOS2_SOLVER)
message("**** WARNING: Amesos2-Solver could not be found and will be disabled ****")
endif(${TRILINOS_EXCLUDE_AMESOS2_SOLVER} MATCHES ON)
# Including the amgcl, which is header only
include_directories("../../external_libraries")
# CHecking MPI is included
IF (NOT ${USE_MPI} OR NOT DEFINED USE_MPI)
MESSAGE(FATAL_ERROR "TrilinosApplication requires MPI, please ser ON USE_MPI")
ENDIF (NOT ${USE_MPI} OR NOT DEFINED USE_MPI)
# Sources for the Trilinos application core
file(GLOB_RECURSE KRATOS_TRILINOS_APPLICATION_CORE_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/trilinos_application.cpp
${CMAKE_CURRENT_SOURCE_DIR}/external_includes/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/custom_processes/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/custom_factories/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/custom_utilities/*.cpp
)
# Sources for the Python module
file(GLOB_RECURSE KRATOS_TRILINOS_PYTHON_INTERFACE_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/custom_python/*.cpp
)
## Kratos tests sources. Enabled by default
if(${KRATOS_BUILD_TESTING} MATCHES ON)
file(GLOB_RECURSE KRATOS_TRILINOS_TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/tests/cpp_tests/*.cpp)
kratos_add_gtests(TARGET KratosTrilinosCore SOURCES "${KRATOS_TRILINOS_TEST_SOURCES}" USE_MPI)
endif(${KRATOS_BUILD_TESTING} MATCHES ON)
# ###############################################################
## TrilinosApplication core library (C++ parts)
add_library( KratosTrilinosCore SHARED ${KRATOS_TRILINOS_APPLICATION_CORE_SOURCES} )
target_link_libraries(KratosTrilinosCore PUBLIC KratosCore KratosMPICore ${TRILINOS_LIBRARIES} )
set_target_properties( KratosTrilinosCore PROPERTIES COMPILE_DEFINITIONS "TRILINOS_APPLICATION=EXPORT,API")
target_include_directories(KratosTrilinosCore SYSTEM PUBLIC ${TRILINOS_INCLUDE_DIR})
## TrilinosApplication python module
pybind11_add_module( KratosTrilinosApplication MODULE THIN_LTO ${KRATOS_TRILINOS_PYTHON_INTERFACE_SOURCES} )
target_link_libraries( KratosTrilinosApplication PRIVATE KratosTrilinosCore)
set_target_properties( KratosTrilinosApplication PROPERTIES PREFIX "")
# Set batch size in the unity build
IF(CMAKE_UNITY_BUILD MATCHES ON)
set_target_properties(KratosTrilinosCore PROPERTIES UNITY_BUILD_BATCH_SIZE ${KRATOS_UNITY_BUILD_BATCH_SIZE})
set_target_properties(KratosTrilinosApplication PROPERTIES UNITY_BUILD_BATCH_SIZE ${KRATOS_UNITY_BUILD_BATCH_SIZE})
ENDIF(CMAKE_UNITY_BUILD MATCHES ON)
# Changing the .dll suffix to .pyd
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set_target_properties(KratosTrilinosApplication PROPERTIES SUFFIX .pyd)
endif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
# Changing the .dylib suffix to .so
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set_target_properties(KratosTrilinosApplication PROPERTIES SUFFIX .so)
endif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# Add to the KratosMultiphisics Python module
kratos_python_install(${INSTALL_PYTHON_USING_LINKS} ${CMAKE_CURRENT_SOURCE_DIR}/TrilinosApplication.py KratosMultiphysics/TrilinosApplication/__init__.py )
# Install python files
get_filename_component (CURRENT_DIR_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME)
kratos_python_install_directory(${INSTALL_PYTHON_USING_LINKS} ${CMAKE_CURRENT_SOURCE_DIR}/python_scripts KratosMultiphysics/${CURRENT_DIR_NAME} )
# TODO: Move this to the new system. Not sure how it will work on windows but being Trilinos should give no problem.
message(STATUS "Trilinos libs to be installed: " ${TRILINOS_LIBRARIES})
install(FILES ${TRILINOS_LIBRARIES} DESTINATION libs )
# Kratos Testing. Install everything except sources to ensure that reference and configuration files are copied.
if(${INSTALL_TESTING_FILES} MATCHES ON )
get_filename_component (CURRENT_DIR_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tests DESTINATION applications/${CURRENT_DIR_NAME}
PATTERN "*.git" EXCLUDE
PATTERN "*.c" EXCLUDE
PATTERN "*.h" EXCLUDE
PATTERN "*.cpp" EXCLUDE
PATTERN "*.hpp" EXCLUDE
)
endif(${INSTALL_TESTING_FILES} MATCHES ON)
## Install targets
install(TARGETS KratosTrilinosCore DESTINATION libs )
install(TARGETS KratosTrilinosApplication DESTINATION libs )
# Define custom targets
set(KRATOS_KERNEL "${KRATOS_KERNEL};KratosTrilinosCore" PARENT_SCOPE)
set(KRATOS_PYTHON_INTERFACE "${KRATOS_PYTHON_INTERFACE};KratosTrilinosApplication" PARENT_SCOPE)