diff mbox series

[meta-oe,PATCHv2] yajl: Add patch for CMake 4+ compatibility and fix build issue

Message ID 20250709211112.663441-1-alperyasinak1@gmail.com
State New
Headers show
Series [meta-oe,PATCHv2] yajl: Add patch for CMake 4+ compatibility and fix build issue | expand

Commit Message

Alper Ak July 9, 2025, 9:11 p.m. UTC
- CMake 3.0 and newer disallow reading the LOCATION property of targets directly.
Instead, use the recommended $<TARGET_FILE:target> generator expression when
referencing the output binary in add_custom_command.

Fixes:

| CMake Error at CMakeLists.txt:15 (CMAKE_MINIMUM_REQUIRED):
|   Compatibility with CMake < 3.5 has been removed from CMake.
|
|   Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
|   to tell CMake that the project requires at least <min> but has been updated
|   to work with policies introduced by <max> or earlier.
|
|   Or, add -DCMAKE_POLICY_VERSION_MINIMUM=3.5 to try configuring anyway.
|
|
| -- Configuring incomplete, errors occurred!

-----

| CMake Error at reformatter/CMakeLists.txt:38 (GET_TARGET_PROPERTY):
|   The LOCATION property may not be read from target "json_reformat".  Use the
|   target name directly with add_custom_command, or use the generator
|   expression $<TARGET_FILE>, as appropriate.
|
|
|
| CMake Error at verify/CMakeLists.txt:32 (GET_TARGET_PROPERTY):
|   The LOCATION property may not be read from target "json_verify".  Use the
|   target name directly with add_custom_command, or use the generator
|   expression $<TARGET_FILE>, as appropriate.

Signed-off-by: Alper Ak <alperyasinak1@gmail.com>
---
 .../yajl/0001-allow-build-with-cmake-4.patch  | 93 +++++++++++++++++++
 meta-oe/recipes-devtools/yajl/yajl_2.1.0.bb   |  2 +-
 2 files changed, 94 insertions(+), 1 deletion(-)
 create mode 100644 meta-oe/recipes-devtools/yajl/yajl/0001-allow-build-with-cmake-4.patch
diff mbox series

Patch

diff --git a/meta-oe/recipes-devtools/yajl/yajl/0001-allow-build-with-cmake-4.patch b/meta-oe/recipes-devtools/yajl/yajl/0001-allow-build-with-cmake-4.patch
new file mode 100644
index 0000000000..78076e5c1e
--- /dev/null
+++ b/meta-oe/recipes-devtools/yajl/yajl/0001-allow-build-with-cmake-4.patch
@@ -0,0 +1,93 @@ 
+From e67398dad70e5d0174ad0eca5c293a5bf1ce1796 Mon Sep 17 00:00:00 2001
+From: Alper Ak <alperyasinak1@gmail.com>
+Date: Thu, 10 Jul 2025 00:00:33 +0300
+Subject: [PATCH] cmake: Set minimum required version to 3.5 for CMake 4+
+ compatibility
+
+CMake 3.0 and newer disallow reading the LOCATION property of targets directly.
+Instead, use the recommended $<TARGET_FILE:target> generator expression when
+referencing the output binary in add_custom_command.
+
+Fix:
+
+| CMake Error at CMakeLists.txt:15 (CMAKE_MINIMUM_REQUIRED):
+|   Compatibility with CMake < 3.5 has been removed from CMake.
+|
+|   Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
+|   to tell CMake that the project requires at least <min> but has been updated
+|   to work with policies introduced by <max> or earlier.
+|
+|   Or, add -DCMAKE_POLICY_VERSION_MINIMUM=3.5 to try configuring anyway.
+|
+|
+| -- Configuring incomplete, errors occurred!
+
+---
+
+| CMake Error at reformatter/CMakeLists.txt:38 (GET_TARGET_PROPERTY):
+|   The LOCATION property may not be read from target "json_reformat".  Use the
+|   target name directly with add_custom_command, or use the generator
+|   expression $<TARGET_FILE>, as appropriate.
+|
+|
+|
+| CMake Error at verify/CMakeLists.txt:32 (GET_TARGET_PROPERTY):
+|   The LOCATION property may not be read from target "json_verify".  Use the
+|   target name directly with add_custom_command, or use the generator
+|   expression $<TARGET_FILE>, as appropriate.
+
+Upstream-Status: Submitted [https://github.com/lloyd/yajl/pull/256]
+
+Signed-off-by: Alper Ak <alperyasinak1@gmail.com>
+---
+ CMakeLists.txt             | 2 +-
+ reformatter/CMakeLists.txt | 4 +---
+ verify/CMakeLists.txt      | 4 +---
+ 3 files changed, 3 insertions(+), 7 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 4c0a9be..e7031c8 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -12,7 +12,7 @@
+ # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ 
+-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
++CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0...3.10)
+ 
+ PROJECT(YetAnotherJSONParser C)
+ 
+diff --git a/reformatter/CMakeLists.txt b/reformatter/CMakeLists.txt
+index 52a9bee..267d02e 100644
+--- a/reformatter/CMakeLists.txt
++++ b/reformatter/CMakeLists.txt
+@@ -35,9 +35,7 @@ IF (NOT WIN32)
+ ENDIF (NOT WIN32)
+ 
+ # copy the binary into the output directory
+-GET_TARGET_PROPERTY(binPath json_reformat LOCATION)
+-
+ ADD_CUSTOM_COMMAND(TARGET json_reformat POST_BUILD
+-    COMMAND ${CMAKE_COMMAND} -E copy_if_different ${binPath} ${binDir})
++    COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:json_reformat> ${binDir})
+ 
+ INSTALL(TARGETS json_reformat RUNTIME DESTINATION bin)
+diff --git a/verify/CMakeLists.txt b/verify/CMakeLists.txt
+index 967fca1..2f39008 100644
+--- a/verify/CMakeLists.txt
++++ b/verify/CMakeLists.txt
+@@ -29,9 +29,7 @@ ADD_EXECUTABLE(json_verify ${SRCS})
+ TARGET_LINK_LIBRARIES(json_verify yajl_s)
+ 
+ # copy in the binary
+-GET_TARGET_PROPERTY(binPath json_verify LOCATION)
+-
+ ADD_CUSTOM_COMMAND(TARGET json_verify POST_BUILD
+-    COMMAND ${CMAKE_COMMAND} -E copy_if_different ${binPath} ${binDir})
++    COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:json_verify> ${binDir})
+ 
+ INSTALL(TARGETS json_verify RUNTIME DESTINATION bin)
+-- 
+2.43.0
+
diff --git a/meta-oe/recipes-devtools/yajl/yajl_2.1.0.bb b/meta-oe/recipes-devtools/yajl/yajl_2.1.0.bb
index e4434bee45..6951e7e705 100644
--- a/meta-oe/recipes-devtools/yajl/yajl_2.1.0.bb
+++ b/meta-oe/recipes-devtools/yajl/yajl_2.1.0.bb
@@ -12,10 +12,10 @@  SRC_URI = "git://github.com/lloyd/yajl;branch=master;protocol=https \
            file://CVE-2017-16516.patch \
            file://CVE-2022-24795.patch \
            file://CVE-2023-33460.patch \
+           file://0001-allow-build-with-cmake-4.patch \
            "
 SRCREV = "a0ecdde0c042b9256170f2f8890dd9451a4240aa"
 
-
 inherit cmake lib_package
 
 EXTRA_OECMAKE = "-DLIB_SUFFIX=${@d.getVar('baselib').replace('lib', '')}"