From e633f9ed1558fe1e8aa026af2932a1d06b8beadb Mon Sep 17 00:00:00 2001
From: Alexey Rusakov <Kitsune-Ral@users.sf.net>
Date: Wed, 13 Oct 2021 10:00:15 +0200
Subject: CMakeLists: don't report that update-api is enabled when it's
 actually not

add_feature_info() treats unset variable as "no change" rather than
"false", which may lead to a confusing build configuration report when
GTAD_PATH and/or MATRIX_DOC_PATH and/or CLANG_FORMAT have been there
before but were removed since.
---
 CMakeLists.txt | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

(limited to 'CMakeLists.txt')

diff --git a/CMakeLists.txt b/CMakeLists.txt
index bae833c3..30bab53a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -179,6 +179,8 @@ set(FULL_CSAPI_DIR lib/${CSAPI_DIR})
 set(ASAPI_DEF_DIR application-service/definitions)
 set(ISAPI_DEF_DIR identity/definitions)
 
+set(API_GENERATION_ENABLED 0)
+set(API_FORMATTING_ENABLED 0)
 if (GTAD_PATH AND MATRIX_DOC_PATH)
     get_filename_component(ABS_GTAD_PATH "${GTAD_PATH}" PROGRAM PROGRAM_ARGS GTAD_ARGS)
     if (EXISTS ${ABS_GTAD_PATH})
@@ -264,8 +266,10 @@ if (API_GENERATION_ENABLED)
 endif()
 add_feature_info(EnableApiCodeGeneration "${API_GENERATION_ENABLED}"
                  "build target update-api")
-add_feature_info(EnableApiFormatting "${API_FORMATTING_ENABLED}"
-                 "formatting of generated API files with clang-format")
+if (API_GENERATION_ENABLED)
+    add_feature_info(EnableApiFormatting "${API_FORMATTING_ENABLED}"
+                     "formatting of generated API files with clang-format")
+endif()
 
 # Make no mistake: CMake cannot run gtad first and then populate the list of
 # resulting api_SRCS files. In other words, placing the below statement after
-- 
cgit v1.2.3


From f620284bac23bb86c329863c53f3699845bf606f Mon Sep 17 00:00:00 2001
From: Alexey Rusakov <Kitsune-Ral@users.sf.net>
Date: Wed, 13 Oct 2021 10:16:39 +0200
Subject: CMakeLists: more robust GTAD_PATH detection

After switching over to get_filename_component(PROGRAM) paths with
~ (home directory) were no more resolved. They are again.
---
 CMakeLists.txt | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

(limited to 'CMakeLists.txt')

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 30bab53a..34200548 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -182,7 +182,9 @@ set(ISAPI_DEF_DIR identity/definitions)
 set(API_GENERATION_ENABLED 0)
 set(API_FORMATTING_ENABLED 0)
 if (GTAD_PATH AND MATRIX_DOC_PATH)
-    get_filename_component(ABS_GTAD_PATH "${GTAD_PATH}" PROGRAM PROGRAM_ARGS GTAD_ARGS)
+    # REALPATH resolves ~ (home directory) while PROGRAM doesn't
+    get_filename_component(ABS_GTAD_PATH "${GTAD_PATH}" REALPATH)
+    get_filename_component(ABS_GTAD_PATH "${ABS_GTAD_PATH}" PROGRAM PROGRAM_ARGS GTAD_ARGS)
     if (EXISTS ${ABS_GTAD_PATH})
         get_filename_component(ABS_API_DEF_PATH "${MATRIX_DOC_PATH}/data/api" REALPATH)
         if (NOT IS_DIRECTORY ${ABS_API_DEF_PATH})
@@ -195,7 +197,7 @@ if (GTAD_PATH AND MATRIX_DOC_PATH)
             message( WARNING "${MATRIX_DOC_PATH} doesn't seem to point to a valid matrix-doc repo; disabling API stubs generation")
         endif ()
     else (EXISTS ${ABS_GTAD_PATH})
-        message( WARNING "${GTAD_PATH} doesn't exist; disabling API stubs generation")
+        message( WARNING "${GTAD_PATH} is not executable; disabling API stubs generation")
     endif ()
 endif ()
 if (API_GENERATION_ENABLED)
-- 
cgit v1.2.3