diff mbox series

[meta-openembedded,09/20] yajl: Add patch for CMake 4+ compatibility and fix build issue

Message ID 20250708195636.1678606-9-alperyasinak1@gmail.com
State Accepted
Headers show
Series [meta-openembedded,01/20] cannelloni: Upgrade 1.1.0 -> 2.0.0 to allow CMake 4+ compatibility | expand

Commit Message

Alper Ak July 8, 2025, 7:56 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  | 43 ++++++++++++
 ..._FILE-instead-of-LOCATION-property-f.patch | 67 +++++++++++++++++++
 meta-oe/recipes-devtools/yajl/yajl_2.1.0.bb   |  3 +-
 3 files changed, 112 insertions(+), 1 deletion(-)
 create mode 100644 meta-oe/recipes-devtools/yajl/yajl/0001-allow-build-with-cmake-4.patch
 create mode 100644 meta-oe/recipes-devtools/yajl/yajl/0002-cmake-Use-TARGET_FILE-instead-of-LOCATION-property-f.patch

Comments

Gyorgy Sarvari July 9, 2025, 10:43 a.m. UTC | #1
On 7/8/25 21:56, Alper Ak via lists.openembedded.org wrote:
> +++ b/meta-oe/recipes-devtools/yajl/yajl/0001-allow-build-with-cmake-4.patch
> +Upstream-Status: Submitted [https://github.com/lloyd/yajl/pull/256]

Yes, okay, but...

> +
> +++ b/meta-oe/recipes-devtools/yajl/yajl/0002-cmake-Use-TARGET_FILE-instead-of-LOCATION-property-f.patch
> +Upstream-Status: Pending
> +
...this other patch is in the very same PR referenced in the first
patch, but the status is different. Shouldn't this be "Submitted" also,
like above?
Alper Ak July 9, 2025, 10:52 a.m. UTC | #2
> ...this other patch is in the very same PR referenced in the first
> patch, but the status is different. Shouldn't this be "Submitted" also,
> like above?

Yes, it should be as you say. It even makes more sense to do it with a
single patch. I will send a fix.


Gyorgy Sarvari <skandigraun@gmail.com>, 9 Tem 2025 Çar, 13:43
tarihinde şunu yazdı:
>
> On 7/8/25 21:56, Alper Ak via lists.openembedded.org wrote:
> > +++ b/meta-oe/recipes-devtools/yajl/yajl/0001-allow-build-with-cmake-4.patch
> > +Upstream-Status: Submitted [https://github.com/lloyd/yajl/pull/256]
>
> Yes, okay, but...
>
> > +
> > +++ b/meta-oe/recipes-devtools/yajl/yajl/0002-cmake-Use-TARGET_FILE-instead-of-LOCATION-property-f.patch
> > +Upstream-Status: Pending
> > +
> ...this other patch is in the very same PR referenced in the first
> patch, but the status is different. Shouldn't this be "Submitted" also,
> like above?
Alper Ak July 9, 2025, 9:12 p.m. UTC | #3
Sent a v2 patch ->
https://lists.openembedded.org/g/openembedded-devel/message/118386

Alper Ak <alperyasinak1@gmail.com>, 9 Tem 2025 Çar, 13:52 tarihinde şunu yazdı:
>
> > ...this other patch is in the very same PR referenced in the first
> > patch, but the status is different. Shouldn't this be "Submitted" also,
> > like above?
>
> Yes, it should be as you say. It even makes more sense to do it with a
> single patch. I will send a fix.
>
>
> Gyorgy Sarvari <skandigraun@gmail.com>, 9 Tem 2025 Çar, 13:43
> tarihinde şunu yazdı:
> >
> > On 7/8/25 21:56, Alper Ak via lists.openembedded.org wrote:
> > > +++ b/meta-oe/recipes-devtools/yajl/yajl/0001-allow-build-with-cmake-4.patch
> > > +Upstream-Status: Submitted [https://github.com/lloyd/yajl/pull/256]
> >
> > Yes, okay, but...
> >
> > > +
> > > +++ b/meta-oe/recipes-devtools/yajl/yajl/0002-cmake-Use-TARGET_FILE-instead-of-LOCATION-property-f.patch
> > > +Upstream-Status: Pending
> > > +
> > ...this other patch is in the very same PR referenced in the first
> > patch, but the status is different. Shouldn't this be "Submitted" also,
> > like above?
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..c62a846da9
--- /dev/null
+++ b/meta-oe/recipes-devtools/yajl/yajl/0001-allow-build-with-cmake-4.patch
@@ -0,0 +1,43 @@ 
+From 3dfd5276ab30ba7f6820cd4585d390c3706684b0 Mon Sep 17 00:00:00 2001
+From: Alper Ak <alperyasinak1@gmail.com>
+Date: Tue, 8 Jul 2025 18:17:56 +0300
+Subject: [PATCH] cmake: Set minimum required version to 3.5 for CMake 4+
+ compatibility
+
+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!
+
+Upstream-Status: Submitted [https://github.com/lloyd/yajl/pull/256]
+
+Signed-off-by: Alper Ak <alperyasinak1@gmail.com>
+---
+ CMakeLists.txt | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 4c0a9be..a49e52c 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 3.5)
+ 
+ PROJECT(YetAnotherJSONParser C)
+ 
+-- 
+2.43.0
+
diff --git a/meta-oe/recipes-devtools/yajl/yajl/0002-cmake-Use-TARGET_FILE-instead-of-LOCATION-property-f.patch b/meta-oe/recipes-devtools/yajl/yajl/0002-cmake-Use-TARGET_FILE-instead-of-LOCATION-property-f.patch
new file mode 100644
index 0000000000..8b64ffd7d1
--- /dev/null
+++ b/meta-oe/recipes-devtools/yajl/yajl/0002-cmake-Use-TARGET_FILE-instead-of-LOCATION-property-f.patch
@@ -0,0 +1,67 @@ 
+From 1b07726910d4ff7ce1829845471a066bb97dd411 Mon Sep 17 00:00:00 2001
+From: Alper Ak <alperyasinak1@gmail.com>
+Date: Tue, 8 Jul 2025 18:33:48 +0300
+Subject: [PATCH] cmake: Use $<TARGET_FILE> instead of LOCATION property for
+ binary path
+
+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 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: Pending
+
+Signed-off-by: Alper Ak <alperyasinak1@gmail.com>
+---
+ reformatter/CMakeLists.txt | 5 +----
+ verify/CMakeLists.txt      | 5 +----
+ 2 files changed, 2 insertions(+), 8 deletions(-)
+
+diff --git a/reformatter/CMakeLists.txt b/reformatter/CMakeLists.txt
+index 52a9bee..b202fa5 100644
+--- a/reformatter/CMakeLists.txt
++++ b/reformatter/CMakeLists.txt
+@@ -34,10 +34,7 @@ IF (NOT WIN32)
+     TARGET_LINK_LIBRARIES(json_reformat m)
+ 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..37eac62 100644
+--- a/verify/CMakeLists.txt
++++ b/verify/CMakeLists.txt
+@@ -28,10 +28,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..8c0d84f811 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,11 @@  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 \
+           file://0002-cmake-Use-TARGET_FILE-instead-of-LOCATION-property-f.patch \
            "
 SRCREV = "a0ecdde0c042b9256170f2f8890dd9451a4240aa"
 
-
 inherit cmake lib_package
 
 EXTRA_OECMAKE = "-DLIB_SUFFIX=${@d.getVar('baselib').replace('lib', '')}"