summaryrefslogtreecommitdiff
path: root/user/muparser/muparser-buildsystem.patch
blob: bd7faa991c1ad0f8bbaa3c5392963d7aebd61675 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..3912058
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,91 @@
+# CMake based on work from @xantares
+cmake_minimum_required(VERSION 3.1)
+project(muParserProject)
+
+include(CTest)
+enable_testing()
+
+# Bump versions on release
+set(MUPARSER_VERSION_MAJOR 2)
+set(MUPARSER_VERSION_MINOR 2)
+set(MUPARSER_VERSION_PATCH 5)
+set(MUPARSER_VERSION ${MUPARSER_VERSION_MAJOR}.${MUPARSER_VERSION_MINOR}.${MUPARSER_VERSION_PATCH})
+
+# Build options
+option(ENABLE_SAMPLES "Build the samples" ON)
+option(ENABLE_OPENMP "Enable OpenMP for multithreading" OFF)
+
+if(ENABLE_OPENMP)
+    find_package(OpenMP REQUIRED)
+    set(CMAKE_CXX_FLAGS "${OpenMP_CXX_FLAGS} ${CMAKE_CXX_FLAGS}")
+    set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "${OpenMP_CXX_FLAGS} ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}")
+endif()
+
+include_directories("${CMAKE_SOURCE_DIR}/include")
+add_library(muparser
+    src/muParserBase.cpp
+    src/muParserBytecode.cpp
+    src/muParserCallback.cpp
+    src/muParser.cpp
+    src/muParserDLL.cpp
+    src/muParserError.cpp
+    src/muParserInt.cpp
+    src/muParserTest.cpp
+    src/muParserTokenReader.cpp
+)
+target_compile_definitions(muparser PRIVATE MUPARSERLIB_EXPORTS)
+if(ENABLE_OPENMP)
+    target_compile_definitions(muparser PRIVATE MUP_USE_OPENMP)
+endif()
+set_target_properties(muparser PROPERTIES
+    VERSION ${MUPARSER_VERSION}
+    SOVERSION ${MUPARSER_VERSION_MAJOR}
+)
+
+# Install the export set for use with the install-tree
+export(TARGETS muparser FILE "${CMAKE_BINARY_DIR}/muparser-targets.cmake")
+
+if(ENABLE_SAMPLES)
+    # the C example does not compile at the moment, because definitions must be
+    # inside external "C" { } to avoid name mangling.
+    #add_executable(example2 samples/example2/example2.c)
+    #target_link_libraries(example2 muparser)
+    
+    add_executable(example1 samples/example1/example1.cpp)
+    target_link_libraries(example1 muparser)
+    add_test(base example1)
+endif()
+
+install(TARGETS muparser DESTINATION lib)
+install(FILES
+    include/muParserBase.h
+    include/muParserBytecode.h
+    include/muParserCallback.h
+    include/muParserDef.h
+    include/muParserDLL.h
+    include/muParserError.h
+    include/muParserFixes.h
+    include/muParser.h
+    include/muParserInt.h
+    include/muParserStack.h
+    include/muParserTemplateMagic.h
+    include/muParserTest.h
+    include/muParserToken.h
+    include/muParserTokenReader.h
+    DESTINATION include
+)
+
+# Define variables for the pkg-config file
+# The GNUInstallDirs defines ${CMAKE_INSTALL_DATAROOTDIR}
+# See https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html
+include(GNUInstallDirs)
+set(PACKAGE_NAME muparser)
+configure_file(
+    "${CMAKE_SOURCE_DIR}/build/autoconf/muparser.pc.cmakein"
+    "${CMAKE_BINARY_DIR}/muparser.pc"
+    @ONLY
+)
+install(
+    FILES "${CMAKE_BINARY_DIR}/muparser.pc"
+    DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
+)
diff --git a/build/autoconf/muparser.pc.cmakein b/build/autoconf/muparser.pc.cmakein
new file mode 100644
index 0000000..be535ff
--- /dev/null
+++ b/build/autoconf/muparser.pc.cmakein
@@ -0,0 +1,11 @@
+prefix=@CMAKE_INSTALL_PREFIX@
+exec_prefix=${prefix}
+libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
+includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
+
+Name: @PACKAGE_NAME@
+Description: Mathematical expressions parser library
+Version: @MUPARSER_VERSION@
+Requires:
+Libs: -L${libdir} -lmuparser
+Cflags: -I${includedir}