CMakeLists.txt 3.8 KB
Newer Older
Uldis Locans's avatar
Uldis Locans committed
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
CMAKE_MINIMUM_REQUIRED (VERSION 2.8)

SET (DKS_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR})
MACRO (ADD_SOURCES )
  FILE (RELATIVE_PATH _relPath "${DKS_SRC_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}")
  FOREACH (_src ${ARGN})
    IF (_relPath)
      LIST (APPEND DKS_SRCS "${_relPath}/${_src}")
    ELSE ()
      LIST (APPEND DKS_SRCS "${_src}")
    ENDIF ()
  ENDFOREACH ()
  IF (_relPath)
    # propagate SRCS to parent directory
    SET (DKS_SRCS ${DKS_SRCS} PARENT_SCOPE)
  ENDIF ()
ENDMACRO ()

MACRO (ADD_HEADERS )
  FILE (RELATIVE_PATH _relPath "${DKS_SRC_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}")
  FOREACH (_hdr ${ARGN})
    IF (_relPath)
      LIST (APPEND DKS_HDRS "${_relPath}/${_hdr}")
    ELSE ()
      LIST (APPEND DKS_HDRS "${_hdr}")
    ENDIF ()
  ENDFOREACH ()
  IF (_relPath)
    # propagate HDRS to parent directory
    SET (DKS_HDRS ${DKS_HDRS} PARENT_SCOPE)
  ENDIF ()
ENDMACRO ()


SET (DKS_BASEDIR_HDRS
  DKSBase.h
  DKSDefinitions.h
38
  DKSOPAL.h
Uldis Locans's avatar
Uldis Locans committed
39 40 41 42
  )

SET (DKS_BASEDIR_SRCS
  DKSBase.cpp
43
  DKSOPAL.cpp
Uldis Locans's avatar
Uldis Locans committed
44 45
  )

46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
#add opal to DKS if enable_opal is set
IF (ENABLE_OPAL)
  SET (DKS_BASEDIR_HDRS
    ${DKS_BASEDIR_HDRS}
    DKSOPAL.h
    )

  SET (DKS_BASEDIR_SRCS
    ${DKS_BASEDIR_SRCS}
    DKSOPAL.cpp
    )
ENDIF (ENABLE_OPAL)

#and musrt to DKS if cuda or opencl is used and enable_musr is set
IF ( (USE_CUDA OR USE_OPENCL) AND ENABLE_MUSR)
Uldis Locans's avatar
Uldis Locans committed
61 62 63 64 65 66 67 68 69
   SET (DKS_BASEDIR_HDRS
       ${DKS_BASEDIR_HDRS}
       DKSBaseMuSR.h
       )

   SET (DKS_BASEDIR_SRCS
       ${DKS_BASEDIR_SRCS}
       DKSBaseMuSR.cpp
       )
70
ENDIF ( (USE_CUDA OR USE_OPENCL) AND ENABLE_MUSR)
Uldis Locans's avatar
Uldis Locans committed
71

72 73
#add image reconstruction to DKS if cuda is used and enable_pet is set
IF (USE_CUDA AND ENABLE_PET)
Uldis Locans's avatar
Uldis Locans committed
74 75 76 77 78 79 80 81 82
  SET (DKS_BASEDIR_HDRS
    ${DKS_BASEDIR_HDRS}
    DKSImageReconstruction.h
    )
  
  SET (DKS_BASEDIR_SRCS
    ${DKS_BASEDIR_SRCS}
    DKSImageReconstruction.cpp
    )
83
ENDIF (USE_CUDA AND ENABLE_PET)
Uldis Locans's avatar
Uldis Locans committed
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 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147

ADD_HEADERS (${DKS_BASEDIR_HDRS})
ADD_SOURCES (${DKS_BASEDIR_SRCS})

MESSAGE (STATUS "HEADERS: ${DKS_BASEDIR_HDRS}")
MESSAGE (STATUS "SOURCES: ${DKS_BASEDIR_SRCS}")

#add only those source files that will be used
IF (USE_OPENCL)
  MESSAGE (STATUS "Add OpenCL source files")
  ADD_SUBDIRECTORY (OpenCL)
ENDIF (USE_OPENCL)

IF (USE_CUDA)
  MESSAGE (STATUS "Add CUDA source files")
  ADD_SUBDIRECTORY (CUDA)
ENDIF (USE_CUDA)

IF (USE_MIC)
  MESSAGE (STATUS "Add MIC source files")
  ADD_SUBDIRECTORY (MIC)
ENDIF (USE_MIC)

ADD_SUBDIRECTORY (Utility)
ADD_SUBDIRECTORY (AutoTuning)
ADD_SUBDIRECTORY (Algorithms)

IF (USE_CUDA)
  CUDA_ADD_LIBRARY(dks ${DKS_SRCS})
  CUDA_ADD_LIBRARY(dksshared SHARED ${DKS_SRCS})

  IF (USE_UQTK)
    TARGET_LINK_LIBRARIES(dks cudadevrt lreg UQTk quad uqtktools cvode-2.6.0 dsfmt lbfgs uqtklapack uqtkslatec uqtkblas gfortran)
    TARGET_LINK_LIBRARIES(dksshared cudadevrt lreg UQTk quad uqtktools cvode-2.6.0 dsfmt lbfgs uqtklapack uqtkslatec uqtkblas gfortran)
  ELSE (USE_UQTK)
    TARGET_LINK_LIBRARIES(dks cudadevrt)
    TARGET_LINK_LIBRARIES(dksshared cudadevrt)
  ENDIF (USE_UQTK)

ELSE (USE_CUDA)
  MESSAGE (STATUS "DKS srcs: ${DKS_SRCS}")
  ADD_LIBRARY(dks ${DKS_SRCS})
  ADD_LIBRARY(dksshared SHARED ${DKS_SRCS})

  IF (USE_UQTK)
    TARGET_LINK_LIBRARIES(dks lreg UQTk quad uqtktools cvode-2.6.0 dsfmt lbfgs uqtklapack uqtkslatec uqtkblas gfortran)
    TARGET_LINK_LIBRARIES(dksshared lreg UQTk quad uqtktools cvode-2.6.0 dsfmt lbfgs uqtklapack uqtkslatec uqtkblas gfortran)
  ELSE (USE_UQTK)
    TARGET_LINK_LIBRARIES(dks)
    TARGET_LINK_LIBRARIES(dksshared)
  ENDIF(USE_UQTK)

ENDIF (USE_CUDA)

INSTALL(TARGETS dks DESTINATION lib)
INSTALL(TARGETS dksshared DESTINATION lib)
INSTALL(FILES ${DKS_BASEDIR_HDRS} DESTINATION include)

#IF (USE_MIC AND (COMPILER_NAME STREQUAL "icpc" OR COMPILER_NAME STREQUAL "mpiicpc"))
#  INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libdksMIC.a DESTINATION build/lib)
#ENDIF (USE_MIC AND (COMPILER_NAME STREQUAL "icpc" OR COMPILER_NAME STREQUAL "mpiicpc"))