CMakeLists.txt 5.31 KB
Newer Older
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
##  Copyright 2009-2016 Inria
##
## This file is part of the PaMPA software package for parallel
## mesh partitioning and adaptation.
##
## PaMPA is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## any later version.
##
## PaMPA is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## In this respect, the user's attention is drawn to the risks associated
## with loading, using, modifying and/or developing or reproducing the
## software by the user in light of its specific status of free software,
## that may mean that it is complicated to manipulate, and that also
## therefore means that it is reserved for developers and experienced
## professionals having in-depth computer knowledge. Users are therefore
## encouraged to load and test the software's suitability as regards
## their requirements in conditions enabling the security of their
## systems and/or data to be ensured and, more generally, to use and
## operate it in the same conditions as regards security.
##
## The fact that you are presently reading this means that you have had
## knowledge of the GPLv3 license and that you accept its terms.
##
Cédric Lachat's avatar
Cédric Lachat 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
#############################################################
##
##    \file        CMakeLists.txt
##
##    \authors     Cedric Lachat
##
##
##    \date        Version 1.0: from: 31 May 2011
##                              to:   22 Sep 2017
##
#############################################################




########################
#   libpampa-mmg3d4    #
########################

include_directories (${MMG3D4_INCLUDE_DIR})
include_directories (${PAMPA_SOURCE_DIR}/pampa/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_BINARY_DIR}/src/libpampa)

# Generate pampa-mmg3d4.h
add_custom_command(OUTPUT pampa-mmg3d4.h
  COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/library.h ${CMAKE_CURRENT_BINARY_DIR}/pampa-mmg3d4.h
  DEPENDS library.h)

if (FORTRAN_INTERFACE)
  # Generate pampa_commonf.h
  add_custom_command(OUTPUT pampa_commonf.h
61 62 63 64
        COMMAND ${CMAKE_COMMAND} -E copy
        ${CMAKE_CURRENT_SOURCE_DIR}/../../../libpampa/pampa_commonf.h
        ${CMAKE_CURRENT_BINARY_DIR}/pampa_commonf.h
        DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/../../../libpampa/pampa_commonf.h)
Cédric Lachat's avatar
Cédric Lachat committed
65 66 67 68

    # Generate pampa-mmg3d4_commonf.h
    add_custom_command(OUTPUT pampa-mmg3d4_commonf.h
      COMMAND ${CMAKE_COMMAND} -E copy
69
          ${CMAKE_CURRENT_SOURCE_DIR}/library_commonf.h ${CMAKE_CURRENT_BINARY_DIR}/pampa-mmg3d4_commonf.h
Cédric Lachat's avatar
Cédric Lachat committed
70 71 72 73
      DEPENDS library_commonf.h)

  # Generate pampaf-mmg3d4.h
  add_custom_command(OUTPUT pampaf-mmg3d4.h
74 75
        COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/libraryf.h ${CMAKE_CURRENT_BINARY_DIR}/pampaf-mmg3d4.h
        DEPENDS library.h)
Cédric Lachat's avatar
Cédric Lachat committed
76 77 78 79 80 81 82
endif ()

# Sources to build libpampa-mmg3d4

set(PAMPA_MMG3D4_C_SOURCES
  pampa-mmg3d4.h
  library_dmesh_band.c
83
  library_dmesh_check.c
Cédric Lachat's avatar
Cédric Lachat committed
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
  library_dmesh_weight.c
  library_dmesh_metric.c
  library_mesh_adapt.c
  library_mesh_load.c
  library_mesh_save.c
  library_pmesh_to_rmesh.c
  metric.c
  mesh_metric_smooth.c
  mesh_metric_smooth.h
  rmesh_to_pmesh.c
  pmesh_to_rmesh.c
  )

if (FORTRAN_INTERFACE)
  set (PAMPA_MMG3D4_FORTRAN_SOURCES
99 100 101 102 103 104
        pampa_commonf.h
        pampa-mmg3d4_commonf.h
        pampaf-mmg3d4.h
        library_mesh_load.F90
        library_mesh_save.F90
        library.F90)
Cédric Lachat's avatar
Cédric Lachat committed
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 148 149 150 151 152 153
endif ()

add_library(
  pampa-mmg3d4
  ${PAMPA_MMG3D4_C_SOURCES}
  ${PAMPA_MMG3D4_FORTRAN_SOURCES})

# Add dependency on PaMPA
TARGET_LINK_LIBRARIES(pampa-mmg3d4 pampa ${PAMPA_LIBRARY})

# Do some copies after building libpampa
if (PAMPA_BUILD_ALONE)
  if (OLD_CMAKE)
    add_custom_command(TARGET pampa-mmg3d4 POST_BUILD
      COMMAND ${CMAKE_COMMAND} -E copy libpampa-mmg3d4.a ${PAMPA_SOURCE_DIR}/pampa/lib
      COMMAND ${CMAKE_COMMAND} -E copy ${MMG3D4_LIBRARY} ${PAMPA_SOURCE_DIR}/pampa/lib
      )
    # XXX est-ce encore utile ?
    #if (PAMPA_MMG3D4_SCOTCH)
    #  add_custom_command(TARGET pampa-mmg3d4 POST_BUILD
    #    COMMAND ${CMAKE_COMMAND} -E copy ${SCOTCH_MMG3D4_LIBRARY} ${PAMPA_SOURCE_DIR}/pampa/lib
    #    )
    #endif ()
  else (OLD_CMAKE)
    add_custom_command(TARGET pampa-mmg3d4 POST_BUILD
      COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:pampa-mmg3d4> ${PAMPA_SOURCE_DIR}/pampa/lib
      COMMAND ${CMAKE_COMMAND} -E copy ${MMG3D4_LIBRARY} ${PAMPA_SOURCE_DIR}/pampa/lib
      )
    if (PAMPA_MMG3D4_SCOTCH)
      add_custom_command(TARGET pampa-mmg3d4 POST_BUILD
        COMMAND ${CMAKE_COMMAND} -E copy ${SCOTCH_MMG3D4_LIBRARY} ${PAMPA_SOURCE_DIR}/pampa/lib
        )
    endif ()
  endif (OLD_CMAKE)
  if (FORTRAN_INTERFACE)
    add_custom_command(TARGET pampa-mmg3d4 POST_BUILD
      COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/MOD/pampa_mmg3d4.mod ${PAMPA_SOURCE_DIR}/pampa/include
      )
  endif ()
endif ()

# Specify where libpampa-mmg3d4 and include files will be installed
if (BUILD_SHARED_LIBS)
install(TARGETS pampa-mmg3d4 LIBRARY DESTINATION lib)
else ()
install(TARGETS pampa-mmg3d4 ARCHIVE DESTINATION lib)
endif ()
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pampa-mmg3d4.h
  DESTINATION include)