CMakeLists.txt 3.55 KB
Newer Older
1
2
3
set(SRC
  ncDataDz.cpp
  slimDate.cpp
4
  slimFunction.cpp
5
  slimGebco.cpp
6
  slimIterateHelper.cpp
7
8
9
10
  slimLonLat.cpp
  slimStructData.cpp
  slimTemporalSerie.cpp
  slimTpxo.cpp
11
  slimFES.cpp
12
  slimExportNetCDF.cpp
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
13
  unrefMesher.cpp
14
15
)

Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
16
set(LIBS "")
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
17
set(EXTERNAL_MODULE_DEPS "")
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
18

19
20
21
22
23
24
option(ENABLE_NETCDF "Enable NETCDF" ON)
if(ENABLE_NETCDF)
  find_library (NETCDF_LIB netcdf)
  if (NETCDF_LIB)
    find_path (NETCDF_INC "netcdf.h" PATH_SUFFIXES include)
    if (NETCDF_INC)
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
25
26
      message("slimFunction configured with Netcdf")
      add_definitions("-DHAVE_NETCDF")
27
      include_directories(${NETCDF_INC})
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
28
      list(APPEND LIBS ${NETCDF_LIB})
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
29
      dg_add_swig_module(slimNetCDFWrap slimNetCDFWrap.i "dgSlimFunction")
30
31
32
33
    endif(NETCDF_INC)
  endif(NETCDF_LIB)
endif(ENABLE_NETCDF)

34
35
36
37
option(ENABLE_FES "Enable using FES tidal solution" ON)
if(ENABLE_FES)
  find_library (FES_LIB fes)
  if (FES_LIB)
38
39
    find_path(FES_INC "fes.h" PATH_SUFFIXES include)
    find_path(FES_DATA "fes.ini" PATH_SUFFIXES "share/fes_data" HINTS "${FES_INC}/../share/fes_data")
40
    if (FES_INC AND FES_DATA)
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
41
42
43
44
      message("slimFunction configured with FES")
      add_definitions("-DHAVE_FES")
      add_definitions("-DFES_DATA \"${FES_DATA}\"")
      list(APPEND LIBS ${FES_LIB})
45
      include_directories(${FES_INC})
46
    endif(FES_INC AND FES_DATA)
47
48
49
  endif(FES_LIB)
endif(ENABLE_FES)

Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
50
option(ENABLE_PROJ "Enable PROJ" ON)
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
51
option(ENABLE_UNREF "Enable UNREF mesh generator (requires ENABLE_PROJ)" ON)
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
52
if(ENABLE_PROJ)
53
54
55
56
57
58
59
60
61
  if(WIN32)
  set (PROJ_LIB ${CMAKE_CURRENT_BINARY_DIR}/libproj/build/lib/libproj_4_9.a)
    set(PROJ_FPIC "")
  else()
  set (PROJ_LIB ${CMAKE_CURRENT_BINARY_DIR}/libproj/build/lib/libproj.a)
    set(PROJ_FPIC -DCMAKE_C_FLAGS="-fPIC")
  endif(WIN32)
  ExternalProject_Add(
    libproj 
62
63
    URL http://download.osgeo.org/proj/proj-4.9.2.tar.gz
    URL_MD5 9843131676e31bbd903d60ae7dc76cf9
64
65
66
67
68
69
70
71
72
73
    PATCH_COMMAND ${CMAKE_COMMAND} -E remove <SOURCE_DIR>/nad/CMakeLists.txt
    INSTALL_COMMAND ""
    PREFIX libproj
    BINARY_DIR libproj/build
    CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DBUILD_CS2CS=NO -DBUILD_PROJ=NO -DBUILD_GEOD=NO -DBUILD_NAD2BIN=NO -DPROJ4_TESTS=NO -DBUILD_LIBPROJ_SHARED=NO  ${PROJ_FPIC}
  )
  set (PROJ_INC ${CMAKE_CURRENT_BINARY_DIR}/libproj/src/libproj/src)
  message("slimFunction configured with PROJ")
  add_definitions("-DHAVE_PROJ")
  include_directories(${PROJ_INC})
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
74
  list(APPEND EXTERNAL_MODULE_DEPS libproj)
75
  list(APPEND LIBS ${PROJ_LIB})
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
  if (ENABLE_UNREF)
    include(ExternalProject)
    ExternalProject_Add(
      unref 
      GIT_REPOSITORY https://git.immc.ucl.ac.be/unref/unref.git
      GIT_TAG 587ee41
      INSTALL_COMMAND ""
      CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DEXTERNAL_LIBPROJ=ON -DPROJ_INCLUDE_PATH=${PROJ_INC} -DPROJ_LIBRARY=${PROJ_LIB} -DBUILD_EXECUTABLE=OFF -DCMAKE_CXX_FLAGS=-fPIC
      PREFIX unref
      BINARY_DIR unref/build
    )
    list(APPEND EXTERNAL_MODULE_DEPS unref)
    add_definition(-DHAVE_UNREF)
    list(APPEND LIBS ${CMAKE_CURRENT_BINARY_DIR}/unref/build/libunref.a)
    include_directories(${CMAKE_CURRENT_BINARY_DIR}/unref/src/unref)
  endif(ENABLE_UNREF)
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
92
93
endif(ENABLE_PROJ)

Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
94
dg_add_module(dgSlimFunction "${SRC}" "${LIBS};${PYTHON_LIBRARY}")
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
95
dg_add_swig_module(slimFunction slimFunction.i dgSlimFunction)
96
if(ENABLE_PROJ)
97
98
  set(SWIG_MODULE_proj_EXTRA_DEPS "libproj;dg")
  dg_add_swig_module(proj proj.i "${PROJ_LIB};dg")
Jonathan Lambrechts's avatar
Jonathan Lambrechts committed
99
  add_dependencies(dgSlimFunction ${EXTERNAL_MODULE_DEPS})
100
endif(ENABLE_PROJ)
101
dg_add_test_directory(tests valentin.vallaeys@uclouvain.be)