CMakeLists.txt 4.5 KB
Newer Older
gsell's avatar
gsell committed
1 2 3 4 5 6
cmake_minimum_required (VERSION 2.6)

set (PACKAGE \"opal\")
set (PACKAGE_BUGREPORT \"opal@lists.psi.ch\")
set (PACKAGE_NAME \"OPAL\")
set (PACKAGE_TARNAME \"opal\")
gsell's avatar
gsell committed
7
set (PACKAGE_VERSION \"1.3.0\")
gsell's avatar
gsell committed
8 9 10 11 12 13

configure_file(config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/config.h)


#FIXME: get from Makefile.def (IPPL)
set (CMAKE_CXX_FLAGS
14
    "${IPPL_CMAKE_CXX_FLAGS} -DUSEH5FEDV2 -DPARALLEL_IO ${CMAKE_CXX_FLAGS}"
gsell's avatar
gsell committed
15 16
    )

17
IF(ENABLE_SAAMG_SOLVER)
gsell's avatar
gsell committed
18
    set (CMAKE_CXX_FLAGS
19
        "-DHAVE_SAAMG_SOLVER ${CMAKE_CXX_FLAGS}"
gsell's avatar
gsell committed
20
    )
21
ENDIF(ENABLE_SAAMG_SOLVER)
gsell's avatar
gsell committed
22

23 24 25 26 27 28
IF(ENABLE_AMR_SOLVER)
    set (CMAKE_CXX_FLAGS
        "-DHAVE_AMR_SOLVER ${CMAKE_CXX_FLAGS}"
    )
ENDIF(ENABLE_AMR_SOLVER)

29
#MESSAGE ("Compile OPAL with: ${CMAKE_CXX_FLAGS}")
gsell's avatar
gsell committed
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

set (OPAL_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR})
macro (add_sources)
    file (RELATIVE_PATH _relPath "${OPAL_SRC_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}")
    foreach (_src ${ARGN})
        if (_relPath)
            list (APPEND OPAL_SRCS "${_relPath}/${_src}")
        else()
            list (APPEND OPAL_SRCS "${_src}")
        endif()
    endforeach()
    if (_relPath)
        # propagate SRCS to parent directory
        set (OPAL_SRCS ${OPAL_SRCS} PARENT_SCOPE)
    endif()
endmacro()

add_subdirectory (AbstractObjects)
add_subdirectory (Algebra)
add_subdirectory (Algorithms)
add_subdirectory (Aperture)
add_subdirectory (Attributes)
add_subdirectory (BasicActions)
add_subdirectory (Distribution)
add_subdirectory (Editor)
add_subdirectory (Elements)
add_subdirectory (Errors)
add_subdirectory (Expressions)
add_subdirectory (Lines)
add_subdirectory (OpalConfigure)
add_subdirectory (OpalParser)
add_subdirectory (Match)
add_subdirectory (PhysicsActions)
add_subdirectory (Solvers)
64
add_subdirectory (Solvers/amr)
gsell's avatar
gsell committed
65 66 67 68 69 70
add_subdirectory (Structure)
add_subdirectory (Tables)
add_subdirectory (Track)
add_subdirectory (Utilities)
add_subdirectory (ValueDefinitions)

71
include_directories (Solvers/amr
72
    ${CMAKE_CURRENT_SOURCE_DIR}
gsell's avatar
gsell committed
73 74 75 76 77 78 79 80
    ${IPPL_INCLUDE_DIR}
    ${H5Hut_INCLUDE_DIR}
    ${HDF5_INCLUDE_DIR}
    ${GSL_INCLUDE_DIR}
    ${CLASSIC_SOURCE_DIR}
    ${Trilinos_INCLUDE_DIRS}
    ${Trilinos_TPL_INCLUDE_DIRS}
    ${IPPL_INCLUDE_DIRS}
81
    ${CCSE_INCLUDE_DIRS}
gsell's avatar
gsell committed
82 83 84 85 86 87 88 89
)

link_directories (
    ${IPPL_LIBRARY_DIR}
    ${CLASSIC_SOURCE_DIR}
    ${DOOM_SOURCE_DIR}
    ${Trilinos_LIBRARY_DIRS}
    ${Trilinos_TPL_LIBRARY_DIRS}
90
    ${CCSE_LIBRARY_DIR}
gsell's avatar
gsell committed
91 92 93 94 95 96 97 98 99 100 101
)
#   "/opt/parmetis/parmetis-3.1"
#   "/opt/intel-mkl/mkl-10.0/lib/em64t"

set (OPAL_LIBS
    m
    ${GSL_LIBRARY}
    ${H5Hut_LIBRARY}
    ${HDF5_LIBRARY}
    ${IPPL_LIBRARY}
    z
102 103
    mpi
    mpi_cxx
gsell's avatar
gsell committed
104 105
)

kraus's avatar
kraus committed
106 107 108
add_library( OPALib ${OPAL_SRCS} opal.cpp )
set_target_properties( OPALib PROPERTIES OUTPUT_NAME OPAL )

109
add_executable( opal Main.cpp )
110
target_link_libraries( opal OPALib CLASSIC ${OPAL_LIBS} ${Trilinos_LIBRARIES} ${Trilinos_TPL_LIBRARIES} ${CCSE_LIBRARIES} ${OTHER_CMAKE_EXE_LINKER_FLAGS} -lgfortran ${CMAKE_DL_LIBS})
111 112 113 114 115 116 117 118 119 120 121

# build unit tests; unit tests are defined in unit_tests directory, we build the
# executable here so that we can use the OPAL src and lib definitions
if (BUILD_OPAL_UNIT_TESTS)
    # touch CMakeLists to force cmake to redo the glob for new test source files
    # otherwise cmake does not detect new source files
    execute_process(COMMAND touch ${CMAKE_CURRENT_SOURCE_DIR}/unit_tests/CMakeLists.txt)
    add_subdirectory(unit_tests)
    # include and link gtest library
    # this can be built using the script provided at
    #     unit_test/gtest/bin/install_gtest.bash
122
    link_directories( ${GTEST_LIB_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/../classic/5.0/src)
123 124 125 126 127
    include_directories(${GTEST_INCLUDE_DIR})
    # Check to see if cmake finds the test files
    message(STATUS "unit test src files: ${TEST_SRCS}")
    # Build the test exe. We don't do an install on the unit test exe as it is
    # assumed that this is internal to opal
kraus's avatar
kraus committed
128 129
    add_executable(${TEST_EXE} ${TEST_SRCS}) # the opal and classic sources are not needed again if we link agains libOPAL and libCLASSIC!
    target_link_libraries(${TEST_EXE} OPALib CLASSIC ${OPAL_LIBS} ${Trilinos_LIBRARIES} ${Trilinos_TPL_LIBRARIES} ${CCSE_LIBRARIES} -lgfortran ${OTHER_CMAKE_EXE_LINKER_FLAGS} ${GTEST_LINK_TARGETS} )
130 131 132 133
endif (BUILD_OPAL_UNIT_TESTS)

install (TARGETS ${TEST_EXE} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
install (TARGETS opal RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
gsell's avatar
gsell committed
134 135
install (TARGETS OPALib DESTINATION "${CMAKE_INSTALL_PREFIX}/lib")
install (FILES opal.h DESTINATION "${CMAKE_INSTALL_PREFIX}/include")
136
install (FILES Utilities/OpalException.h DESTINATION "${CMAKE_INSTALL_PREFIX}/include/Utilities")