File tree 3 files changed +53
-16
lines changed
3 files changed +53
-16
lines changed Original file line number Diff line number Diff line change @@ -455,15 +455,29 @@ inclusion(GLIB2_DIR GLIB2_INCLUDE_DIRS)
455
455
456
456
# find libraries using pkg-config
457
457
find_package (PkgConfig REQUIRED)
458
+ include (PkgConfigTools.cmake)
459
+ save_pkg_config_env()
458
460
459
- pkg_search_module(FONTCONFIG REQUIRED fontconfig>=2.11.0)
460
- message (STATUS "fontconfig found: ${FONTCONFIG_VERSION} " )
461
+ if (DEFINED ENV{OPENSCAD_LIBRARIES})
462
+ set (ENV{PKG_CONFIG_PATH} "$ENV{OPENSCAD_LIBRARIES} /lib/pkgconfig" )
463
+ endif ()
464
+
465
+ pkg_check_modules(FONTCONFIG REQUIRED fontconfig>=2.11.0)
466
+ if (FONTCONFIG_VERSION)
467
+ message (STATUS "fontconfig ${FONTCONFIG_VERSION} found: ${FONTCONFIG_INCLUDE_DIRS} " )
468
+ endif ()
461
469
462
- pkg_search_module(FREETYPE REQUIRED freetype2>=2.4.9)
463
- message (STATUS "freetype2 found: ${FREETYPE_VERSION} " )
470
+ pkg_check_modules(FREETYPE REQUIRED freetype2>=2.4.9)
471
+ if (FREETYPE_VERSION)
472
+ message (STATUS "freetype2 ${FREETYPE_VERSION} found: ${FREETYPE_INCLUDE_DIRS} " )
473
+ endif ()
474
+
475
+ pkg_check_modules(HARFBUZZ REQUIRED harfbuzz>=0.9.19)
476
+ if (HARFBUZZ_VERSION)
477
+ message (STATUS "harfbuzz ${HARFBUZZ_VERSION} found: ${HARFBUZZ_INCLUDE_DIRS} " )
478
+ endif ()
464
479
465
- pkg_search_module(HARFBUZZ REQUIRED harfbuzz>=0.9.19)
466
- message (STATUS "harfbuzz found: ${HARFBUZZ_VERSION} " )
480
+ restore_pkg_config_env()
467
481
468
482
add_definitions (${FONTCONFIG_CFLAGS} )
469
483
add_definitions (${FREETYPE_CFLAGS} )
Original file line number Diff line number Diff line change 1
1
message (STATUS "running openscad/tests/FindGLIB2.cmake ..." )
2
2
3
+ include (PkgConfigTools.cmake)
4
+ save_pkg_config_env()
5
+
3
6
# GLIB2 requires pkg-config to build.
4
7
# If we are did an OPENSCAD_LIBRARIES dependency build of glib2, we need to
5
8
# tell pkg-config to look under OPENSCAD_LIBRARIES dir.
@@ -8,8 +11,6 @@ if (NOT $ENV{OPENSCAD_LIBRARIES} STREQUAL "")
8
11
if (EXISTS "$ENV{OPENSCAD_LIBRARIES} /include/glib-2.0/glib.h" )
9
12
message (STATUS "found glib.h under OPENSCAD_LIBRARIES." )
10
13
message (STATUS "redirecting pkg-config to look under OPENSCAD_LIBRARIES" )
11
- set (SAVED_PKG_CONFIG_PATH "$ENV{PKG_CONFIG_PATH} " )
12
- set (SAVED_PKG_CONFIG_LIBDIR "$ENV{PKG_CONFIG_LIBDIR} " )
13
14
set (ENV{PKG_CONFIG_PATH} "$ENV{OPENSCAD_LIBRARIES} /lib/pkgconfig" )
14
15
set (ENV{PKG_CONFIG_LIBDIR} "$ENV{OPENSCAD_LIBRARIES} /lib/pkgconfig" )
15
16
else ()
@@ -55,11 +56,4 @@ foreach(glib2libdir ${GLIB2_LIBRARIES})
55
56
message (STATUS " " ${glib2libdir} )
56
57
endforeach ()
57
58
58
- if (NOT $ENV{OPENSCAD_LIBRARIES} STREQUAL "" )
59
- if (EXISTS "$ENV{OPENSCAD_LIBRARIES} /include/glib-2.0/glib.h" )
60
- message (STATUS "resetting pkgconfig as it was" )
61
- else ()
62
- set (ENV{PKG_CONFIG_PATH} "${SAVED_PKG_CONFIG_PATH} " )
63
- set (ENV{PKG_CONFIG_LIBDIR} "${SAVED_PKG_CONFIG_LIBDIR} " )
64
- endif ()
65
- endif ()
59
+ restore_pkg_config_env()
Original file line number Diff line number Diff line change
1
+ # Use this to save the existing pkg-config settings
2
+ function (save_pkg_config_env)
3
+ message (STATUS "saving pkg-config env" )
4
+
5
+ if (DEFINED ENV{PKG_CONFIG_PATH})
6
+ set (SAVED_PKG_CONFIG_PATH "$ENV{PKG_CONFIG_PATH} " )
7
+ endif ()
8
+ if (DEFINED ENV{PKG_CONFIG_LIBDIR})
9
+ set (SAVED_PKG_CONFIG_LIBDIR "$ENV{PKG_CONFIG_LIBDIR} " )
10
+ endif ()
11
+ endfunction ()
12
+
13
+ # Use this to restore to the original pkg-config settings
14
+ function (restore_pkg_config_env)
15
+ message (STATUS "restoring pkg-config env" )
16
+
17
+ if (SAVED_PKG_CONFIG_PATH)
18
+ set (ENV{PKG_CONFIG_PATH} "${SAVED_PKG_CONFIG_PATH} " )
19
+ unset (SAVED_PKG_CONFIG_PATH)
20
+ else ()
21
+ unset (ENV{PKG_CONFIG_PATH})
22
+ endif ()
23
+ if (SAVED_PKG_CONFIG_LIBDIR)
24
+ set (ENV{PKG_CONFIG_LIBDIR} "${SAVED_PKG_CONFIG_LIBDIR} " )
25
+ unset (SAVED_PKG_CONFIG_LIBDIR)
26
+ else ()
27
+ unset (ENV{PKG_CONFIG_LIBDIR})
28
+ endif ()
29
+ endfunction ()
You can’t perform that action at this time.
0 commit comments