--- a/cmake/FindGEOS.cmake
+++ b/cmake/FindGEOS.cmake
@@ -99,8 +99,7 @@ ELSE(WIN32)
 
       IF (GEOS_CONFIG)
 
-        EXEC_PROGRAM(${GEOS_CONFIG}
-            ARGS --version
+      EXECUTE_PROCESS(COMMAND ${GEOS_CONFIG} --version
             OUTPUT_VARIABLE GEOS_VERSION)
         STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)(dev)?" "\\1" GEOS_VERSION_MAJOR "${GEOS_VERSION}")
         STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)(dev)?" "\\2" GEOS_VERSION_MINOR "${GEOS_VERSION}")
@@ -110,8 +109,7 @@ ELSE(WIN32)
         ENDIF (GEOS_VERSION_MAJOR LESS 3 OR (GEOS_VERSION_MAJOR EQUAL 3 AND GEOS_VERSION_MINOR LESS 3) )
 
         # set INCLUDE_DIR to prefix+include
-        EXEC_PROGRAM(${GEOS_CONFIG}
-            ARGS --prefix
+        EXECUTE_PROCESS(COMMAND ${GEOS_CONFIG} --prefix
             OUTPUT_VARIABLE GEOS_PREFIX)
 
         FIND_PATH(GEOS_INCLUDE_DIR
@@ -122,8 +120,7 @@ ELSE(WIN32)
             )
 
         ## extract link dirs for rpath
-        EXEC_PROGRAM(${GEOS_CONFIG}
-            ARGS --libs
+        EXECUTE_PROCESS(COMMAND ${GEOS_CONFIG} --libs
             OUTPUT_VARIABLE GEOS_CONFIG_LIBS )
 
         ## split off the link dirs (for rpath)
--- a/meos/CMakeLists.txt
+++ b/meos/CMakeLists.txt
@@ -68,14 +68,16 @@ add_definitions(-DPOSTGIS_VERSION_NUMBER=${POSTGIS_VERSION_NUMBER})
 #--------------------------------
 
 # PostGIS
-configure_file(${CMAKE_SOURCE_DIR}/postgis/postgis_config.h.in ${CMAKE_SOURCE_DIR}/postgis/postgis_config.h)
+configure_file(../postgis/postgis_config.h.in ../postgis/postgis_config.h)
 include_directories("${CMAKE_SOURCE_DIR}/postgis/liblwgeom")
 include_directories("${CMAKE_SOURCE_DIR}/postgis")
+include_directories("${CMAKE_BINARY_DIR}/postgis")
 add_subdirectory("${CMAKE_SOURCE_DIR}/postgis" "postgis")
 
 # PostgreSQL
-configure_file(${CMAKE_SOURCE_DIR}/meos/postgres/pg_config.h.in ${CMAKE_SOURCE_DIR}/meos/postgres/pg_config.h)
+configure_file(postgres/pg_config.h.in postgres/pg_config.h)
 include_directories("postgres")
+include_directories("${CMAKE_BINARY_DIR}/meos/postgres")
 add_subdirectory("postgres")
 # Disable all warnings on embedded code from PostgreSQL
 if(CMAKE_GENERATOR STREQUAL "Unix Makefiles")
--- a/mobilitydb/CMakeLists.txt
+++ b/mobilitydb/CMakeLists.txt
@@ -81,10 +81,11 @@ add_definitions(-DPOSTGIS_VERSION_NUMBER=${POSTGIS_VERSION_NUMBER})
 #--------------------------------
 
 # Embed PostGIS 3
-configure_file(${CMAKE_SOURCE_DIR}/postgis/postgis_config.h.in ${CMAKE_SOURCE_DIR}/postgis/postgis_config.h)
+configure_file(../postgis/postgis_config.h.in ../postgis/postgis_config.h)
 include_directories("${CMAKE_SOURCE_DIR}/postgis/liblwgeom")
 include_directories("${CMAKE_SOURCE_DIR}/postgis/libpgcommon")
 include_directories("${CMAKE_SOURCE_DIR}/postgis")
+include_directories("${CMAKE_BINARY_DIR}/postgis")
 add_subdirectory("${CMAKE_SOURCE_DIR}/postgis" "postgis")
 
 # MEOS
--- a/postgis/liblwgeom/liblwgeom.h
+++ b/postgis/liblwgeom/liblwgeom.h
@@ -33,7 +33,7 @@
 #include <stdint.h>
 #include <stdio.h>
 #include <stdbool.h> // MEOS
-#include "../postgis_config.h"
+#include "postgis_config.h"
 
 #include "proj.h"
 
--- a/postgis/liblwgeom/liblwgeom.h.in
+++ b/postgis/liblwgeom/liblwgeom.h.in
@@ -33,7 +33,7 @@
 #include <stdint.h>
 #include <stdio.h>
 
-#include "../postgis_config.h"
+#include "postgis_config.h"
 
 #if POSTGIS_PROJ_VERSION < 60
 #include "proj_api.h"
--- a/postgis/liblwgeom/liblwgeom_internal.h
+++ b/postgis/liblwgeom/liblwgeom_internal.h
@@ -29,7 +29,7 @@
 #ifndef _LIBLWGEOM_INTERNAL_H
 #define _LIBLWGEOM_INTERNAL_H 1
 
-#include "../postgis_config.h"
+#include "postgis_config.h"
 
 #include "lwgeom_log.h"
 
--- a/postgis/liblwgeom/liblwgeom_topo_internal.h
+++ b/postgis/liblwgeom/liblwgeom_topo_internal.h
@@ -26,7 +26,7 @@
 #ifndef LIBLWGEOM_TOPO_INTERNAL_H
 #define LIBLWGEOM_TOPO_INTERNAL_H 1
 
-#include "../postgis_config.h"
+#include "postgis_config.h"
 
 #include "liblwgeom.h"
 #include "liblwgeom_topo.h"
--- a/postgis/liblwgeom/lwgeom_geos_clean.c
+++ b/postgis/liblwgeom/lwgeom_geos_clean.c
@@ -22,7 +22,7 @@
  *
  **********************************************************************/
 
-#include "../postgis_config.h"
+#include "postgis_config.h"
 /*#define POSTGIS_DEBUG_LEVEL 4*/
 
 #include "liblwgeom.h"
--- a/postgis/liblwgeom/lwgeom_geos_split.c
+++ b/postgis/liblwgeom/lwgeom_geos_split.c
@@ -22,7 +22,7 @@
  *
  **********************************************************************/
 
-#include "../postgis_config.h"
+#include "postgis_config.h"
 /*#define POSTGIS_DEBUG_LEVEL 4*/
 #include "lwgeom_geos.h"
 #include "liblwgeom_internal.h"
--- a/postgis/liblwgeom/lwgeom_topo.c
+++ b/postgis/liblwgeom/lwgeom_topo.c
@@ -24,7 +24,7 @@
 
 
 
-#include "../postgis_config.h"
+#include "postgis_config.h"
 
 /*#define POSTGIS_DEBUG_LEVEL 1*/
 #include "lwgeom_log.h"
--- a/postgis/liblwgeom/lwgeom_transform.c
+++ b/postgis/liblwgeom/lwgeom_transform.c
@@ -24,7 +24,7 @@
 
 /* MobilityDB: Added for pg_strcasecmp */
 // #include "postgres.h"
-#include "../postgis_config.h"
+#include "postgis_config.h"
 #include "liblwgeom_internal.h"
 #include "lwgeom_log.h"
 #include <string.h>
--- a/postgis/liblwgeom/lwgeom_wrapx.c
+++ b/postgis/liblwgeom/lwgeom_wrapx.c
@@ -22,7 +22,7 @@
  *
  **********************************************************************/
 
-#include "../postgis_config.h"
+#include "postgis_config.h"
 /*#define POSTGIS_DEBUG_LEVEL 4*/
 #include "lwgeom_geos.h"
 #include "liblwgeom_internal.h"
--- a/postgis/liblwgeom/lwin_encoded_polyline.c
+++ b/postgis/liblwgeom/lwin_encoded_polyline.c
@@ -28,7 +28,7 @@
 #include <math.h>
 
 #include "liblwgeom.h"
-#include "../postgis_config.h"
+#include "postgis_config.h"
 
 LWGEOM*
 lwgeom_from_encoded_polyline(const char *encodedpolyline, int precision)
--- a/postgis/liblwgeom/lwin_geojson.c
+++ b/postgis/liblwgeom/lwin_geojson.c
@@ -26,7 +26,7 @@
 
 #include "liblwgeom.h"
 #include "lwgeom_log.h"
-#include "../postgis_config.h"
+#include "postgis_config.h"
 
 #if defined(HAVE_LIBJSON)
 
--- a/postgis/liblwgeom/lwin_wkb.c
+++ b/postgis/liblwgeom/lwin_wkb.c
@@ -23,7 +23,7 @@
  **********************************************************************/
 
 
-#include "../postgis_config.h"
+#include "postgis_config.h"
 /*#define POSTGIS_DEBUG_LEVEL 4*/
 #include "liblwgeom_internal.h" /* NOTE: includes lwgeom_log.h */
 #include "lwgeom_log.h"
--- a/postgis/liblwgeom/lwpoint.c
+++ b/postgis/liblwgeom/lwpoint.c
@@ -26,7 +26,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include "../postgis_config.h"
+#include "postgis_config.h"
 /*#define POSTGIS_DEBUG_LEVEL 4*/
 #include "liblwgeom_internal.h"
 #include "lwgeom_log.h"
--- a/postgis/liblwgeom/lwstroke.c
+++ b/postgis/liblwgeom/lwstroke.c
@@ -30,7 +30,7 @@
 #include <stdarg.h>
 #include <string.h>
 
-#include "../postgis_config.h"
+#include "postgis_config.h"
 
 /*#define POSTGIS_DEBUG_LEVEL 3*/
 
--- a/postgis/liblwgeom/lwutil.c
+++ b/postgis/liblwgeom/lwutil.c
@@ -33,7 +33,7 @@
 #include <ctype.h> /* for tolower */
 
 /* Global variables */
-#include "../postgis_config.h"
+#include "postgis_config.h"
 #include "liblwgeom_internal.h"
 #include "lwgeom_log.h"
 
--- a/postgis/liblwgeom/ptarray.c
+++ b/postgis/liblwgeom/ptarray.c
@@ -28,7 +28,7 @@
 #include <string.h>
 #include <stdlib.h>
 
-#include "../postgis_config.h"
+#include "postgis_config.h"
 /*#define POSTGIS_DEBUG_LEVEL 4*/
 #include "liblwgeom_internal.h"
 #include "lwgeom_log.h"
--- a/postgis/libpgcommon/gserialized_gist.c
+++ b/postgis/libpgcommon/gserialized_gist.c
@@ -17,7 +17,7 @@
   #include "varatt.h"
 #endif
 
-#include "../postgis_config.h"
+#include "postgis_config.h"
 
 /*#define POSTGIS_DEBUG_LEVEL 4*/
 
--- a/postgis/libpgcommon/lwgeom_cache.c
+++ b/postgis/libpgcommon/lwgeom_cache.c
@@ -17,7 +17,7 @@
 #include "fmgr.h"
 #include "utils/memutils.h"
 
-#include "../postgis_config.h"
+#include "postgis_config.h"
 
 /* Include for VARATT_EXTERNAL_GET_POINTER */
 #if POSTGRESQL_VERSION_NUMBER < 130000
--- a/postgis/libpgcommon/lwgeom_pg.c
+++ b/postgis/libpgcommon/lwgeom_pg.c
@@ -33,7 +33,7 @@
 #include <catalog/pg_extension.h>
 #include <commands/extension.h>
 
-#include "../postgis_config.h"
+#include "postgis_config.h"
 
 #if POSTGRESQL_VERSION_NUMBER >= 100000
 #include <utils/regproc.h>
--- a/postgis/libpgcommon/lwgeom_transform.c
+++ b/postgis/libpgcommon/lwgeom_transform.c
@@ -21,7 +21,7 @@
 #include "utils/hsearch.h"
 
 /* PostGIS headers */
-#include "../postgis_config.h"
+#include "postgis_config.h"
 #include "liblwgeom.h"
 #include "lwgeom_pg.h"
 #include "lwgeom_cache.h"
-- 
2.44.0

