Skip to contentSkip to conversation

CMake: Throw a clear error when config.h in top-level source directory

PATCH In review Frank Lichtenheld 3 participants 3 messages Jul 3, 2023 – Jul 4, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 CMake: Throw a clear error when config.h in top-level source directory

This causes weird, difficult to debug compilation errors. Usually caused by trying to run CMake against a source that had an in-tree autoconfig build.

Note that you're able to do out-of-tree autoconfig builds and they can obviously mix with out-of-tree cmake builds.

---
 CMakeLists.txt | 4 ++++
 1 file changed, 4 insertions(+)
CMakeLists.txt +4 -0
index acebbb73..597dc907 100644
@@ -26,6 +26,10 @@ if (NOT WIN32 AND NOT ${UNSUPPORTED_BUILDS})
     message(FATAL_ERROR "Note: on Unix platform the official and supported build method is using autoconfig. CMake based build should be only used for Windows and internal testing/development.")
 endif()
 
+if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/config.h")
+    message(FATAL_ERROR "The top level source directory has a config.h file. Note that you can't mix in-tree autoconfig builds with out-of-tree cmake builds.")
+endif ()
+
 option(MBED "BUILD with mbed" OFF)
 option(WOLFSSL "BUILD with wolfSSL" OFF)
 option(ENABLE_LZ4 "BUILD with lz4" ON)
Signature · 1 line
2.34.1
Acked-by on v1 1/1
#1 lore raw

Am 03.07.23 um 18:39 schrieb Frank Lichtenheld:

Quoted 7 lines

This causes weird, difficult to debug compilation errors. Usually caused by trying to run CMake against a source that had an in-tree autoconfig build.

Note that you're able to do out-of-tree autoconfig builds and they can obviously mix with out-of-tree cmake builds.

#2 lore raw
In reply to Frank Lichtenheld

Sounds & looks reasonable. Not that I could really verify this, or have tested it, but that's what we have an ACK from Arne for :-)

Your patch has been applied to the master branch.

commit 0652ae84f4528daa57da344eee28b7385a6659a1

Author: Frank Lichtenheld
Date:   Mon Jul 3 17:39:25 2023 +0200
     CMake: Throw a clear error when config.h in top-level source directory

     Signed-off-by: Frank Lichtenheld <[email protected]...>
     Acked-by: Arne Schwabe <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg26809.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering