[mathgl] Update, fix cmake config, dependencies, linkage, usage (#28311)

* Fix mathgl confix fixup

* Control library linkage

* Fix dependencies

* Revise tool installation

* Install usage doc

* Reduce config warnings

* Don't pick up gettext

* Fix osx

* Cross-builds partially unsupported

* uwp unsupported

* Devendor getopt

* No _CRT_STDIO_ISO_WIDE_SPECIFIERS

* Fix mgllab

* Fix glut

* Cleanup

* Update to 8.0.1

* Control building of examples

* Fix examples

* Add vcpkg-ci-mathgl test port

* Update versions

* Trim qt5 dependency

* Trim non-trivial dependencies

* Fix cross builds

* CR changes
This commit is contained in:
Kai Pastor 2023-01-07 09:59:30 +01:00 committed by GitHub
parent 12c2a93b40
commit 797256da29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 779 additions and 179 deletions

View File

@ -0,0 +1,39 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2a73d0f..fda5ba1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -51,6 +51,7 @@ endif()
set(MathGL_INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH "Installation directory for CMake files")
# Make relative paths absolute (needed later on)
foreach(p LIB BIN INCLUDE CMAKE)
+ break() # Absolute paths break config fixup for tools
set(var MathGL_INSTALL_${p}_DIR)
if(NOT IS_ABSOLUTE "${${var}}")
set(${var} "${CMAKE_INSTALL_PREFIX}/${${var}}")
diff --git a/scripts/MathGLConfig.cmake.in b/scripts/MathGLConfig.cmake.in
index f219126..2a9f58b 100644
--- a/scripts/MathGLConfig.cmake.in
+++ b/scripts/MathGLConfig.cmake.in
@@ -1,15 +1,19 @@
# - Config file for the MathGL package
# It defines the following variables
-set(MathGL2_INCLUDE_DIRS "@MathGL_INSTALL_INCLUDE_DIR@")
-set(MathGL2_LIBRARIES_DIRS "@MathGL_INSTALL_LIB_DIR@")
+set(MathGL2_INCLUDE_DIRS "@CMAKE_INSTALL_PREFIX@/@MathGL_INSTALL_INCLUDE_DIR@")
+if(CMAKE_BUILD_TYPE MATCHES "[Dd][Ee][Bb][Uu][Gg]")
+ set(MathGL2_LIBRARIES_DIRS "@CMAKE_INSTALL_PREFIX@/debug/@MathGL_INSTALL_LIB_DIR@")
+else()
+ set(MathGL2_LIBRARIES_DIRS "@CMAKE_INSTALL_PREFIX@/@MathGL_INSTALL_LIB_DIR@")
+endif()
set(MathGL2_HAVE_QT5 "@enable-qt5@")
set(MathGL2_HAVE_QT4 "@enable-qt4@")
set(MathGL2_HAVE_WX "@enable-wx@")
set(MathGL2_HAVE_FLTK "@enable-fltk@")
set(MathGL2_HAVE_GLUT "@enable-glut@")
set(MathGL2_HAVE_PTHREAD "@CMAKE_USE_PTHREADS_INIT@")
-set(MathGL2_HAVE_OPENMP "@OPENMP_FOUND@")
+set(MathGL2_HAVE_OPENMP "@enable-openmp@")
include(CMakeFindDependencyMacro)
# Adding dependency for Threads imported target

View File

@ -0,0 +1,5 @@
if(WIN32 AND NOT MINGW)
find_package(unofficial-getopt-win32 REQUIRED)
set(getopt_lib-static unofficial::getopt-win32::getopt)
set(MGL_HAVE_GETOPT 1 CACHE INTERNAL "From vcpkg")
endif()

View File

@ -0,0 +1,118 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 466e9bc..d99c1e4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -441,9 +441,10 @@ else(enable-pthr-widget OR enable-pthread)
endif(enable-pthr-widget OR enable-pthread)
if(enable-arma)
- find_package(Armadillo)
+ find_package(Armadillo CONFIG REQUIRED)
if(ARMADILLO_FOUND)
set(MGL_HAVE_ARMA 1)
+ list(APPEND MGL_DEP_LIBS armadillo)
else(ARMADILLO_FOUND)
set(MGL_HAVE_ARMA 0)
endif(ARMADILLO_FOUND)
@@ -548,7 +549,7 @@ endif(enable-hdf5)
if(enable-jpeg)
set(MGL_HAVE_JPEG 1)
- include(FindJPEG)
+ find_package(JPEG)
if(NOT JPEG_FOUND)
message(SEND_ERROR "Couldn't find JPEG library.")
endif(NOT JPEG_FOUND)
@@ -561,7 +562,7 @@ endif(enable-jpeg)
if(enable-zlib)
set(MGL_HAVE_ZLIB 1)
- include(FindZLIB)
+ find_package(ZLIB)
if(NOT ZLIB_FOUND)
message(SEND_ERROR "Couldn't find ZLib library.")
endif(NOT ZLIB_FOUND)
@@ -573,7 +574,7 @@ endif(enable-zlib)
if(enable-freetype)
set(MGL_HAVE_FREETYPE 1)
- include(FindFreetype)
+ find_package(Freetype)
if(NOT FREETYPE_FOUND)
message(SEND_ERROR "Couldn't find FreeType library.")
endif(NOT FREETYPE_FOUND)
@@ -588,7 +589,7 @@ if(enable-png)
if(NOT MGL_HAVE_ZLIB)
message(SEND_ERROR "You have to enable ZLib if you plan to use PNG export.")
endif(NOT MGL_HAVE_ZLIB)
- include(FindPNG)
+ find_package(PNG)
if(NOT PNG_FOUND)
message(SEND_ERROR "Couldn't find PNG library.")
endif(NOT PNG_FOUND)
@@ -620,7 +621,7 @@ endif(enable-pdf)
if(enable-gif)
set(MGL_HAVE_GIF 1)
- include(FindGIF)
+ find_package(GIF)
if(NOT GIF_FOUND)
message(SEND_ERROR "Couldn't find GIF library.")
endif(NOT GIF_FOUND)
@@ -633,7 +634,7 @@ endif(enable-gif)
if(enable-opengl)
set(MGL_HAVE_OPENGL 1)
set(OpenGL_GL_PREFERENCE LEGACY)
- include(FindOpenGL)
+ find_package(OpenGL)
if(NOT OPENGL_FOUND)
message(SEND_ERROR "Couldn't find OpenGL libraries.")
endif(NOT OPENGL_FOUND)
@@ -648,7 +649,7 @@ if(enable-glut)
if(NOT MGL_HAVE_OPENGL)
message(SEND_ERROR "You have to enable OpenGL if you plan to use GLUT.")
endif(NOT MGL_HAVE_OPENGL)
- include(FindGLUT)
+ find_package(GLUT REQUIRED)
if(NOT GLUT_FOUND)
message(SEND_ERROR "Couldn't find GLUT library.")
endif(NOT GLUT_FOUND)
@@ -658,14 +659,19 @@ endif(enable-glut)
if(enable-fltk)
set(MGL_HAVE_FLTK 1)
- FIND_PACKAGE(FLTK)
+ find_package(FLTK CONFIG)
+ set(FLTK_LIBRARIES fltk)
if(NOT FLTK_FOUND)
message(SEND_ERROR "Couldn't find FLTK library.")
else(NOT FLTK_FOUND)
- include_directories(${FLTK_INCLUDE_DIR})
+ set(FLTK_LIBRARIES fltk)
+ include(CMakePushCheckState)
+ cmake_push_check_state()
+ list(APPEND CMAKE_REQUIRED_LIBRARIES ${FLTK_LIBRARIES})
CHECK_CXX_SOURCE_COMPILES(
"#include <FL/Fl_Copy_Surface.H>
int main(){return 0;}" MGL_HAVE_FL_COPY)
+ cmake_pop_check_state()
endif(NOT FLTK_FOUND)
if(NOT MGL_HAVE_FL_COPY)
set(MGL_HAVE_FL_COPY 0)
diff --git a/scripts/MathGLConfig.cmake.in b/scripts/MathGLConfig.cmake.in
index 78bad89..0c2e5ed 100644
--- a/scripts/MathGLConfig.cmake.in
+++ b/scripts/MathGLConfig.cmake.in
@@ -25,6 +25,12 @@ endif()
if (MathGL2_HAVE_OPENMP STRGREATER "")
find_dependency(OpenMP)
endif()
+if("@enable-arma@")
+ find_dependency(Armadillo CONFIG)
+endif()
+if(MathGL2_HAVE_FLTK)
+ find_dependency(FLTK CONFIG)
+endif()
# Compute paths
get_filename_component(MathGL2_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)

View File

@ -0,0 +1,14 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b393fa7..8a1ce4b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -838,7 +838,9 @@ if(NOT enable-lgpl)
add_subdirectory( lang )
endif(enable-python OR enable-lua OR enable-octave)
add_subdirectory( utils )
+if(enable-examples)
add_subdirectory( examples )
+endif()
if(NOT WIN32)
add_subdirectory( fonts )
endif(NOT WIN32)

View File

@ -0,0 +1,60 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8a1ce4b..71d07bf 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -842,8 +842,9 @@ if(enable-examples)
add_subdirectory( examples )
endif()
if(NOT WIN32)
- add_subdirectory( fonts )
+ set(INSTALL_FONTS 1)
endif(NOT WIN32)
+add_subdirectory( fonts )
add_subdirectory( mgllab )
endif(NOT enable-lgpl)
diff --git a/fonts/CMakeLists.txt b/fonts/CMakeLists.txt
index f529c18..aba1bc3 100644
--- a/fonts/CMakeLists.txt
+++ b/fonts/CMakeLists.txt
@@ -1,8 +1,20 @@
+if(MAKE_BIN_EXECUTABLE)
+ add_executable(make_bin IMPORTED)
+ set_target_properties(make_bin PROPERTIES IMPORTED_LOCATION "${MAKE_BIN_EXECUTABLE}")
+else()
+ add_executable(make_bin make_bin.cpp)
+ target_link_libraries(make_bin mgl${link_type} ${getopt_lib-static})
+ install(TARGETS make_bin RUNTIME DESTINATION bin)
+endif()
+if(NOT INSTALL_FONTS)
+ return()
+elseif(0)
include_directories( ${MathGL2_SOURCE_DIR}/include ${MathGL2_BINARY_DIR}/include)
set(hdrF ../include/mgl2/font.h ../include/mgl2/define.h ${MathGL2_BINARY_DIR}/include/mgl2/config.h)
add_executable(make_bin make_bin.cpp ../src/font.cpp ${hdrF})
#target_link_libraries(make_bin mgl-static ${getopt_lib-static})
target_link_libraries(make_bin ${MGL_DEP_LIBS})
+endif()
set(MGL_FONTS STIX adventor bonum cursor heroscn heros pagella schola termes)
set(MGL_FONTS_BIN )
diff --git a/fonts/make_bin.cpp b/fonts/make_bin.cpp
index 73d0adb..e0158be 100644
--- a/fonts/make_bin.cpp
+++ b/fonts/make_bin.cpp
@@ -20,6 +20,7 @@
#include <getopt.h>
#include "mgl2/font.h"
//-----------------------------------------------------------------------------
+#if 0 // vcpkg links to mgl lib
extern mglFont *mglDefFont;
void mgl_init() // TODO try to add ld option: "-init mgl_init"
{
@@ -30,6 +31,7 @@ void mgl_init() // TODO try to add ld option: "-init mgl_init"
mglDefFont = new mglFont(MGL_DEF_FONT_NAME);
}
}
+#endif
int main(int argc, char *argv[])
{
mglFont fnt;

View File

@ -0,0 +1,32 @@
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index cd389bd..56ad515 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -26,7 +26,7 @@ endif(MGL_HAVE_GLUT)
if(MGL_HAVE_WX)
include(${wxWidgets_USE_FILE})
- add_executable(mgl_wx_example wnd_samples.cpp wx_example.cpp)
+ add_executable(mgl_wx_example WIN32 wnd_samples.cpp wx_example.cpp)
target_link_libraries(mgl_wx_example mgl-wx${link_type})
endif(MGL_HAVE_WX)
diff --git a/examples/full_test.cpp b/examples/full_test.cpp
index 50fb6ae..6f3ef26 100644
--- a/examples/full_test.cpp
+++ b/examples/full_test.cpp
@@ -21,6 +21,14 @@
#include <locale.h>
#include <time.h>
#include <getopt.h>
+#if defined(_UNICODE) && defined(getopt_long_only)
+#undef getopt_long_only
+#undef option
+#undef optarg
+#define getopt_long_only getopt_long_only_a
+#define option option_a
+#define optarg optarg_a
+#endif
#ifdef WIN32
#include <io.h>
#include <direct.h>

View File

@ -0,0 +1,140 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a560278..3184d2c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -239,6 +239,11 @@ if(MSVC AND MSVC_VERSION GREATER 1899)
SET(CMAKE_CXX_FLAGS "/EHsc -D_CRT_STDIO_ISO_WIDE_SPECIFIERS ${CMAKE_CXX_FLAGS}")
SET(CMAKE_C_FLAGS "-D_CRT_STDIO_ISO_WIDE_SPECIFIERS ${CMAKE_C_FLAGS}")
endif(MSVC AND MSVC_VERSION GREATER 1899)
+# _CRT_STDIO_ISO_WIDE_SPECIFIERS was never officially supported
+# and breaks link mathgl widget libs against their GUI libs:
+# error LNK2038: mismatch detected for '_CRT_STDIO_ISO_WIDE_SPECIFIERS': value '0' doesn't match value '1' in fltk.cpp.obj
+string(REPLACE "-D_CRT_STDIO_ISO_WIDE_SPECIFIERS" "-DVCPKG_MSVC_WPRINTF" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
+string(REPLACE "-D_CRT_STDIO_ISO_WIDE_SPECIFIERS" "-DVCPKG_MSVC_WPRINTF" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
include(CheckCXXSourceCompiles)
diff --git a/src/export_2d.cpp b/src/export_2d.cpp
index bd07404..65f5fdf 100644
--- a/src/export_2d.cpp
+++ b/src/export_2d.cpp
@@ -17,6 +17,13 @@
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
+// wprintf format specifier for char*.
+// Inject by replacing (wprintf.*?[^"])" PERCENT_S " with $1" PERCENT_S "
+#ifdef VCPKG_MSVC_WPRINTF
+#define PERCENT_S "%S"
+#else
+#define PERCENT_S "%s"
+#endif
#include "mgl2/canvas.h"
#include "mgl2/canvas_cf.h"
#include "mgl2/font.h"
@@ -661,7 +668,7 @@ void MGL_EXPORT mgl_write_tex(HMGL gr, const char *fname,const char *descr)
FILE *fp = fopen(fname,"w");
if(!fp) { gr->SetWarn(mglWarnOpen,fname); return; }
const std::string loc = setlocale(LC_NUMERIC, "C"); fwide(fp,1);
- fwprintf(fp, L"%% Created by MathGL library\n%% Title: %s\n\n",descr?descr:fname);
+ fwprintf(fp, L"%% Created by MathGL library\n%% Title: " PERCENT_S "\n\n",descr?descr:fname);
// provide marks
fwprintf(fp, L"\\providecommand{\\mglp}[4]{\\draw[#3] (#1-#4, #2) -- (#1+#4,#2) (#1,#2-#4) -- (#1,#2+#4);}\n");
fwprintf(fp, L"\\providecommand{\\mglx}[4]{\\draw[#3] (#1-#4, #2-#4) -- (#1+#4,#2+#4) (#1+#4,#2-#4) -- (#1-#4,#2+#4);}\n");
@@ -707,47 +714,47 @@ void MGL_EXPORT mgl_write_tex(HMGL gr, const char *fname,const char *descr)
switch(q.n4) // NOTE: no thickness for marks in TeX
{
case 'P':
- fwprintf(fp, L"\\mglp{%.4g}{%.4g}{%s}{%.4g} \\mgls{%.4g}{%.4g}{%s}{%.4g}\n", x,y,cname,s,x,y,cname,s); break;
+ fwprintf(fp, L"\\mglp{%.4g}{%.4g}{" PERCENT_S "}{%.4g} \\mgls{%.4g}{%.4g}{" PERCENT_S "}{%.4g}\n", x,y,cname,s,x,y,cname,s); break;
case 'X':
- fwprintf(fp, L"\\mglx{%.4g}{%.4g}{%s}{%.4g} \\mgls{%.4g}{%.4g}{%s}{%.4g}\n", x,y,cname,s,x,y,cname,s); break;
+ fwprintf(fp, L"\\mglx{%.4g}{%.4g}{" PERCENT_S "}{%.4g} \\mgls{%.4g}{%.4g}{" PERCENT_S "}{%.4g}\n", x,y,cname,s,x,y,cname,s); break;
case 'C':
- fwprintf(fp, L"\\mglc{%.4g}{%.4g}{%s}{%.4g} \\mglo{%.4g}{%.4g}{%s}{%.4g}\n", x,y,cname,s,x,y,cname,s); break;
- case '+': fwprintf(fp, L"\\mglp{%.4g}{%.4g}{%s}{%.4g}\n", x,y,cname,s); break;
- case 'x': fwprintf(fp, L"\\mglx{%.4g}{%.4g}{%s}{%.4g}\n", x,y,cname,s); break;
- case 's': fwprintf(fp, L"\\mgls{%.4g}{%.4g}{%s}{%.4g}\n", x,y,cname,s); break;
- case 'S': fwprintf(fp, L"\\mglS{%.4g}{%.4g}{%s}{%.4g}\n", x,y,cname,s); break;
- case 'd': fwprintf(fp, L"\\mgld{%.4g}{%.4g}{%s}{%.4g}\n", x,y,cname,s); break;
- case 'D': fwprintf(fp, L"\\mglD{%.4g}{%.4g}{%s}{%.4g}\n", x,y,cname,s); break;
- case '^': fwprintf(fp, L"\\mglt{%.4g}{%.4g}{%s}{%.4g}\n", x,y,cname,s); break;
- case 'T': fwprintf(fp, L"\\mglT{%.4g}{%.4g}{%s}{%.4g}\n", x,y,cname,s); break;
- case 'v': fwprintf(fp, L"\\mglv{%.4g}{%.4g}{%s}{%.4g}\n", x,y,cname,s); break;
- case 'V': fwprintf(fp, L"\\mglV{%.4g}{%.4g}{%s}{%.4g}\n", x,y,cname,s); break;
- case '<': fwprintf(fp, L"\\mgll{%.4g}{%.4g}{%s}{%.4g}\n", x,y,cname,s); break;
- case 'L': fwprintf(fp, L"\\mglL{%.4g}{%.4g}{%s}{%.4g}\n", x,y,cname,s); break;
- case '>': fwprintf(fp, L"\\mglr{%.4g}{%.4g}{%s}{%.4g}\n", x,y,cname,s); break;
- case 'R': fwprintf(fp, L"\\mglR{%.4g}{%.4g}{%s}{%.4g}\n", x,y,cname,s); break;
- case 'Y': fwprintf(fp, L"\\mglY{%.4g}{%.4g}{%s}{%.4g}\n", x,y,cname,s); break;
- case 'o': fwprintf(fp, L"\\mglo{%.4g}{%.4g}{%s}{%.4g}\n", x,y,cname,s); break;
- case 'O': fwprintf(fp, L"\\mglO{%.4g}{%.4g}{%s}{%.4g}\n", x,y,cname,s); break;
- case '*': fwprintf(fp, L"\\mgla{%.4g}{%.4g}{%s}{%.4g}\n", x,y,cname,s); break;
- default: fwprintf(fp, L"\\mglc{%.4g}{%.4g}{%s}\n", x,y,cname); break;
+ fwprintf(fp, L"\\mglc{%.4g}{%.4g}{" PERCENT_S "}{%.4g} \\mglo{%.4g}{%.4g}{" PERCENT_S "}{%.4g}\n", x,y,cname,s,x,y,cname,s); break;
+ case '+': fwprintf(fp, L"\\mglp{%.4g}{%.4g}{" PERCENT_S "}{%.4g}\n", x,y,cname,s); break;
+ case 'x': fwprintf(fp, L"\\mglx{%.4g}{%.4g}{" PERCENT_S "}{%.4g}\n", x,y,cname,s); break;
+ case 's': fwprintf(fp, L"\\mgls{%.4g}{%.4g}{" PERCENT_S "}{%.4g}\n", x,y,cname,s); break;
+ case 'S': fwprintf(fp, L"\\mglS{%.4g}{%.4g}{" PERCENT_S "}{%.4g}\n", x,y,cname,s); break;
+ case 'd': fwprintf(fp, L"\\mgld{%.4g}{%.4g}{" PERCENT_S "}{%.4g}\n", x,y,cname,s); break;
+ case 'D': fwprintf(fp, L"\\mglD{%.4g}{%.4g}{" PERCENT_S "}{%.4g}\n", x,y,cname,s); break;
+ case '^': fwprintf(fp, L"\\mglt{%.4g}{%.4g}{" PERCENT_S "}{%.4g}\n", x,y,cname,s); break;
+ case 'T': fwprintf(fp, L"\\mglT{%.4g}{%.4g}{" PERCENT_S "}{%.4g}\n", x,y,cname,s); break;
+ case 'v': fwprintf(fp, L"\\mglv{%.4g}{%.4g}{" PERCENT_S "}{%.4g}\n", x,y,cname,s); break;
+ case 'V': fwprintf(fp, L"\\mglV{%.4g}{%.4g}{" PERCENT_S "}{%.4g}\n", x,y,cname,s); break;
+ case '<': fwprintf(fp, L"\\mgll{%.4g}{%.4g}{" PERCENT_S "}{%.4g}\n", x,y,cname,s); break;
+ case 'L': fwprintf(fp, L"\\mglL{%.4g}{%.4g}{" PERCENT_S "}{%.4g}\n", x,y,cname,s); break;
+ case '>': fwprintf(fp, L"\\mglr{%.4g}{%.4g}{" PERCENT_S "}{%.4g}\n", x,y,cname,s); break;
+ case 'R': fwprintf(fp, L"\\mglR{%.4g}{%.4g}{" PERCENT_S "}{%.4g}\n", x,y,cname,s); break;
+ case 'Y': fwprintf(fp, L"\\mglY{%.4g}{%.4g}{" PERCENT_S "}{%.4g}\n", x,y,cname,s); break;
+ case 'o': fwprintf(fp, L"\\mglo{%.4g}{%.4g}{" PERCENT_S "}{%.4g}\n", x,y,cname,s); break;
+ case 'O': fwprintf(fp, L"\\mglO{%.4g}{%.4g}{" PERCENT_S "}{%.4g}\n", x,y,cname,s); break;
+ case '*': fwprintf(fp, L"\\mgla{%.4g}{%.4g}{" PERCENT_S "}{%.4g}\n", x,y,cname,s); break;
+ default: fwprintf(fp, L"\\mglc{%.4g}{%.4g}{" PERCENT_S "}\n", x,y,cname); break;
}
}
else if(q.type==2 && cp.r[3])
{
const mglPnt &p2=gr->GetPnt(q.n2), &p3=gr->GetPnt(q.n3);
if(cp.r[3]<255)
- fwprintf(fp, L"\\fill[%s, fill opacity=%.4g] (%.4g,%.4g) -- (%.4g,%.4g) -- (%.4g,%.4g) -- cycle;\n", cname,cp.r[3]/255., x,y, p2.x/100,p2.y/100, p3.x/100,p3.y/100);
+ fwprintf(fp, L"\\fill[" PERCENT_S ", fill opacity=%.4g] (%.4g,%.4g) -- (%.4g,%.4g) -- (%.4g,%.4g) -- cycle;\n", cname,cp.r[3]/255., x,y, p2.x/100,p2.y/100, p3.x/100,p3.y/100);
else
- fwprintf(fp, L"\\fill[%s, fill] (%.4g,%.4g) -- (%.4g,%.4g) -- (%.4g,%.4g) -- cycle;\n", cname, x,y, p2.x/100,p2.y/100, p3.x/100,p3.y/100);
+ fwprintf(fp, L"\\fill[" PERCENT_S ", fill] (%.4g,%.4g) -- (%.4g,%.4g) -- (%.4g,%.4g) -- cycle;\n", cname, x,y, p2.x/100,p2.y/100, p3.x/100,p3.y/100);
}
else if(q.type==3 && cp.r[3])
{
const mglPnt &p2=gr->GetPnt(q.n2), &p3=gr->GetPnt(q.n3), &p4=gr->GetPnt(q.n4);
if(cp.r[3]<255)
- fwprintf(fp, L"\\fill[%s, fill opacity=%.4g] (%.4g,%.4g) -- (%.4g,%.4g) -- (%.4g,%.4g) -- (%.4g,%.4g) -- cycle;\n", cname,cp.r[3]/255., x,y, p2.x/100,p2.y/100, p4.x/100,p4.y/100, p3.x/100,p3.y/100);
+ fwprintf(fp, L"\\fill[" PERCENT_S ", fill opacity=%.4g] (%.4g,%.4g) -- (%.4g,%.4g) -- (%.4g,%.4g) -- (%.4g,%.4g) -- cycle;\n", cname,cp.r[3]/255., x,y, p2.x/100,p2.y/100, p4.x/100,p4.y/100, p3.x/100,p3.y/100);
else
- fwprintf(fp, L"\\fill[%s, fill] (%.4g,%.4g) -- (%.4g,%.4g) -- (%.4g,%.4g) -- (%.4g,%.4g) -- cycle;\n", cname, x,y, p2.x/100,p2.y/100, p4.x/100,p4.y/100, p3.x/100,p3.y/100);
+ fwprintf(fp, L"\\fill[" PERCENT_S ", fill] (%.4g,%.4g) -- (%.4g,%.4g) -- (%.4g,%.4g) -- (%.4g,%.4g) -- cycle;\n", cname, x,y, p2.x/100,p2.y/100, p4.x/100,p4.y/100, p3.x/100,p3.y/100);
}
else if(q.type==1) // lines
@@ -755,8 +762,8 @@ void MGL_EXPORT mgl_write_tex(HMGL gr, const char *fname,const char *descr)
//const char *dash[]={"", "8 8","4 4","1 3","7 4 1 4","3 2 1 2"};
const char *w[]={"semithick","thick","very thick","ultra thick"};
int iw=int(q.w-0.5); if(iw>3) iw=3;
- if(iw<0) fwprintf(fp,L"\\draw[%s] ",cname);
- else fwprintf(fp,L"\\draw[%s,%s] ",cname,w[iw]);
+ if(iw<0) fwprintf(fp,L"\\draw[" PERCENT_S "] ",cname);
+ else fwprintf(fp,L"\\draw[" PERCENT_S "," PERCENT_S "] ",cname,w[iw]);
// TODO: add line dashing
wp = q.w>1 ? q.w:1; st = q.n3;
std::vector<long> ids = put_line(gr,i,wp,cp.c,st);
@@ -780,9 +787,9 @@ void MGL_EXPORT mgl_write_tex(HMGL gr, const char *fname,const char *descr)
// if(f&MGL_FONT_ITAL) ss.append(",font=\\itshape");
// if(f&MGL_FONT_BOLD) ss.append(",font=\\bfshape");
if(t.text.find('\\')!=std::string::npos || t.text.find('{')!=std::string::npos || t.text.find('_')!=std::string::npos || t.text.find('^')!=std::string::npos)
- fwprintf(fp,L"\\draw[%s] (%.4g,%.4g) node[rotate=%.2g]{$%ls$};\n", ss.c_str(),x-dx,y-dy, -q.p, t.text.c_str());
+ fwprintf(fp,L"\\draw[" PERCENT_S "] (%.4g,%.4g) node[rotate=%.2g]{$%ls$};\n", ss.c_str(),x-dx,y-dy, -q.p, t.text.c_str());
else
- fwprintf(fp,L"\\draw[%s] (%.4g,%.4g) node[rotate=%.2g]{%ls};\n", ss.c_str(),x-dx,y-dy, -q.p, t.text.c_str());
+ fwprintf(fp,L"\\draw[" PERCENT_S "] (%.4g,%.4g) node[rotate=%.2g]{%ls};\n", ss.c_str(),x-dx,y-dy, -q.p, t.text.c_str());
}
}
fwprintf(fp, L"\\end{tikzpicture}\n");

View File

@ -0,0 +1,13 @@
diff --git a/widgets/glut.cpp b/widgets/glut.cpp
index eca65db..6a4641d 100644
--- a/widgets/glut.cpp
+++ b/widgets/glut.cpp
@@ -27,7 +27,7 @@
#if defined(_MSC_VER) || defined(__BORLANDC__)
#include <windows.h>
#include <GL/gl.h>
- #include "glut.h"
+ #include <GL/glut.h>
#else
#include <GL/gl.h>
#include <GL/glut.h>

View File

@ -0,0 +1,13 @@
diff --git a/mgllab/mgllab.cpp b/mgllab/mgllab.cpp
index ef2d556..36fbfc4 100644
--- a/mgllab/mgllab.cpp
+++ b/mgllab/mgllab.cpp
@@ -344,7 +344,7 @@ Fl_Menu_Item menuitems[] = {
void mem_upd_cb(Fl_Widget *, void *v)
{ ((ScriptWindow*)v)->mem_init(); }
//-----------------------------------------------------------------------------
-extern Fl_RGB_Image img_udav;
+extern MGL_EXPORT Fl_RGB_Image img_udav;
ScriptWindow *new_view()
{
Fl_Group *gg;

View File

@ -1,14 +0,0 @@
diff --git "a/include/mgl2/define.h" "b/include/mgl2/define.h"
index e23ec04..8e79086 100644
--- "a/include/mgl2/define.h"
+++ "b/include/mgl2/define.h"
@@ -141,7 +140,9 @@ typedef long msize;
#define getcwd _getcwd
#define chdir _chdir // BORLAND has chdir
#endif
+#if (_MSC_VER<1500)
#define snprintf _snprintf
+#endif
#if (_MSC_VER<1600) // based on https://hg.python.org/cpython/rev/9aedb876c2d7
#define hypot _hypot
#endif

View File

@ -1,11 +0,0 @@
--- a/include/mgl2/define.h 2021-12-08 13:59:55.000000000 +0800
+++ a/include/mgl2/define.h 2021-12-15 10:39:09.701079400 +0800
@@ -66,6 +66,8 @@
#else
#define MGL_FUNC_CONST
#define MGL_FUNC_PURE
+#define MGL_FUNC_INIT
+#define MGL_FUNC_FINI
#endif
#define MGL_EXPORT_CONST MGL_EXPORT MGL_FUNC_CONST
#define MGL_EXPORT_PURE MGL_EXPORT MGL_FUNC_PURE

View File

@ -1,38 +0,0 @@
diff --git a/mgllab/CMakeLists.txt b/mgllab/CMakeLists.txt
index 1649104..eeec1c1 100644
--- a/mgllab/CMakeLists.txt
+++ b/mgllab/CMakeLists.txt
@@ -38,7 +38,11 @@ if(MGL_HAVE_FLTK)
set(mgllab_src ${mgllab_src} mgllab.rc)
endif(WIN32)
add_executable(mgllab ${mgllab_src} ${mgllab_hdr})
- target_link_libraries(mgllab mgl mgl-fltk ${FLTK_LIBRARIES})
+ if(WIN32)
+ target_link_libraries(mgllab mgl mgl-fltk mgl-fltk-static mgl-static getopt-static ${FLTK_LIBRARIES})
+ else(WIN32)
+ target_link_libraries(mgllab mgl mgl-fltk ${FLTK_LIBRARIES})
+ endif(WIN32)
install(
TARGETS mgllab
RUNTIME DESTINATION bin )
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d0c779d..acd9d7f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -579,10 +579,15 @@ if(enable-glut)
if(NOT MGL_HAVE_OPENGL)
message(SEND_ERROR "You have to enable OpenGL if you plan to use GLUT.")
endif(NOT MGL_HAVE_OPENGL)
- include(FindGLUT)
+ find_path(GLUT_INCLUDE_DIR freeglut.h PATH_SUFFIXES GL)
+ include(SelectLibraryConfigurations)
+ find_library(GLUT_LIBRARY_RELEASE NAMES freeglut)
+ find_library(GLUT_LIBRARY_DEBUG NAMES freeglutd)
+ select_library_configurations(GLUT)
if(NOT GLUT_FOUND)
message(SEND_ERROR "Couldn't find GLUT library.")
endif(NOT GLUT_FOUND)
+ include_directories(${GLUT_INCLUDE_DIR}/GL)
else(enable-glut)
set(MGL_HAVE_GLUT 0)
endif(enable-glut)

View File

@ -1,21 +0,0 @@
diff --git "a/src/canvas_cf.cpp" "b/src/canvas_cf.cpp"
index 5e1443a..26a0a8e 100644
--- "a/src/canvas_cf.cpp"
+++ "b/src/canvas_cf.cpp"
@@ -50,7 +50,6 @@ void MGL_EXPORT MGL_FUNC_INIT mgl_init() // TODO try to add ld option: "-init mg
#endif
for(long i=0;i<360;i++) mgl_cos[i] = cos(i*M_PI/180.);
if(!mglDefFont) mglDefFont = new mglFont(MGL_DEF_FONT_NAME);
- if(!mglDefaultGr) mglDefaultGr = new mglCanvas(600,400);
}
}
void MGL_EXPORT MGL_FUNC_FINI mgl_fini() // TODO try to add ld option: "-fini mgl_fini"
@@ -434,7 +433,7 @@ void MGL_EXPORT mgl_set_legend_marks(HMGL gr, int num)
uintptr_t MGL_EXPORT mgl_create_graph_(int *width, int *height)
{ return uintptr_t(new mglCanvas(*width,*height)); }
void MGL_EXPORT mgl_delete_graph_(uintptr_t *gr) { delete _GR_; }
-uintptr_t MGL_EXPORT mgl_default_graph_() { return uintptr_t(&mglDefaultGr); }
+uintptr_t MGL_EXPORT mgl_default_graph_() { return uintptr_t(mgl_default_graph()); }
void MGL_EXPORT mgl_set_size_scl_(double *scl) { mgl_set_size_scl(*scl); }
void MGL_EXPORT mgl_set_size_(uintptr_t *gr, int *width, int *height)
{ mgl_set_size(_GR_,*width,*height); }

View File

@ -1,28 +0,0 @@
diff --git a/include/mgl2/abstract.h b/include/mgl2/abstract.h
index c8c53b8..245333b 100644
--- a/include/mgl2/abstract.h
+++ b/include/mgl2/abstract.h
@@ -235,7 +235,11 @@ struct MGL_EXPORT mglNum
};
//-----------------------------------------------------------------------------
/// List of user-defined data arrays
+#ifndef MGL_WIDGETS_DLL
MGL_EXPORT extern std::vector<mglDataA*> mglDataList;
+#else
+__declspec(dllimport) extern std::vector<mglDataA*> mglDataList;
+#endif
//-----------------------------------------------------------------------------
/// Abstract class for data array
class MGL_EXPORT mglDataA
diff --git a/widgets/CMakeLists.txt b/widgets/CMakeLists.txt
index a9e1269..4c1d0d4 100644
--- a/widgets/CMakeLists.txt
+++ b/widgets/CMakeLists.txt
@@ -2,6 +2,7 @@ include(GenerateExportHeader)
if(MSVC)
add_definitions(-DMGL_LIB_MSVC)
+ add_definitions(-DMGL_WIDGETS_DLL)
endif(MSVC)
if(MGL_HAVE_FLTK)

187
ports/mathgl/linkage.patch Normal file
View File

@ -0,0 +1,187 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a316984..920a099 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -71,6 +71,14 @@ macro(mgl_po_src)
set(po_files ${po_files} ${l_files} PARENT_SCOPE)
endmacro(mgl_po_src)
+if(BUILD_SHARED_LIBS)
+ set(link_type "")
+ set(excluded_type "-static")
+else()
+ set(link_type "-static")
+ set(excluded_type "")
+endif()
+
function(mgl_add_lib mgl_tmp_lib)
if(${mgl_tmp_lib} MATCHES mgl)
set(mgllib mgl)
@@ -113,8 +121,10 @@ function(mgl_add_lib mgl_tmp_lib)
set_target_properties(${mgllib}-static PROPERTIES OUTPUT_NAME "${mgllib}${mgl_lib_static}${mgl_lib_end}")
endif(enable-mgl2)
+ target_compile_definitions(${mgllib} PRIVATE BUILDING_${mgllib}_LIB)
+ set_target_properties(${mgllib}${excluded_type} PROPERTIES EXCLUDE_FROM_ALL 1)
install(
- TARGETS ${mgllib} ${mgllib}-static
+ TARGETS ${mgllib}${link_type}
EXPORT MathGLTargets
RUNTIME DESTINATION ${MathGL_INSTALL_BIN_DIR}
ARCHIVE DESTINATION ${MathGL_INSTALL_LIB_DIR}
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 0263910..186d95b 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -4,7 +4,7 @@ file(COPY ${CMAKE_SOURCE_DIR}/examples/Equirectangular-projection.jpg DESTINATIO
file(COPY ${CMAKE_SOURCE_DIR}/examples/samples.cpp DESTINATION ${CMAKE_BINARY_DIR}/examples)
file(COPY ${CMAKE_SOURCE_DIR}/examples/wnd_samples.cpp DESTINATION ${CMAKE_BINARY_DIR}/examples)
add_executable(mgl_example wnd_samples.cpp full_test.cpp samples.cpp)
-target_link_libraries(mgl_example mgl-static ${getopt_lib-static})
+target_link_libraries(mgl_example mgl${link_type} ${getopt_lib-static})
if(CMAKE_BUILD_TYPE STREQUAL "Debug" AND CMAKE_COMPILER_IS_GNUCXX AND enable-lcov)
setup_target_for_coverage(
NAME mgl_coverage
@@ -16,25 +16,25 @@ endif(CMAKE_BUILD_TYPE STREQUAL "Debug" AND CMAKE_COMPILER_IS_GNUCXX AND enable-
if(MGL_HAVE_FLTK)
include_directories(${FLTK_INCLUDE_DIR})
add_executable(mgl_fltk_example wnd_samples.cpp fltk_example.cpp)
- target_link_libraries(mgl_fltk_example mgl-fltk)
+ target_link_libraries(mgl_fltk_example mgl-fltk${link_type})
endif(MGL_HAVE_FLTK)
if(MGL_HAVE_GLUT)
add_executable(mgl_glut_example wnd_samples.cpp glut_example.cpp)
- target_link_libraries(mgl_glut_example mgl-glut)
+ target_link_libraries(mgl_glut_example mgl-glut${link_type})
endif(MGL_HAVE_GLUT)
if(MGL_HAVE_WX)
include(${wxWidgets_USE_FILE})
add_executable(mgl_wx_example wnd_samples.cpp wx_example.cpp)
- target_link_libraries(mgl_wx_example mgl-wx)
+ target_link_libraries(mgl_wx_example mgl-wx${link_type})
endif(MGL_HAVE_WX)
if(QT_ENABLED)
add_executable(mgl_qt_example wnd_samples.cpp qt_example.cpp)
if(enable-qt5)
include(../scripts/qt5.cmake)
- target_link_libraries(mgl_qt_example mgl-qt5)
+ target_link_libraries(mgl_qt_example mgl-qt5${link_type})
else(enable-qt5)
include(../scripts/qt4.cmake)
target_link_libraries(mgl_qt_example mgl-qt4)
@@ -43,7 +43,7 @@ if(QT_ENABLED)
if(MGL_HAVE_OPENGL)
add_executable(mgl_qgl_example wnd_samples.cpp qgl_example.cpp)
if(enable-qt5)
- target_link_libraries(mgl_qgl_example mgl ${MGL_QT5_LIBS})
+ target_link_libraries(mgl_qgl_example mgl${link_type} ${MGL_QT5_LIBS})
else(enable-qt5)
target_link_libraries(mgl_qgl_example mgl ${MGL_QT4_LIBS})
endif(enable-qt5)
@@ -52,11 +52,11 @@ endif(QT_ENABLED)
if(MGL_HAVE_LTDL)
add_library(mgl_module MODULE mgl_module.cpp)
- target_link_libraries(mgl_module mgl) # for compatibility with win32
+ target_link_libraries(mgl_module mgl${link_type}) # for compatibility with win32
endif(MGL_HAVE_LTDL)
if(MGL_HAVE_MPI)
add_executable(mgl_mpi_example mpi_test.cpp)
- target_link_libraries(mgl_mpi_example mgl-mpi mgl ${MPI_LIBRARIES})
+ target_link_libraries(mgl_mpi_example mgl-mpi${link_type} mgl${link_type} ${MPI_LIBRARIES})
target_include_directories(mgl_mpi_example SYSTEM PUBLIC ${MPI_CXX_INCLUDE_PATH})
endif(MGL_HAVE_MPI)
diff --git a/include/mgl2/abstract.h b/include/mgl2/abstract.h
index da27869..b1e6761 100644
--- a/include/mgl2/abstract.h
+++ b/include/mgl2/abstract.h
@@ -20,6 +20,15 @@
#ifndef _MGL_ABSTRACT_H_
#define _MGL_ABSTRACT_H_
+#include "mgl2/dllexport.h"
+#if defined(BUILDING_mgl_LIB) || !defined mgl_EXPORTS
+#define MGL_CORE_EXPORT MGL_EXPORT
+#elif defined(_WIN32) && !defined(MGL_STATIC_DEFINE)
+#define MGL_CORE_EXPORT __declspec(dllimport)
+#else
+#define MGL_CORE_EXPORT
+#endif
+
#include "mgl2/define.h"
//-----------------------------------------------------------------------------
#ifdef __cplusplus
@@ -209,11 +218,11 @@ cmdual MGL_EXPORT mgl_cexpr_eval_v(HAEX ex, mdual *vars);
//-----------------------------------------------------------------------------
/// Callback function for asking user a question. Result shouldn't exceed 1024.
-extern MGL_EXPORT void (*mgl_ask_func)(const wchar_t *quest, wchar_t *res);
+extern MGL_CORE_EXPORT void (*mgl_ask_func)(const wchar_t *quest, wchar_t *res);
/// Console function for asking user a question. Result shouldn't exceed 1024.
void MGL_EXPORT mgl_ask_gets(const wchar_t *quest, wchar_t *res);
/// Callback function for displaying progress of something.
-extern MGL_EXPORT void (*mgl_progress_func)(int value, int maximal, HMGL gr);
+extern MGL_CORE_EXPORT void (*mgl_progress_func)(int value, int maximal, HMGL gr);
/// Console function for displaying progress of something.
void MGL_EXPORT mgl_progress_txt(int value, int maximal, HMGL gr);
/// Display progress of something.
@@ -404,7 +413,7 @@ struct MGL_EXPORT mglColorID
char id;
mglColor col;
};
-MGL_EXPORT extern mglColorID mglColorIds[31];
+MGL_CORE_EXPORT extern mglColorID mglColorIds[31];
// MGL_EXPORT extern std::string mglGlobalMess; ///< Buffer for receiving global messages
//-----------------------------------------------------------------------------
#endif
diff --git a/mgllab/CMakeLists.txt b/mgllab/CMakeLists.txt
index 1649104..41c2e6a 100644
--- a/mgllab/CMakeLists.txt
+++ b/mgllab/CMakeLists.txt
@@ -38,7 +38,7 @@ if(MGL_HAVE_FLTK)
set(mgllab_src ${mgllab_src} mgllab.rc)
endif(WIN32)
add_executable(mgllab ${mgllab_src} ${mgllab_hdr})
- target_link_libraries(mgllab mgl mgl-fltk ${FLTK_LIBRARIES})
+ target_link_libraries(mgllab mgl${link_type} mgl-fltk${link_type} ${getopt_lib-static} ${FLTK_LIBRARIES})
install(
TARGETS mgllab
RUNTIME DESTINATION bin )
diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt
index 3e10fa7..0281859 100644
--- a/utils/CMakeLists.txt
+++ b/utils/CMakeLists.txt
@@ -1,11 +1,5 @@
add_executable(make_pas make_pas.cpp)
-if(MSVC)
-set(link_type -static)
-else(MSVC)
-set(link_type)
-endif(MSVC)
-
add_executable(mgltask mgltask.cpp)
target_link_libraries(mgltask mgl${link_type} ${getopt_lib-static})
install(
@@ -23,7 +17,7 @@ install(
)
add_executable(mgl.cgi mglcgi.cpp)
-target_link_libraries(mgl.cgi mgl-static)
+target_link_libraries(mgl.cgi mgl${link_type})
install(
TARGETS mgl.cgi
EXPORT MathGLTargets
@@ -36,7 +30,7 @@ mgl_po_src(mglconv.cpp mglview.cpp mglcgi.cpp mgltask.cpp)
if(MGL_HAVE_FLTK)
add_definitions(-DUSE_FLTK)
add_executable(mglview mglview.cpp)
- target_link_libraries(mglview mgl-fltk ${getopt_lib-static} ${FLTK_LIBRARIES})
+ target_link_libraries(mglview mgl-fltk${link_type} ${getopt_lib-static} ${FLTK_LIBRARIES})
install(
TARGETS mglview
EXPORT MathGLTargets

View File

@ -1,86 +1,107 @@
set(MATHGL_VERSION "2.5")
vcpkg_minimum_required(VERSION 2022-10-12)
vcpkg_from_sourceforge(
OUT_SOURCE_PATH SOURCE_PATH
REPO mathgl/mathgl
REF mathgl%20${MATHGL_VERSION}
FILENAME "mathgl-${MATHGL_VERSION}.tar.gz"
SHA512 1fe27962ffef8d7127c4e1294d735e5da4dd2d647397f09705c3ca860f90bd06fd447ff614e584f3d2b874a02262c5518be37d59e9e0a838dd5b8b64fd77ef9d
REF "mathgl 8.0"
FILENAME "mathgl-${VERSION}.tar.gz"
SHA512 1ff3023f1bbd7bfd84202777a0166a8d4255a020a07f3650b9858929345bc8a2ceea4db155d2c93ba32b762d2304474276290a9edac99fda70fb4b5bc12982c2
PATCHES
fix_cmakelists_and_cpp.patch
fix_attribute.patch
fix_default_graph_init.patch
fix_mglDataList.patch
fix_arma_sprintf.patch
cmake-config.patch
dependencies.patch
linkage.patch
enable-examples.patch
fix-examples.patch
fix-cross-builds.patch
fix-format-specifiers.patch
fix-glut.patch
fix-mgllab.patch
)
file(REMOVE_RECURSE "${SOURCE_PATH}/addons/getopt")
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
hdf5 enable-hdf5
arma enable-arma
examples enable-examples
fltk enable-fltk
gif enable-gif
arma enable-arma
png enable-png
zlib enable-zlib
jpeg enable-jpeg
gsl enable-gsl
opengl enable-opengl
glut enable-glut
wx enable-wx
gsl enable-gsl
hdf5 enable-hdf5
jpeg enable-jpeg
opengl enable-opengl
png enable-png
qt5 enable-qt5
wx enable-wx
zlib enable-zlib
)
if(VCPKG_TARGET_IS_OSX)
list(APPEND FEATURE_OPTIONS
-Denable-openmp=OFF
-Denable-pthread=ON
)
endif()
if(VCPKG_CROSSCOMPILING)
list(APPEND FEATURE_OPTIONS "-DMAKE_BIN_EXECUTABLE=${CURRENT_HOST_INSTALLED_DIR}/tools/${PORT}/make_bin${VCPKG_HOST_EXECUTABLE_SUFFIX}")
endif()
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS ${FEATURE_OPTIONS}
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
${FEATURE_OPTIONS}
"-DCMAKE_PROJECT_INCLUDE=${CMAKE_CURRENT_LIST_DIR}/cmake-project-include.cmake"
-DMathGL_INSTALL_CMAKE_DIR:STRING=share/mathgl2
-DCMAKE_CXX_STANDARD=11 # minimum for armadillo on osx
-DCMAKE_DISABLE_FIND_PACKAGE_Intl=1
-DCMAKE_POLICY_DEFAULT_CMP0127=NEW # cmake_dependent_option condition syntax
)
vcpkg_cmake_install()
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
if(NOT VCPKG_CMAKE_SYSTEM_NAME OR VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
vcpkg_cmake_config_fixup(CONFIG_PATH cmake)
file(REMOVE "${CURRENT_PACKAGES_DIR}/mathgl2-config.cmake")
file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/mathgl2-config.cmake")
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/mgl2/dllexport.h" "#ifdef MGL_STATIC_DEFINE" "#if 1")
else()
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/mathgl2)
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/mgl2/dllexport.h" "#ifdef MGL_STATIC_DEFINE" "#if 0")
endif()
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")
#somehow the native CMAKE_EXECUTABLE_SUFFIX does not work, so here we emulate it
if(CMAKE_HOST_WIN32)
set(EXECUTABLE_SUFFIX ".exe")
# MathGL exports proper CMake config under the MathGL2Config.cmake filename, and
# a find_path/find_library based package under the mathgl2-config.cmake filename.
# The latter doesn't support multi-config or static linkage requirements, and
# the variable names don't match the package names, i.e. it is unusable.
if(VCPKG_TARGET_IS_WINDOWS)
file(REMOVE "${CURRENT_PACKAGES_DIR}/mathgl2-config.cmake")
file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/mathgl2-config.cmake")
else()
set(EXECUTABLE_SUFFIX "")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/lib/cmake")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/lib/cmake")
endif()
vcpkg_cmake_config_fixup(PACKAGE_NAME mathgl2)
file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/bin/mgllab${EXECUTABLE_SUFFIX}")
file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/bin/mglview${EXECUTABLE_SUFFIX}")
file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/bin/mglconv${EXECUTABLE_SUFFIX}")
file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/bin/mgltask${EXECUTABLE_SUFFIX}")
file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/bin/udav${EXECUTABLE_SUFFIX}")
file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/tools/mathgl/")
file(RENAME "${CURRENT_PACKAGES_DIR}/bin/mglconv${EXECUTABLE_SUFFIX}" "${CURRENT_PACKAGES_DIR}/tools/mathgl/mglconv${EXECUTABLE_SUFFIX}")
file(RENAME "${CURRENT_PACKAGES_DIR}/bin/mgltask${EXECUTABLE_SUFFIX}" "${CURRENT_PACKAGES_DIR}/tools/mathgl/mgltask${EXECUTABLE_SUFFIX}")
if (EXISTS "${CURRENT_PACKAGES_DIR}/bin/mgllab${EXECUTABLE_SUFFIX}")
file(RENAME "${CURRENT_PACKAGES_DIR}/bin/mgllab${EXECUTABLE_SUFFIX}" "${CURRENT_PACKAGES_DIR}/tools/mathgl/mgllab${EXECUTABLE_SUFFIX}")
endif()
if ("EXISTS ${CURRENT_PACKAGES_DIR}/bin/mglview${EXECUTABLE_SUFFIX}")
file(RENAME "${CURRENT_PACKAGES_DIR}/bin/mglview${EXECUTABLE_SUFFIX}" "${CURRENT_PACKAGES_DIR}/tools/mathgl/mglview${EXECUTABLE_SUFFIX}")
endif()
if (EXISTS "${CURRENT_PACKAGES_DIR}/bin/udav${EXECUTABLE_SUFFIX}")
file(RENAME "${CURRENT_PACKAGES_DIR}/bin/udav${EXECUTABLE_SUFFIX}" "${CURRENT_PACKAGES_DIR}/tools/mathgl/udav${EXECUTABLE_SUFFIX}")
endif()
file(REMOVE_RECURSE
"${CURRENT_PACKAGES_DIR}/debug/share"
"${CURRENT_PACKAGES_DIR}/debug/include"
"${CURRENT_PACKAGES_DIR}/share/applications"
"${CURRENT_PACKAGES_DIR}/share/mime"
"${CURRENT_PACKAGES_DIR}/share/pixmaps"
)
vcpkg_copy_tool_dependencies("${CURRENT_PACKAGES_DIR}/tools/mathgl")
if(VCPKG_LIBRARY_LINKAGE STREQUAL static)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin")
set(tools mglconv mgltask)
if(NOT VCPKG_CROSSCOMPILING)
list(APPEND tools make_bin)
endif()
if(enable-fltk)
list(APPEND tools mglview mgllab)
endif()
if(enable-qt5)
list(APPEND tools mglview udav)
endif()
list(REMOVE_DUPLICATES tools)
vcpkg_copy_tools(TOOL_NAMES ${tools} AUTO_CLEAN)
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/mgl2/config.h" "#define MGL_INSTALL_DIR \"${CURRENT_PACKAGES_DIR}\"" "")
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/mgl2/config.h" "#define MGL_FONT_PATH\t\"${CURRENT_PACKAGES_DIR}/fonts\"" "") # there is no fonts folder
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/mgl2/config.h" "#define MGL_FONT_PATH\t\"${CURRENT_PACKAGES_DIR}/share/mathgl/fonts\"" "")
file(INSTALL "${SOURCE_PATH}/COPYING" DESTINATION "${CURRENT_PACKAGES_DIR}/share/mathgl" RENAME copyright)
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
file(INSTALL "${SOURCE_PATH}/COPYING" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)

4
ports/mathgl/usage Normal file
View File

@ -0,0 +1,4 @@
mathgl provides CMake targets:
find_package(MathGL2 CONFIG REQUIRED)
target_link_libraries(main PRIVATE $<IF:$<TARGET_EXISTS:mgl>,mgl,mgl-static>)

View File

@ -1,10 +1,17 @@
{
"name": "mathgl",
"version": "2.5",
"port-version": 2,
"version": "8.0.1",
"description": "MathGL is a free library of fast C++ routines for the plotting of the data varied in one or more dimensions",
"license": "GPL-3.0-only",
"supports": "!uwp",
"dependencies": [
"getopt",
{
"$comment": "Non-windows targets need host `make_bin`.",
"name": "mathgl",
"host": true,
"default-features": false
},
{
"name": "vcpkg-cmake",
"host": true
@ -27,10 +34,16 @@
"armadillo"
]
},
"examples": {
"description": "Build example programs (not installed)"
},
"fltk": {
"description": "fltk module",
"dependencies": [
"fltk"
{
"name": "fltk",
"default-features": false
}
]
},
"gif": {
@ -42,7 +55,17 @@
"glut": {
"description": "glut module",
"dependencies": [
"freeglut"
{
"name": "freeglut",
"platform": "!osx"
},
{
"name": "mathgl",
"default-features": false,
"features": [
"opengl"
]
}
]
},
"gsl": {
@ -54,7 +77,10 @@
"hdf5": {
"description": "hdf5 module",
"dependencies": [
"hdf5"
{
"name": "hdf5",
"default-features": false
}
]
},
"jpeg": {
@ -78,13 +104,19 @@
"qt5": {
"description": "qt5 module",
"dependencies": [
"qt5"
{
"name": "qt5-base",
"default-features": false
}
]
},
"wx": {
"description": "wx module",
"dependencies": [
"wxwidgets"
{
"name": "wxwidgets",
"default-features": false
}
]
},
"zlib": {

View File

@ -566,10 +566,6 @@ marble:arm-uwp=fail
marble:x64-linux=fail
marble:x64-osx=fail
marble:x86-windows=fail
mathgl:arm-uwp=fail
mathgl:x64-osx=fail
mathgl:arm64-osx=fail
mathgl:x64-uwp=fail
mecab:arm64-windows = skip
mecab:arm-uwp = skip
mecab:x64-linux = skip
@ -1231,6 +1227,12 @@ vcpkg-ci-llvm:x64-windows-static-md=pass
vcpkg-ci-llvm:x64-windows-static=pass
vcpkg-ci-llvm:x64-windows=pass
vcpkg-ci-llvm:x86-windows=pass
vcpkg-ci-mathgl:x64-linux=pass
vcpkg-ci-mathgl:x64-osx=pass
vcpkg-ci-mathgl:x64-windows=pass
vcpkg-ci-mathgl:x64-windows-static=pass
vcpkg-ci-mathgl:x64-windows-static-md=pass
vcpkg-ci-mathgl:x86-windows=pass
vcpkg-ci-opencv:arm-uwp=pass
vcpkg-ci-opencv:arm64-windows=pass
vcpkg-ci-opencv:x64-linux=pass

View File

@ -0,0 +1 @@
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)

View File

@ -0,0 +1,26 @@
{
"name": "vcpkg-ci-mathgl",
"version-date": "2022-12-28",
"description": "Ensures that the vcpkg CI build of mathgl tests all features and examples",
"license": "MIT",
"dependencies": [
{
"name": "mathgl",
"features": [
"arma",
"examples",
"fltk",
"gif",
"glut",
"gsl",
"hdf5",
"jpeg",
"opengl",
"png",
"qt5",
"wx",
"zlib"
]
}
]
}

View File

@ -4817,8 +4817,8 @@
"port-version": 1
},
"mathgl": {
"baseline": "2.5",
"port-version": 2
"baseline": "8.0.1",
"port-version": 0
},
"matio": {
"baseline": "1.5.23",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "8fd2208b95f6ebc6f17a30cc79c3b57b1a8bcfb7",
"version": "8.0.1",
"port-version": 0
},
{
"git-tree": "e86f7ba9325f53bd43f5713e38d78fba18e7bc1d",
"version": "2.5",