Gentoo Archives: gentoo-commits

From: Alexey Shvetsov <alexxy@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-cpp/muParser/, dev-cpp/muParser/files/
Date: Sun, 07 Nov 2021 19:59:56
Message-Id: 1636315152.95c35c5f43f6c712154ea3cb35e735dea39eeddd.alexxy@gentoo
1 commit: 95c35c5f43f6c712154ea3cb35e735dea39eeddd
2 Author: Alexey Shvetsov <alexxy <AT> gentoo <DOT> org>
3 AuthorDate: Sun Nov 7 19:58:46 2021 +0000
4 Commit: Alexey Shvetsov <alexxy <AT> gentoo <DOT> org>
5 CommitDate: Sun Nov 7 19:59:12 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=95c35c5f
7
8 dev-cpp/muParser: Fix cmake export target
9
10 Closes: https://bugs.gentoo.org/821718
11
12 Package-Manager: Portage-3.0.28, Repoman-3.0.3
13 Signed-off-by: Alexey Shvetsov <alexxy <AT> gentoo.org>
14
15 .../muParser/files/muParser-2.3-export-cmake.patch | 405 +++++++++++++++++++++
16 ...arser-2.3.2.ebuild => muParser-2.3.2-r1.ebuild} | 2 +
17 2 files changed, 407 insertions(+)
18
19 diff --git a/dev-cpp/muParser/files/muParser-2.3-export-cmake.patch b/dev-cpp/muParser/files/muParser-2.3-export-cmake.patch
20 new file mode 100644
21 index 00000000000..79254626db6
22 --- /dev/null
23 +++ b/dev-cpp/muParser/files/muParser-2.3-export-cmake.patch
24 @@ -0,0 +1,405 @@
25 +From a9e6626c9b2e250eb9161c767d2fb2e5a07315e2 Mon Sep 17 00:00:00 2001
26 +From: Francis Giraldeau <francis.giraldeau@×××××××××××.ca>
27 +Date: Wed, 8 Jul 2020 14:59:27 -0400
28 +Subject: [PATCH] Export muparser cmake targets
29 +
30 +Export muparser targets, such that client projects can
31 +import it using find_package(). This mechanism for both the build tree
32 +and the install tree. The provided example3 shows how to import muparser
33 +targets.
34 +
35 +Signed-off-by: Francis Giraldeau <francis.giraldeau@×××××××××××.ca>
36 +Signed-off-by: Alexey Shvetsov <alexxy@g.o>
37 +---
38 + CMakeLists.txt | 39 ++++++-
39 + CMakeLists.txt.orig | 173 ++++++++++++++++++++++++++++++++
40 + muparserConfig.cmake.in | 6 ++
41 + samples/example3/CMakeLists.txt | 12 +++
42 + samples/example3/README.md | 2 +
43 + samples/example3/build.sh | 23 +++++
44 + samples/example3/example3.cpp | 49 +++++++++
45 + 7 files changed, 301 insertions(+), 3 deletions(-)
46 + create mode 100644 CMakeLists.txt.orig
47 + create mode 100644 muparserConfig.cmake.in
48 + create mode 100644 samples/example3/CMakeLists.txt
49 + create mode 100644 samples/example3/README.md
50 + create mode 100755 samples/example3/build.sh
51 + create mode 100644 samples/example3/example3.cpp
52 +
53 +diff --git a/CMakeLists.txt b/CMakeLists.txt
54 +index cfdce99..aecc67d 100644
55 +--- a/CMakeLists.txt
56 ++++ b/CMakeLists.txt
57 +@@ -55,6 +55,11 @@ add_library(muparser
58 + src/muParserTest.cpp
59 + src/muParserTokenReader.cpp
60 + )
61 ++# use the headers in the build-tree or the installed ones
62 ++target_include_directories(muparser PUBLIC
63 ++ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
64 ++ $<INSTALL_INTERFACE:include>
65 ++)
66 +
67 + # this compiles the "DLL" interface (C API)
68 + target_compile_definitions(muparser PRIVATE MUPARSER_DLL)
69 +@@ -77,9 +82,6 @@ set_target_properties(muparser PROPERTIES
70 + SOVERSION ${MUPARSER_VERSION_MAJOR}
71 + )
72 +
73 +-# Install the export set for use with the install-tree
74 +-export(TARGETS muparser FILE "${CMAKE_BINARY_DIR}/muparser-targets.cmake")
75 +-
76 + if(ENABLE_SAMPLES)
77 + add_executable(example1 samples/example1/example1.cpp)
78 + target_link_libraries(example1 muparser)
79 +@@ -91,8 +93,10 @@ endif()
80 + # The GNUInstallDirs defines ${CMAKE_INSTALL_DATAROOTDIR}
81 + # See https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html
82 + include (GNUInstallDirs)
83 ++set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/muparser)
84 +
85 + install(TARGETS muparser
86 ++ EXPORT muparser-export
87 + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT RuntimeLibraries
88 + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Development
89 + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT RuntimeLibraries
90 +@@ -116,6 +120,35 @@ install(FILES
91 + COMPONENT Development
92 + )
93 +
94 ++# Export the target under the build-tree (no need to install)
95 ++export(EXPORT muparser-export
96 ++ FILE "${CMAKE_BINARY_DIR}/muparser-targets.cmake"
97 ++ NAMESPACE muparser::
98 ++)
99 ++
100 ++# Export the installed target (typically for packaging)
101 ++include(CMakePackageConfigHelpers)
102 ++write_basic_package_version_file(
103 ++ "${CMAKE_CURRENT_BINARY_DIR}/muparserConfigVersion.cmake"
104 ++ VERSION ${MUPARSER_VERSION}
105 ++ COMPATIBILITY AnyNewerVersion
106 ++)
107 ++configure_file(muparserConfig.cmake.in
108 ++ "${CMAKE_CURRENT_BINARY_DIR}/muparserConfig.cmake"
109 ++ COPYONLY
110 ++)
111 ++install(EXPORT muparser-export
112 ++ FILE muparser-targets.cmake
113 ++ NAMESPACE muparser::
114 ++ DESTINATION ${INSTALL_CONFIGDIR}
115 ++)
116 ++install(FILES
117 ++ ${CMAKE_CURRENT_BINARY_DIR}/muparserConfig.cmake
118 ++ ${CMAKE_CURRENT_BINARY_DIR}/muparserConfigVersion.cmake
119 ++ DESTINATION ${INSTALL_CONFIGDIR}
120 ++ COMPONENT Development
121 ++)
122 ++
123 + # Define variables for the pkg-config file
124 + set(PACKAGE_NAME muparser)
125 + configure_file(
126 +diff --git a/CMakeLists.txt.orig b/CMakeLists.txt.orig
127 +new file mode 100644
128 +index 0000000..b496584
129 +--- /dev/null
130 ++++ b/CMakeLists.txt.orig
131 +@@ -0,0 +1,173 @@
132 ++# CMake based on work from @xantares
133 ++cmake_minimum_required (VERSION 3.1.0)
134 ++set(CMAKE_CXX_STANDARD 11)
135 ++set(CMAKE_CXX_STANDARD_REQUIRED ON)
136 ++
137 ++# By default, build in Release mode. Must appear before project() command
138 ++if (NOT DEFINED CMAKE_BUILD_TYPE)
139 ++ set (CMAKE_BUILD_TYPE Release CACHE STRING "Build type")
140 ++endif ()
141 ++
142 ++project(muParserProject)
143 ++
144 ++
145 ++
146 ++# Bump versions on release
147 ++set(MUPARSER_VERSION_MAJOR 2)
148 ++set(MUPARSER_VERSION_MINOR 3)
149 ++set(MUPARSER_VERSION_PATCH 2)
150 ++set(MUPARSER_VERSION ${MUPARSER_VERSION_MAJOR}.${MUPARSER_VERSION_MINOR}.${MUPARSER_VERSION_PATCH})
151 ++
152 ++# Build options
153 ++option(ENABLE_SAMPLES "Build the samples" ON)
154 ++option(ENABLE_OPENMP "Enable OpenMP for multithreading" ON)
155 ++option(BUILD_SHARED_LIBS "Build shared/static libs" ON)
156 ++
157 ++if(ENABLE_OPENMP)
158 ++ find_package(OpenMP REQUIRED)
159 ++ set(CMAKE_CXX_FLAGS "${OpenMP_CXX_FLAGS} ${CMAKE_CXX_FLAGS}")
160 ++ set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "${OpenMP_CXX_FLAGS} ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}")
161 ++endif()
162 ++
163 ++
164 ++# Credit: https://stackoverflow.com/questions/2368811/how-to-set-warning-level-in-cmake/3818084
165 ++if(MSVC)
166 ++ # Force to always compile with W4
167 ++ if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
168 ++ string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
169 ++ else()
170 ++ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
171 ++ endif()
172 ++elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
173 ++ # Update if necessary
174 ++ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long -pedantic")
175 ++endif()
176 ++
177 ++include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include")
178 ++add_library(muparser
179 ++ src/muParserBase.cpp
180 ++ src/muParserBytecode.cpp
181 ++ src/muParserCallback.cpp
182 ++ src/muParser.cpp
183 ++ src/muParserDLL.cpp
184 ++ src/muParserError.cpp
185 ++ src/muParserInt.cpp
186 ++ src/muParserTest.cpp
187 ++ src/muParserTokenReader.cpp
188 ++)
189 ++<<<<<<< HEAD
190 ++=======
191 ++# use the headers in the build-tree or the installed ones
192 ++target_include_directories(muparser PUBLIC
193 ++ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
194 ++ $<INSTALL_INTERFACE:include>
195 ++)
196 ++>>>>>>> e259981 (Export muparser cmake targets)
197 ++
198 ++# this compiles the "DLL" interface (C API)
199 ++target_compile_definitions(muparser PRIVATE MUPARSER_DLL)
200 ++
201 ++if (BUILD_SHARED_LIBS)
202 ++ target_compile_definitions(muparser PRIVATE MUPARSERLIB_EXPORTS)
203 ++else ()
204 ++ target_compile_definitions(muparser PUBLIC MUPARSER_STATIC)
205 ++endif()
206 ++
207 ++if (CMAKE_BUILD_TYPE STREQUAL Debug)
208 ++ target_compile_definitions(muparser PRIVATE _DEBUG)
209 ++endif ()
210 ++
211 ++if(ENABLE_OPENMP)
212 ++ target_compile_definitions(muparser PRIVATE MUP_USE_OPENMP)
213 ++endif()
214 ++set_target_properties(muparser PROPERTIES
215 ++ VERSION ${MUPARSER_VERSION}
216 ++ SOVERSION ${MUPARSER_VERSION_MAJOR}
217 ++)
218 ++
219 ++if(ENABLE_SAMPLES)
220 ++ add_executable(example1 samples/example1/example1.cpp)
221 ++ target_link_libraries(example1 muparser)
222 ++
223 ++ add_executable(example2 samples/example2/example2.c)
224 ++ target_link_libraries(example2 muparser)
225 ++endif()
226 ++
227 ++# The GNUInstallDirs defines ${CMAKE_INSTALL_DATAROOTDIR}
228 ++# See https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html
229 ++include (GNUInstallDirs)
230 ++set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/muparser)
231 ++
232 ++install(TARGETS muparser
233 ++ EXPORT muparser-export
234 ++ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT RuntimeLibraries
235 ++ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT Development
236 ++ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT RuntimeLibraries
237 ++)
238 ++
239 ++install(FILES
240 ++ include/muParserBase.h
241 ++ include/muParserBytecode.h
242 ++ include/muParserCallback.h
243 ++ include/muParserDef.h
244 ++ include/muParserDLL.h
245 ++ include/muParserError.h
246 ++ include/muParserFixes.h
247 ++ include/muParser.h
248 ++ include/muParserInt.h
249 ++ include/muParserTemplateMagic.h
250 ++ include/muParserTest.h
251 ++ include/muParserToken.h
252 ++ include/muParserTokenReader.h
253 ++ DESTINATION include
254 ++ COMPONENT Development
255 ++)
256 ++
257 ++# Export the target under the build-tree (no need to install)
258 ++export(EXPORT muparser-export
259 ++ FILE "${CMAKE_BINARY_DIR}/muparser-targets.cmake"
260 ++ NAMESPACE muparser::
261 ++)
262 ++
263 ++# Export the installed target (typically for packaging)
264 ++include(CMakePackageConfigHelpers)
265 ++write_basic_package_version_file(
266 ++ "${CMAKE_CURRENT_BINARY_DIR}/muparserConfigVersion.cmake"
267 ++ VERSION ${MUPARSER_VERSION}
268 ++ COMPATIBILITY AnyNewerVersion
269 ++)
270 ++configure_file(muparserConfig.cmake.in
271 ++ "${CMAKE_CURRENT_BINARY_DIR}/muparserConfig.cmake"
272 ++ COPYONLY
273 ++)
274 ++install(EXPORT muparser-export
275 ++ FILE muparser-targets.cmake
276 ++ NAMESPACE muparser::
277 ++ DESTINATION ${INSTALL_CONFIGDIR}
278 ++)
279 ++install(FILES
280 ++ ${CMAKE_CURRENT_BINARY_DIR}/muparserConfig.cmake
281 ++ ${CMAKE_CURRENT_BINARY_DIR}/muparserConfigVersion.cmake
282 ++ DESTINATION ${INSTALL_CONFIGDIR}
283 ++ COMPONENT Development
284 ++)
285 ++
286 ++# Define variables for the pkg-config file
287 ++set(PACKAGE_NAME muparser)
288 ++configure_file(
289 ++ muparser.pc.in
290 ++ ${CMAKE_BINARY_DIR}/muparser.pc
291 ++ @ONLY
292 ++)
293 ++install(
294 ++ FILES ${CMAKE_BINARY_DIR}/muparser.pc
295 ++ DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
296 ++)
297 ++
298 ++include(CTest)
299 ++enable_testing()
300 ++
301 ++add_executable (t_ParserTest test/t_ParserTest.cpp)
302 ++target_link_libraries(t_ParserTest muparser)
303 ++add_test (NAME ParserTest COMMAND t_ParserTest)
304 ++
305 +diff --git a/muparserConfig.cmake.in b/muparserConfig.cmake.in
306 +new file mode 100644
307 +index 0000000..6a28a5e
308 +--- /dev/null
309 ++++ b/muparserConfig.cmake.in
310 +@@ -0,0 +1,6 @@
311 ++get_filename_component(muparser_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
312 ++include(CMakeFindDependencyMacro)
313 ++
314 ++if(NOT TARGET muparser::muparser)
315 ++ include("${muparser_CMAKE_DIR}/muparser-targets.cmake")
316 ++endif()
317 +diff --git a/samples/example3/CMakeLists.txt b/samples/example3/CMakeLists.txt
318 +new file mode 100644
319 +index 0000000..0049c3e
320 +--- /dev/null
321 ++++ b/samples/example3/CMakeLists.txt
322 +@@ -0,0 +1,12 @@
323 ++cmake_minimum_required(VERSION 3.2)
324 ++project(muparser-example3)
325 ++
326 ++# find muparser target already installed
327 ++find_package(muparser 2.0 REQUIRED)
328 ++
329 ++add_executable(example3 example3.cpp)
330 ++target_link_libraries(example3 muparser::muparser)
331 ++
332 ++include(CTest)
333 ++add_test(example3 example3)
334 ++
335 +diff --git a/samples/example3/README.md b/samples/example3/README.md
336 +new file mode 100644
337 +index 0000000..73e15d4
338 +--- /dev/null
339 ++++ b/samples/example3/README.md
340 +@@ -0,0 +1,2 @@
341 ++The example3 shows how to import and use muparser as an installed external
342 ++dependency using cmake `find_package()`.
343 +diff --git a/samples/example3/build.sh b/samples/example3/build.sh
344 +new file mode 100755
345 +index 0000000..289fac9
346 +--- /dev/null
347 ++++ b/samples/example3/build.sh
348 +@@ -0,0 +1,23 @@
349 ++#!/bin/bash -x
350 ++
351 ++CWD="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
352 ++MP_SOURCES=${CWD}/../../
353 ++MP_BUILD=${CWD}/muparser-build
354 ++MP_INSTALL=${CWD}/muparser-install
355 ++EX3_BUILD_TREE=${CWD}/example3-using-buildtree
356 ++EX3_INSTALL_TREE=${CWD}/example3-using-installtree
357 ++
358 ++# Build muparser and install it
359 ++cmake -H${MP_SOURCES} -B${MP_BUILD} -DCMAKE_INSTALL_PREFIX=${MP_INSTALL}
360 ++cmake --build ${MP_BUILD} --target install
361 ++
362 ++# Build the example using muparser build tree
363 ++cmake -H${CWD} -B${EX3_BUILD_TREE} -DCMAKE_PREFIX_PATH=${MP_BUILD}
364 ++cmake --build ${EX3_BUILD_TREE} --target all
365 ++cmake --build ${EX3_BUILD_TREE} --target test
366 ++
367 ++# Build the example using muparser install tree
368 ++cmake -H${CWD} -B${EX3_INSTALL_TREE} -DCMAKE_PREFIX_PATH=${MP_INSTALL}
369 ++cmake --build ${EX3_INSTALL_TREE} --target all
370 ++cmake --build ${EX3_INSTALL_TREE} --target test
371 ++
372 +diff --git a/samples/example3/example3.cpp b/samples/example3/example3.cpp
373 +new file mode 100644
374 +index 0000000..78df86f
375 +--- /dev/null
376 ++++ b/samples/example3/example3.cpp
377 +@@ -0,0 +1,49 @@
378 ++/*
379 ++
380 ++ _____ __ _____________ _______ ______ ___________
381 ++ / \| | \____ \__ \\_ __ \/ ___// __ \_ __ \
382 ++ | Y Y \ | / |_> > __ \| | \/\___ \\ ___/| | \/
383 ++ |__|_| /____/| __(____ /__| /____ >\___ >__|
384 ++ \/ |__| \/ \/ \/
385 ++ Copyright (C) 2004 - 2020 Ingo Berg
386 ++
387 ++ Redistribution and use in source and binary forms, with or without modification, are permitted
388 ++ provided that the following conditions are met:
389 ++
390 ++ * Redistributions of source code must retain the above copyright notice, this list of
391 ++ conditions and the following disclaimer.
392 ++ * Redistributions in binary form must reproduce the above copyright notice, this list of
393 ++ conditions and the following disclaimer in the documentation and/or other materials provided
394 ++ with the distribution.
395 ++
396 ++ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
397 ++ IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
398 ++ FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
399 ++ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
400 ++ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
401 ++ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
402 ++ IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
403 ++ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
404 ++*/
405 ++
406 ++// Small example using the cmake imported target. Include file and link library
407 ++// should work automagically.
408 ++
409 ++#include <muParser.h>
410 ++#include <muParserDef.h>
411 ++
412 ++int main()
413 ++{
414 ++ mu::Parser parser;
415 ++
416 ++ mu::value_type values[] = { 1, 2 };
417 ++ parser.DefineVar("a", &values[0]);
418 ++ parser.DefineVar("b", &values[1]);
419 ++
420 ++ std::string expr = "a + b";
421 ++ parser.SetExpr("a + b");
422 ++ mu::value_type ans = parser.Eval();
423 ++ std::cout << expr << " == " << ans << "\n";
424 ++
425 ++ return (ans == 3.0) ? 0 : -1;
426 ++}
427 +--
428 +2.33.1
429 +
430
431 diff --git a/dev-cpp/muParser/muParser-2.3.2.ebuild b/dev-cpp/muParser/muParser-2.3.2-r1.ebuild
432 similarity index 92%
433 rename from dev-cpp/muParser/muParser-2.3.2.ebuild
434 rename to dev-cpp/muParser/muParser-2.3.2-r1.ebuild
435 index 8e282638dbf..010002a56d2 100644
436 --- a/dev-cpp/muParser/muParser-2.3.2.ebuild
437 +++ b/dev-cpp/muParser/muParser-2.3.2-r1.ebuild
438 @@ -16,6 +16,8 @@ KEYWORDS="~amd64 ~arm ~arm64 ~ppc ~ppc64 ~riscv ~x86 ~amd64-linux ~x86-linux ~pp
439 IUSE="doc openmp test"
440 RESTRICT="!test? ( test )"
441
442 +PATCHES=( "${FILESDIR}/muParser-2.3-export-cmake.patch" )
443 +
444 src_configure() {
445 mycmakeargs=(
446 -DENABLE_OPENMP=$(usex openmp)