From 41da6c6701082eafff6c3d8c5e418074be6e11f2 Mon Sep 17 00:00:00 2001
From: Lionel GUEZ <guez@lmd.ens.fr>
Date: Fri, 9 Jul 2021 22:48:07 +0200
Subject: [PATCH] Replace `CMAKE_SOURCE_DIR` by `PROJECT_SOURCE_DIR`

In case we are a sub-project.
---
 Inst_eddies/CMakeLists.txt       | 10 ++--
 Inst_eddies/Tests/CMakeLists.txt | 52 +++++++++---------
 Overlap/CMakeLists.txt           | 18 +++----
 Overlap/Tests/CMakeLists.txt     | 90 ++++++++++++++++----------------
 Tests/CMakeLists.txt             |  2 +-
 5 files changed, 86 insertions(+), 86 deletions(-)

diff --git a/Inst_eddies/CMakeLists.txt b/Inst_eddies/CMakeLists.txt
index b67461b0..680f9799 100644
--- a/Inst_eddies/CMakeLists.txt
+++ b/Inst_eddies/CMakeLists.txt
@@ -1,11 +1,11 @@
 add_executable(inst_eddies inst_eddies.f90
-  ${CMAKE_SOURCE_DIR}/Common/write_eddy.f90 local_extrema.f90
+  ${PROJECT_SOURCE_DIR}/Common/write_eddy.f90 local_extrema.f90
   set_max_speed.f90 get_1_outerm.f90 max_speed_contour_ssh.f90
-  good_contour.f90 ${CMAKE_SOURCE_DIR}/Common/spher_polyline_area.f90
+  good_contour.f90 ${PROJECT_SOURCE_DIR}/Common/spher_polyline_area.f90
   mean_speed.f90 inside_4.f90 set_all_outerm.f90
-  ${CMAKE_SOURCE_DIR}/Common/derived_types.f90
-  ${CMAKE_SOURCE_DIR}/Common/shpc_create.f90 nearby_extr.f90 get_var.f90
-  ${CMAKE_SOURCE_DIR}/Common/shpc_close.f90 write_aux.f90 config.f90)
+  ${PROJECT_SOURCE_DIR}/Common/derived_types.f90
+  ${PROJECT_SOURCE_DIR}/Common/shpc_create.f90 nearby_extr.f90 get_var.f90
+  ${PROJECT_SOURCE_DIR}/Common/shpc_close.f90 write_aux.f90 config.f90)
 
 target_include_directories(inst_eddies PRIVATE ${fortrangis_INCLUDE_DIR})
 
diff --git a/Inst_eddies/Tests/CMakeLists.txt b/Inst_eddies/Tests/CMakeLists.txt
index 49229f54..41b1b52b 100644
--- a/Inst_eddies/Tests/CMakeLists.txt
+++ b/Inst_eddies/Tests/CMakeLists.txt
@@ -1,12 +1,12 @@
 # test_get_1_outerm
 
 add_executable(test_get_1_outerm good_contour.f90
-  ${CMAKE_SOURCE_DIR}/Common/derived_types.f90 get_1_outerm.f90
-  ${CMAKE_SOURCE_DIR}/Common/spher_polyline_area.f90
+  ${PROJECT_SOURCE_DIR}/Common/derived_types.f90 get_1_outerm.f90
+  ${PROJECT_SOURCE_DIR}/Common/spher_polyline_area.f90
   ${CMAKE_CURRENT_LIST_DIR}/test_get_1_outerm.f90
-  ${CMAKE_SOURCE_DIR}/Common/shpc_create.f90
-  ${CMAKE_SOURCE_DIR}/Common/write_eddy.f90
-  ${CMAKE_SOURCE_DIR}/Common/shpc_close.f90)
+  ${PROJECT_SOURCE_DIR}/Common/shpc_create.f90
+  ${PROJECT_SOURCE_DIR}/Common/write_eddy.f90
+  ${PROJECT_SOURCE_DIR}/Common/shpc_close.f90)
 
 target_link_libraries(test_get_1_outerm geometry NetCDF95::netcdf95 shapelib_03
   contour_531 nr_util jumble NetCDF_Fortran::NetCDF_Fortran)
@@ -17,13 +17,13 @@ target_include_directories(test_get_1_outerm PRIVATE
 # test_set_all_outerm
 
 add_executable(test_set_all_outerm
-  ${CMAKE_SOURCE_DIR}/Common/derived_types.f90 set_all_outerm.f90
+  ${PROJECT_SOURCE_DIR}/Common/derived_types.f90 set_all_outerm.f90
   local_extrema.f90 get_1_outerm.f90 good_contour.f90
-  ${CMAKE_SOURCE_DIR}/Common/spher_polyline_area.f90 nearby_extr.f90
+  ${PROJECT_SOURCE_DIR}/Common/spher_polyline_area.f90 nearby_extr.f90
   get_var.f90 ${CMAKE_CURRENT_LIST_DIR}/test_set_all_outerm.f90
-  config.f90 ${CMAKE_SOURCE_DIR}/Common/shpc_create.f90
-  ${CMAKE_SOURCE_DIR}/Common/write_eddy.f90
-  ${CMAKE_SOURCE_DIR}/Common/shpc_close.f90)
+  config.f90 ${PROJECT_SOURCE_DIR}/Common/shpc_create.f90
+  ${PROJECT_SOURCE_DIR}/Common/write_eddy.f90
+  ${PROJECT_SOURCE_DIR}/Common/shpc_close.f90)
 
 target_link_libraries(test_set_all_outerm geometry NetCDF95::netcdf95
   numer_rec_95 shapelib_03 contour_531 jumble nr_util
@@ -65,7 +65,7 @@ target_include_directories(test_mean_speed PRIVATE
 # test_max_speed_contour_ssh
 
 add_executable(test_max_speed_contour_ssh
-  ${CMAKE_SOURCE_DIR}/Common/derived_types.f90 max_speed_contour_ssh.f90
+  ${PROJECT_SOURCE_DIR}/Common/derived_types.f90 max_speed_contour_ssh.f90
   get_var.f90
   ${CMAKE_CURRENT_LIST_DIR}/test_max_speed_contour_ssh.f90)
 
@@ -78,13 +78,13 @@ target_include_directories(test_max_speed_contour_ssh PRIVATE
 # test_nearby_extr
 
 add_executable(test_nearby_extr nearby_extr.f90
-  ${CMAKE_SOURCE_DIR}/Common/derived_types.f90
+  ${PROJECT_SOURCE_DIR}/Common/derived_types.f90
   ${CMAKE_CURRENT_LIST_DIR}/test_nearby_extr.f90
-  ${CMAKE_SOURCE_DIR}/Common/read_snapshot.f90
-  ${CMAKE_SOURCE_DIR}/Common/read_eddy.f90
-  ${CMAKE_SOURCE_DIR}/Common/read_field_indices.f90
-  ${CMAKE_SOURCE_DIR}/Common/shpc_open.f90
-  ${CMAKE_SOURCE_DIR}/Common/shpc_close.f90)
+  ${PROJECT_SOURCE_DIR}/Common/read_snapshot.f90
+  ${PROJECT_SOURCE_DIR}/Common/read_eddy.f90
+  ${PROJECT_SOURCE_DIR}/Common/read_field_indices.f90
+  ${PROJECT_SOURCE_DIR}/Common/shpc_open.f90
+  ${PROJECT_SOURCE_DIR}/Common/shpc_close.f90)
 
 target_link_libraries(test_nearby_extr NetCDF95::netcdf95 shapelib_03
   contour_531 jumble nr_util NetCDF_Fortran::NetCDF_Fortran ezmpi
@@ -97,7 +97,7 @@ target_include_directories(test_nearby_extr PRIVATE
 
 add_executable(test_local_extrema local_extrema.f90
   ${CMAKE_CURRENT_LIST_DIR}/test_local_extrema.f90
-  ${CMAKE_SOURCE_DIR}/Tests/write_extr_map.f90)
+  ${PROJECT_SOURCE_DIR}/Tests/write_extr_map.f90)
 
 target_link_libraries(test_local_extrema NetCDF95::netcdf95 nr_util
   jumble NetCDF_Fortran::NetCDF_Fortran)
@@ -105,16 +105,16 @@ target_link_libraries(test_local_extrema NetCDF95::netcdf95 nr_util
 # test_set_max_speed
 
 add_executable(test_set_max_speed
-  ${CMAKE_SOURCE_DIR}/Common/derived_types.f90 set_max_speed.f90
+  ${PROJECT_SOURCE_DIR}/Common/derived_types.f90 set_max_speed.f90
   good_contour.f90 max_speed_contour_ssh.f90 mean_speed.f90
-  ${CMAKE_SOURCE_DIR}/Common/spher_polyline_area.f90 inside_4.f90
+  ${PROJECT_SOURCE_DIR}/Common/spher_polyline_area.f90 inside_4.f90
   ${CMAKE_CURRENT_LIST_DIR}/test_set_max_speed.f90
-  ${CMAKE_SOURCE_DIR}/Common/shpc_open.f90
-  ${CMAKE_SOURCE_DIR}/Common/shpc_close.f90
-  ${CMAKE_SOURCE_DIR}/Common/read_field_indices.f90
-  ${CMAKE_SOURCE_DIR}/Common/read_eddy.f90
-  ${CMAKE_SOURCE_DIR}/Common/shpc_create.f90
-  ${CMAKE_SOURCE_DIR}/Common/write_eddy.f90)
+  ${PROJECT_SOURCE_DIR}/Common/shpc_open.f90
+  ${PROJECT_SOURCE_DIR}/Common/shpc_close.f90
+  ${PROJECT_SOURCE_DIR}/Common/read_field_indices.f90
+  ${PROJECT_SOURCE_DIR}/Common/read_eddy.f90
+  ${PROJECT_SOURCE_DIR}/Common/shpc_create.f90
+  ${PROJECT_SOURCE_DIR}/Common/write_eddy.f90)
 
 target_link_libraries(test_set_max_speed geometry numer_rec_95
   NetCDF95::netcdf95 shapelib_03 contour_531 jumble nr_util
diff --git a/Overlap/CMakeLists.txt b/Overlap/CMakeLists.txt
index 68c23257..afa29bcd 100644
--- a/Overlap/CMakeLists.txt
+++ b/Overlap/CMakeLists.txt
@@ -1,16 +1,16 @@
 add_executable(eddy_graph eddy_graph.f90
-  ${CMAKE_SOURCE_DIR}/Common/shpc_open.f90
-  ${CMAKE_SOURCE_DIR}/Common/shpc_create.f90 get_snapshot.f90
+  ${PROJECT_SOURCE_DIR}/Common/shpc_open.f90
+  ${PROJECT_SOURCE_DIR}/Common/shpc_create.f90 get_snapshot.f90
   overlap.f90 dispatch_snapshot.f90
-  ${CMAKE_SOURCE_DIR}/Common/shpc_close.f90
-  ${CMAKE_SOURCE_DIR}/Common/read_field_indices.f90
-  ${CMAKE_SOURCE_DIR}/Common/read_snapshot.f90 recv_snapshot.f90
+  ${PROJECT_SOURCE_DIR}/Common/shpc_close.f90
+  ${PROJECT_SOURCE_DIR}/Common/read_field_indices.f90
+  ${PROJECT_SOURCE_DIR}/Common/read_snapshot.f90 recv_snapshot.f90
   candidate_overlap.f90 spher_polygon_area.f90
-  ${CMAKE_SOURCE_DIR}/Common/spher_polyline_area.f90
+  ${PROJECT_SOURCE_DIR}/Common/spher_polyline_area.f90
   weight.f90 send_snapshot.f90
-  ${CMAKE_SOURCE_DIR}/Common/read_eddy.f90
-  ${CMAKE_SOURCE_DIR}/Common/write_eddy.f90
-  ${CMAKE_SOURCE_DIR}/Common/derived_types.f90 unit_edge_m.f90)
+  ${PROJECT_SOURCE_DIR}/Common/read_eddy.f90
+  ${PROJECT_SOURCE_DIR}/Common/write_eddy.f90
+  ${PROJECT_SOURCE_DIR}/Common/derived_types.f90 unit_edge_m.f90)
 
 target_include_directories(eddy_graph PRIVATE ${fortrangis_INCLUDE_DIR})
 
diff --git a/Overlap/Tests/CMakeLists.txt b/Overlap/Tests/CMakeLists.txt
index 7730d578..5beac004 100644
--- a/Overlap/Tests/CMakeLists.txt
+++ b/Overlap/Tests/CMakeLists.txt
@@ -1,16 +1,16 @@
 # test_overlap
 
 add_executable(test_overlap
-  ${CMAKE_SOURCE_DIR}/Common/derived_types.f90 overlap.f90
-  ${CMAKE_SOURCE_DIR}/Common/read_snapshot.f90 spher_polygon_area.f90
-  ${CMAKE_SOURCE_DIR}/Common/spher_polyline_area.f90 weight.f90
-  ${CMAKE_SOURCE_DIR}/Common/read_eddy.f90
-  ${CMAKE_SOURCE_DIR}/Common/read_field_indices.f90
-  candidate_overlap.f90 ${CMAKE_SOURCE_DIR}/Common/write_eddy.f90
-  ${CMAKE_SOURCE_DIR}/Common/shpc_create.f90
+  ${PROJECT_SOURCE_DIR}/Common/derived_types.f90 overlap.f90
+  ${PROJECT_SOURCE_DIR}/Common/read_snapshot.f90 spher_polygon_area.f90
+  ${PROJECT_SOURCE_DIR}/Common/spher_polyline_area.f90 weight.f90
+  ${PROJECT_SOURCE_DIR}/Common/read_eddy.f90
+  ${PROJECT_SOURCE_DIR}/Common/read_field_indices.f90
+  candidate_overlap.f90 ${PROJECT_SOURCE_DIR}/Common/write_eddy.f90
+  ${PROJECT_SOURCE_DIR}/Common/shpc_create.f90
   ${CMAKE_CURRENT_LIST_DIR}/test_overlap.f90
-  ${CMAKE_SOURCE_DIR}/Common/shpc_open.f90
-  ${CMAKE_SOURCE_DIR}/Common/shpc_close.f90 unit_edge_m.f90)
+  ${PROJECT_SOURCE_DIR}/Common/shpc_open.f90
+  ${PROJECT_SOURCE_DIR}/Common/shpc_close.f90 unit_edge_m.f90)
 
 target_link_libraries(test_overlap shapelib_03 geometry contour_531
   gpc_f ezmpi nr_util jumble MPI::MPI_Fortran)
@@ -20,17 +20,17 @@ target_include_directories(test_overlap PRIVATE ${fortrangis_INCLUDE_DIR})
 # test_read_snapshot
 
 add_executable(test_read_snapshot
-  ${CMAKE_SOURCE_DIR}/Common/derived_types.f90
-  ${CMAKE_SOURCE_DIR}/Common/shpc_create.f90
-  ${CMAKE_SOURCE_DIR}/Common/read_snapshot.f90
-  ${CMAKE_SOURCE_DIR}/Common/write_eddy.f90
-  ${CMAKE_SOURCE_DIR}/Common/read_eddy.f90
-  ${CMAKE_SOURCE_DIR}/Common/read_field_indices.f90
+  ${PROJECT_SOURCE_DIR}/Common/derived_types.f90
+  ${PROJECT_SOURCE_DIR}/Common/shpc_create.f90
+  ${PROJECT_SOURCE_DIR}/Common/read_snapshot.f90
+  ${PROJECT_SOURCE_DIR}/Common/write_eddy.f90
+  ${PROJECT_SOURCE_DIR}/Common/read_eddy.f90
+  ${PROJECT_SOURCE_DIR}/Common/read_field_indices.f90
   ${CMAKE_CURRENT_LIST_DIR}/test_read_snapshot.f90
-  ${CMAKE_SOURCE_DIR}/Tests/write_extr_map.f90
+  ${PROJECT_SOURCE_DIR}/Tests/write_extr_map.f90
   ${CMAKE_CURRENT_LIST_DIR}/write_snapshot.f90
-  ${CMAKE_SOURCE_DIR}/Common/shpc_open.f90
-  ${CMAKE_SOURCE_DIR}/Common/shpc_close.f90)
+  ${PROJECT_SOURCE_DIR}/Common/shpc_open.f90
+  ${PROJECT_SOURCE_DIR}/Common/shpc_close.f90)
 
 target_link_libraries(test_read_snapshot NetCDF95::netcdf95
   shapelib_03 contour_531 gpc_f ezmpi nr_util jumble
@@ -42,7 +42,7 @@ target_include_directories(test_read_snapshot PRIVATE
 # test_spher_polygon_area
 
 add_executable(test_spher_polygon_area spher_polygon_area.f90
-  ${CMAKE_SOURCE_DIR}/Common/spher_polyline_area.f90
+  ${PROJECT_SOURCE_DIR}/Common/spher_polyline_area.f90
   ${CMAKE_CURRENT_LIST_DIR}/test_spher_polygon_area.f90)
 
 target_link_libraries(test_spher_polygon_area geometry shapelib_03
@@ -54,7 +54,7 @@ target_include_directories(test_spher_polygon_area PRIVATE
 # test_weight
 
 add_executable(test_weight weight.f90
-  ${CMAKE_SOURCE_DIR}/Common/derived_types.f90
+  ${PROJECT_SOURCE_DIR}/Common/derived_types.f90
   ${CMAKE_CURRENT_LIST_DIR}/test_weight.f90)
 
 target_link_libraries(test_weight contour_531 nr_util)
@@ -63,14 +63,14 @@ target_include_directories(test_weight PRIVATE ${fortrangis_INCLUDE_DIR})
 # test_read_eddy
 
 add_executable(test_read_eddy
-  ${CMAKE_SOURCE_DIR}/Common/derived_types.f90
-  ${CMAKE_SOURCE_DIR}/Common/shpc_create.f90
-  ${CMAKE_SOURCE_DIR}/Common/read_eddy.f90
-  ${CMAKE_SOURCE_DIR}/Common/write_eddy.f90
-  ${CMAKE_SOURCE_DIR}/Common/read_field_indices.f90
+  ${PROJECT_SOURCE_DIR}/Common/derived_types.f90
+  ${PROJECT_SOURCE_DIR}/Common/shpc_create.f90
+  ${PROJECT_SOURCE_DIR}/Common/read_eddy.f90
+  ${PROJECT_SOURCE_DIR}/Common/write_eddy.f90
+  ${PROJECT_SOURCE_DIR}/Common/read_field_indices.f90
   ${CMAKE_CURRENT_LIST_DIR}/test_read_eddy.f90
-  ${CMAKE_SOURCE_DIR}/Common/shpc_open.f90
-  ${CMAKE_SOURCE_DIR}/Common/shpc_close.f90)
+  ${PROJECT_SOURCE_DIR}/Common/shpc_open.f90
+  ${PROJECT_SOURCE_DIR}/Common/shpc_close.f90)
 
 target_link_libraries(test_read_eddy shapelib_03 contour_531 gpc_f
   ezmpi nr_util MPI::MPI_Fortran jumble)
@@ -81,16 +81,16 @@ target_include_directories(test_read_eddy PRIVATE ${fortrangis_INCLUDE_DIR})
 
 add_executable(test_send_recv
   ${CMAKE_CURRENT_LIST_DIR}/test_send_recv.f90 send_snapshot.f90
-  recv_snapshot.f90 ${CMAKE_SOURCE_DIR}/Common/read_field_indices.f90
-  ${CMAKE_SOURCE_DIR}/Common/read_snapshot.f90
-  ${CMAKE_SOURCE_DIR}/Common/write_eddy.f90
-  ${CMAKE_SOURCE_DIR}/Common/shpc_create.f90
-  ${CMAKE_SOURCE_DIR}/Common/read_eddy.f90
+  recv_snapshot.f90 ${PROJECT_SOURCE_DIR}/Common/read_field_indices.f90
+  ${PROJECT_SOURCE_DIR}/Common/read_snapshot.f90
+  ${PROJECT_SOURCE_DIR}/Common/write_eddy.f90
+  ${PROJECT_SOURCE_DIR}/Common/shpc_create.f90
+  ${PROJECT_SOURCE_DIR}/Common/read_eddy.f90
   ${CMAKE_CURRENT_LIST_DIR}/write_snapshot.f90
-  ${CMAKE_SOURCE_DIR}/Tests/write_extr_map.f90
-  ${CMAKE_SOURCE_DIR}/Common/derived_types.f90
-  ${CMAKE_SOURCE_DIR}/Common/shpc_open.f90
-  ${CMAKE_SOURCE_DIR}/Common/shpc_close.f90)
+  ${PROJECT_SOURCE_DIR}/Tests/write_extr_map.f90
+  ${PROJECT_SOURCE_DIR}/Common/derived_types.f90
+  ${PROJECT_SOURCE_DIR}/Common/shpc_open.f90
+  ${PROJECT_SOURCE_DIR}/Common/shpc_close.f90)
 
 target_link_libraries(test_send_recv PRIVATE MPI::MPI_Fortran
   shapelib_03 ezmpi nr_util contour_531 gpc_f NetCDF95::netcdf95
@@ -104,16 +104,16 @@ target_include_directories(test_send_recv PRIVATE
 add_executable(test_get_dispatch_snap
   ${CMAKE_CURRENT_LIST_DIR}/test_get_dispatch_snap.f90
   get_snapshot.f90 dispatch_snapshot.f90
-  ${CMAKE_SOURCE_DIR}/Common/read_field_indices.f90
+  ${PROJECT_SOURCE_DIR}/Common/read_field_indices.f90
   ${CMAKE_CURRENT_LIST_DIR}/write_snapshot.f90
-  ${CMAKE_SOURCE_DIR}/Common/read_snapshot.f90 recv_snapshot.f90
-  ${CMAKE_SOURCE_DIR}/Common/shpc_create.f90
-  ${CMAKE_SOURCE_DIR}/Common/write_eddy.f90
-  ${CMAKE_SOURCE_DIR}/Tests/write_extr_map.f90
-  ${CMAKE_SOURCE_DIR}/Common/read_eddy.f90 send_snapshot.f90
-  ${CMAKE_SOURCE_DIR}/Common/derived_types.f90
-  ${CMAKE_SOURCE_DIR}/Common/shpc_open.f90
-  ${CMAKE_SOURCE_DIR}/Common/shpc_close.f90)
+  ${PROJECT_SOURCE_DIR}/Common/read_snapshot.f90 recv_snapshot.f90
+  ${PROJECT_SOURCE_DIR}/Common/shpc_create.f90
+  ${PROJECT_SOURCE_DIR}/Common/write_eddy.f90
+  ${PROJECT_SOURCE_DIR}/Tests/write_extr_map.f90
+  ${PROJECT_SOURCE_DIR}/Common/read_eddy.f90 send_snapshot.f90
+  ${PROJECT_SOURCE_DIR}/Common/derived_types.f90
+  ${PROJECT_SOURCE_DIR}/Common/shpc_open.f90
+  ${PROJECT_SOURCE_DIR}/Common/shpc_close.f90)
 
 target_link_libraries(test_get_dispatch_snap shapelib_03 jumble
   contour_531 ezmpi NetCDF95::netcdf95 gpc_f nr_util
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 858f64f6..5bc344b0 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -1,5 +1,5 @@
 add_executable(test_spher_polyline_area
-  ${CMAKE_SOURCE_DIR}/Common/spher_polyline_area.f90
+  ${PROJECT_SOURCE_DIR}/Common/spher_polyline_area.f90
   ${CMAKE_CURRENT_LIST_DIR}/test_spher_polyline_area.f90)
 
 target_link_libraries(test_spher_polyline_area geometry contour_531 nr_util)
-- 
GitLab