Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add shared library option #4

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 49 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,25 @@ cmake_minimum_required(VERSION 2.8.12)
# not every version of CMAKE uses the new version of policy CMP0057
# this enforces it since Kokkos assumes the new version of the policy
CMAKE_POLICY(SET CMP0057 NEW)
CMAKE_POLICY(SET CMP0048 NEW)

ENABLE_TESTING()

SET(TRILINOS_DIR ${Trilinos_INSTALL_DIR})
SET(Trilinos_SRC_DIR ${Trilinos_SRC_DIR})
option(MrHyDE_BUILD_SHARED_LIBS "Build MrHyDE with shared libraries." ON)

set(CMAKE_PREFIX_PATH ${TRILINOS_DIR} ${CMAKE_PREFIX_PATH})

#PROJECT(mrhyde)
project(mrhyde
LANGUAGES NONE # Defined below after reading in compilers
VERSION 0.1.0
)

# the RPATH to be used when installing, but only if it's not a system directory
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX/lib}" isSystemDir)

find_package(Trilinos REQUIRED)

IF(NOT Trilinos_FOUND)
Expand All @@ -43,6 +49,7 @@ IF(Trilinos_VERSION LESS 14.0) # GH: if a version is not detected, CMake default
ELSE()
MESSAGE(" Trilinos_VERSION >= 14 detected, using new names for Tpetra::KokkosCompat objects")
ADD_DEFINITIONS(-DMrHyDE_HAVE_TRILINOS14)
set(MrHyDE_HAVE_TRILINOS14 TRUE)
ENDIF()
MESSAGE("End of Trilinos details\n")

Expand Down Expand Up @@ -257,7 +264,48 @@ ENDIF()
IF(MrHyDE_ENABLE_UNIT_TESTS)
ADD_SUBDIRECTORY(unit_tests)
ENDIF()


IF(MrHyDE_BUILD_SHARED_LIBS)

# Add necessary definitions here
IF(MrHyDE_HAVE_TRILINOS14)
target_compile_definitions(mrhyde_lib PUBLIC MrHyDE_HAVE_TRILINOS14)
ENDIF()


# Install the shared library object targets
install(TARGETS mrhyde_lib
EXPORT MrHyDETargets
DESTINATION lib)

# Configure the CMake packaging
include(CMakePackageConfigHelpers)
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/MrHyDEConfig.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/MrHyDEcmake"
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)

write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/MrHyDEConfigVersion.cmake"
VERSION "${PROJECT_VERSION}"
COMPATIBILITY SameMajorVersion
)

install(FILES
${CMAKE_CURRENT_BINARY_DIR}/MrHyDEConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/MrHyDEConfigVersion.cmake
DESTINATION lib/cmake/MrHyDE
)

export(TARGETS mrhyde_lib NAMESPACE MrHyDE:: FILE MrHyDETargets.cmake)
export(PACKAGE MrHyDE)

# Install the cmake configuration
install(EXPORT MrHyDETargets NAMESPACE MrHyDE:: DESTINATION lib/cmake/MrHyDE)
ENDIF()

#INSTALL(
# DIRECTORY ""
# DESTINATION ""
Expand Down
6 changes: 6 additions & 0 deletions Config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@PACKAGE_INIT@

include(CMakeFindDependencyMacro)
find_dependency(Trilinos REQUIRED)

include ( "${CMAKE_CURRENT_LIST_DIR}/MrHyDETargets.cmake" )
14 changes: 13 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,21 @@ ENDIF()
ADD_EXECUTABLE(mrhyde
${mrhyde-all}
)

TARGET_LINK_LIBRARIES(mrhyde ${Trilinos_LIBRARIES} ${Trilinos_TPL_LIBRARIES})

IF(MrHyDE_BUILD_SHARED_LIBS)
add_library(mrhyde_lib SHARED
${mrhyde-all}
)
target_include_directories(mrhyde_lib PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>
)
target_link_libraries(mrhyde_lib ${Trilinos_LIBRARIES} ${Trilinos_TPL_LIBRARIES})
install(TARGETS mrhyde_lib DESTINATION lib/)
install(DIRECTORY . DESTINATION include/ FILES_MATCHING PATTERN "*.hpp")
ENDIF()

IF(MrHyDE_ENABLE_XML_to_YAML)
ADD_EXECUTABLE(xml_to_yaml
../scripts/utils/xml_to_yaml.cpp)
Expand Down
4 changes: 2 additions & 2 deletions src/interfaces/discretizationInterface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
#include "Panzer_STK_Interface.hpp"
#include "physicsInterface.hpp"
#include "meshInterface.hpp"
#include "groupMetaData.hpp"
#include "MrHyDE_Debugger.hpp"
#include "tools/groupMetaData.hpp"
#include "tools/MrHyDE_Debugger.hpp"

namespace MrHyDE {

Expand Down
4 changes: 2 additions & 2 deletions src/interfaces/linearAlgebraInterface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#include "trilinos.hpp"
#include "preferences.hpp"
#include "discretizationInterface.hpp"
#include "parameterManager.hpp"
#include "MrHyDE_Debugger.hpp"
#include "managers/parameterManager.hpp"
#include "tools/MrHyDE_Debugger.hpp"

// Belos
#include <BelosConfigDefs.hpp>
Expand Down
6 changes: 3 additions & 3 deletions src/interfaces/meshInterface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
#include "Panzer_STK_Interface.hpp"
#include "Panzer_STK_ExodusReaderFactory.hpp"
#include "Panzer_STKConnManager.hpp"
#include "simplemeshmanager.hpp"
#include "MrHyDE_Debugger.hpp"
#include "tools/simplemeshmanager.hpp"
#include "tools/MrHyDE_Debugger.hpp"

#include "preferences.hpp"
//#include "physicsInterface.hpp"
//#include "group.hpp"
#include "data.hpp"
#include "tools/data.hpp"
//#include "boundaryGroup.hpp"

namespace MrHyDE {
Expand Down
4 changes: 2 additions & 2 deletions src/interfaces/physicsInterface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
#include "preferences.hpp"
#include "MrHyDE_Debugger.hpp"

#include "physicsBase.hpp"
#include "workset.hpp"
#include "physics/physicsBase.hpp"
#include "tools/workset.hpp"

//#include "Panzer_STK_Interface.hpp"
#include "Panzer_DOFManager.hpp"
Expand Down
20 changes: 11 additions & 9 deletions src/managers/assemblyManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,20 @@
#include "Panzer_DOFManager.hpp"

#include "preferences.hpp"
#include "groupMetaData.hpp"
#include "group.hpp"
#include "boundaryGroup.hpp"
#include "workset.hpp"
#include "meshInterface.hpp"
#include "physicsInterface.hpp"
#include "discretizationInterface.hpp"
#include "tools/groupMetaData.hpp"
#include "tools/group.hpp"
#include "tools/boundaryGroup.hpp"
#include "tools/workset.hpp"
#include "tools/data.hpp"

#include "interfaces/meshInterface.hpp"
#include "interfaces/physicsInterface.hpp"
#include "interfaces/discretizationInterface.hpp"

#include "parameterManager.hpp"
#include "multiscaleManager.hpp"
#include "functionManager.hpp"
#include "data.hpp"
#include "MrHyDE_Debugger.hpp"
#include "tools/MrHyDE_Debugger.hpp"

namespace MrHyDE {

Expand Down
8 changes: 4 additions & 4 deletions src/managers/functionManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

#include "trilinos.hpp"
#include "preferences.hpp"
#include "dag.hpp"
#include "interpreter.hpp"
#include "workset.hpp"
#include "vista.hpp"
#include "tools/dag.hpp"
#include "tools/interpreter.hpp"
#include "tools/workset.hpp"
#include "tools/vista.hpp"

namespace MrHyDE {

Expand Down
10 changes: 5 additions & 5 deletions src/managers/multiscaleManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

#include "trilinos.hpp"
#include "preferences.hpp"
#include "group.hpp"
#include "subgridModel.hpp"
#include "tools/group.hpp"
#include "subgrid/subgridModel.hpp"
#include "Amesos2.hpp"
#include "meshInterface.hpp"
#include "workset.hpp"
#include "MrHyDE_Debugger.hpp"
#include "interfaces/meshInterface.hpp"
#include "tools/workset.hpp"
#include "tools/MrHyDE_Debugger.hpp"

namespace MrHyDE {

Expand Down
14 changes: 7 additions & 7 deletions src/managers/parameterManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@

#include "trilinos.hpp"
#include "preferences.hpp"
#include "meshInterface.hpp"
#include "physicsInterface.hpp"
#include "group.hpp"
#include "boundaryGroup.hpp"
#include "interfaces/meshInterface.hpp"
#include "interfaces/physicsInterface.hpp"
#include "tools/group.hpp"
#include "tools/boundaryGroup.hpp"
#include "Panzer_STK_Interface.hpp"
#include "discretizationInterface.hpp"
#include "MrHyDE_OptVector.hpp"
#include "MrHyDE_Debugger.hpp"
#include "interfaces/discretizationInterface.hpp"
#include "optimization/MrHyDE_OptVector.hpp"
#include "tools/MrHyDE_Debugger.hpp"

namespace MrHyDE {

Expand Down
25 changes: 14 additions & 11 deletions src/managers/postprocessManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,20 @@

#include "trilinos.hpp"
#include "preferences.hpp"
#include "meshInterface.hpp"
#include "physicsInterface.hpp"
#include "discretizationInterface.hpp"
//#include "functionManager.hpp"
#include "assemblyManager.hpp"
#include "parameterManager.hpp"
#include "multiscaleManager.hpp"
#include "linearAlgebraInterface.hpp"
#include "MrHyDE_OptVector.hpp"
#include "postprocessTools.hpp"
#include "MrHyDE_Debugger.hpp"

#include "tools/postprocessTools.hpp"

#include "interfaces/meshInterface.hpp"
#include "interfaces/physicsInterface.hpp"
#include "interfaces/discretizationInterface.hpp"
#include "interfaces/linearAlgebraInterface.hpp"

#include "managers/assemblyManager.hpp"
#include "managers/parameterManager.hpp"
#include "managers/multiscaleManager.hpp"

#include "optimization/MrHyDE_OptVector.hpp"
#include "tools/MrHyDE_Debugger.hpp"

#if defined(MrHyDE_ENABLE_FFTW)
#include "fftInterface.hpp"
Expand Down
15 changes: 9 additions & 6 deletions src/managers/solverManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,19 @@

#include "trilinos.hpp"
#include "preferences.hpp"
#include "meshInterface.hpp"
#include "physicsInterface.hpp"

#include "interfaces/meshInterface.hpp"
#include "interfaces/physicsInterface.hpp"
#include "interfaces/discretizationInterface.hpp"
#include "interfaces/linearAlgebraInterface.hpp"

#include "multiscaleManager.hpp"
#include "discretizationInterface.hpp"
#include "assemblyManager.hpp"
#include "parameterManager.hpp"
#include "postprocessManager.hpp"
#include "solutionStorage.hpp"
#include "linearAlgebraInterface.hpp"
#include "MrHyDE_Debugger.hpp"

#include "tools/solutionStorage.hpp"
#include "tools/MrHyDE_Debugger.hpp"

namespace MrHyDE {

Expand Down
6 changes: 3 additions & 3 deletions src/physics/physicsBase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

#include "trilinos.hpp"
#include "preferences.hpp"
#include "workset.hpp"
#include "functionManager.hpp"
#include "compressedView.hpp"
#include "tools/workset.hpp"
#include "managers/functionManager.hpp"
#include "tools/compressedView.hpp"

namespace MrHyDE {

Expand Down
2 changes: 1 addition & 1 deletion src/subgrid/subgridModel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#include "trilinos.hpp"
#include "preferences.hpp"
#include "solutionStorage.hpp"
#include "tools/solutionStorage.hpp"

namespace MrHyDE {

Expand Down
2 changes: 1 addition & 1 deletion src/tools/boundaryGroup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "preferences.hpp"
#include "workset.hpp"
#include "groupMetaData.hpp"
#include "discretizationInterface.hpp"
#include "interfaces/discretizationInterface.hpp"
#include "compressedView.hpp"

#include <iostream>
Expand Down
2 changes: 1 addition & 1 deletion src/tools/data.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "trilinos.hpp"
#include <iostream>
#include <iterator>
#include "CompadreInterface.hpp"
#include "interfaces/CompadreInterface.hpp"

namespace MrHyDE {

Expand Down
4 changes: 2 additions & 2 deletions src/tools/group.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
#include "trilinos.hpp"
#include "preferences.hpp"
#include "workset.hpp"
#include "subgridModel.hpp"
#include "subgrid/subgridModel.hpp"
#include "groupMetaData.hpp"
#include "discretizationInterface.hpp"
#include "interfaces/discretizationInterface.hpp"
#include "compressedView.hpp"

#include <iostream>
Expand Down
6 changes: 3 additions & 3 deletions src/tools/groupMetaData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

#include "trilinos.hpp"
#include "preferences.hpp"
#include "physicsBase.hpp"
#include "physicsInterface.hpp"
#include "sparse3DView.hpp"
#include "physics/physicsBase.hpp"
#include "interfaces/physicsInterface.hpp"
#include "tools/sparse3DView.hpp"

#include <iostream>
#include <iterator>
Expand Down
2 changes: 1 addition & 1 deletion src/trilinos.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

// Kokkos include
#include "Kokkos_Core.hpp"
#include "kokkosTools.hpp"
#include "tools/kokkosTools.hpp"

// Sacado
#include "Sacado.hpp"
Expand Down