mirror of https://github.com/vitalif/openscad
bugfix: FindGLIB2 didn't clean up properly. added new pkg-config utility functions which can be reused
parent
db19afcf80
commit
8ac0209db5
|
@ -455,15 +455,29 @@ inclusion(GLIB2_DIR GLIB2_INCLUDE_DIRS)
|
|||
|
||||
# find libraries using pkg-config
|
||||
find_package(PkgConfig REQUIRED)
|
||||
include(PkgConfigTools.cmake)
|
||||
save_pkg_config_env()
|
||||
|
||||
pkg_search_module(FONTCONFIG REQUIRED fontconfig>=2.11.0)
|
||||
message(STATUS "fontconfig found: ${FONTCONFIG_VERSION}")
|
||||
if (DEFINED ENV{OPENSCAD_LIBRARIES})
|
||||
set(ENV{PKG_CONFIG_PATH} "$ENV{OPENSCAD_LIBRARIES}/lib/pkgconfig")
|
||||
endif()
|
||||
|
||||
pkg_search_module(FREETYPE REQUIRED freetype2>=2.4.9)
|
||||
message(STATUS "freetype2 found: ${FREETYPE_VERSION}")
|
||||
pkg_check_modules(FONTCONFIG REQUIRED fontconfig>=2.11.0)
|
||||
if (FONTCONFIG_VERSION)
|
||||
message(STATUS "fontconfig ${FONTCONFIG_VERSION} found: ${FONTCONFIG_INCLUDE_DIRS}")
|
||||
endif()
|
||||
|
||||
pkg_search_module(HARFBUZZ REQUIRED harfbuzz>=0.9.19)
|
||||
message(STATUS "harfbuzz found: ${HARFBUZZ_VERSION}")
|
||||
pkg_check_modules(FREETYPE REQUIRED freetype2>=2.4.9)
|
||||
if (FREETYPE_VERSION)
|
||||
message(STATUS "freetype2 ${FREETYPE_VERSION} found: ${FREETYPE_INCLUDE_DIRS}")
|
||||
endif()
|
||||
|
||||
pkg_check_modules(HARFBUZZ REQUIRED harfbuzz>=0.9.19)
|
||||
if (HARFBUZZ_VERSION)
|
||||
message(STATUS "harfbuzz ${HARFBUZZ_VERSION} found: ${HARFBUZZ_INCLUDE_DIRS}")
|
||||
endif()
|
||||
|
||||
restore_pkg_config_env()
|
||||
|
||||
add_definitions(${FONTCONFIG_CFLAGS})
|
||||
add_definitions(${FREETYPE_CFLAGS})
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
message(STATUS "running openscad/tests/FindGLIB2.cmake ...")
|
||||
|
||||
include(PkgConfigTools.cmake)
|
||||
save_pkg_config_env()
|
||||
|
||||
# GLIB2 requires pkg-config to build.
|
||||
# If we are did an OPENSCAD_LIBRARIES dependency build of glib2, we need to
|
||||
# tell pkg-config to look under OPENSCAD_LIBRARIES dir.
|
||||
|
@ -8,8 +11,6 @@ if (NOT $ENV{OPENSCAD_LIBRARIES} STREQUAL "")
|
|||
if (EXISTS "$ENV{OPENSCAD_LIBRARIES}/include/glib-2.0/glib.h")
|
||||
message(STATUS "found glib.h under OPENSCAD_LIBRARIES.")
|
||||
message(STATUS "redirecting pkg-config to look under OPENSCAD_LIBRARIES")
|
||||
set(SAVED_PKG_CONFIG_PATH "$ENV{PKG_CONFIG_PATH}")
|
||||
set(SAVED_PKG_CONFIG_LIBDIR "$ENV{PKG_CONFIG_LIBDIR}")
|
||||
set(ENV{PKG_CONFIG_PATH} "$ENV{OPENSCAD_LIBRARIES}/lib/pkgconfig")
|
||||
set(ENV{PKG_CONFIG_LIBDIR} "$ENV{OPENSCAD_LIBRARIES}/lib/pkgconfig")
|
||||
else()
|
||||
|
@ -55,11 +56,4 @@ foreach(glib2libdir ${GLIB2_LIBRARIES})
|
|||
message(STATUS " " ${glib2libdir})
|
||||
endforeach()
|
||||
|
||||
if (NOT $ENV{OPENSCAD_LIBRARIES} STREQUAL "")
|
||||
if (EXISTS "$ENV{OPENSCAD_LIBRARIES}/include/glib-2.0/glib.h")
|
||||
message(STATUS "resetting pkgconfig as it was")
|
||||
else()
|
||||
set(ENV{PKG_CONFIG_PATH} "${SAVED_PKG_CONFIG_PATH}")
|
||||
set(ENV{PKG_CONFIG_LIBDIR} "${SAVED_PKG_CONFIG_LIBDIR}")
|
||||
endif()
|
||||
endif()
|
||||
restore_pkg_config_env()
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
# Use this to save the existing pkg-config settings
|
||||
function(save_pkg_config_env)
|
||||
message(STATUS "saving pkg-config env")
|
||||
|
||||
if (DEFINED ENV{PKG_CONFIG_PATH})
|
||||
set(SAVED_PKG_CONFIG_PATH "$ENV{PKG_CONFIG_PATH}")
|
||||
endif()
|
||||
if (DEFINED ENV{PKG_CONFIG_LIBDIR})
|
||||
set(SAVED_PKG_CONFIG_LIBDIR "$ENV{PKG_CONFIG_LIBDIR}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Use this to restore to the original pkg-config settings
|
||||
function(restore_pkg_config_env)
|
||||
message(STATUS "restoring pkg-config env")
|
||||
|
||||
if (SAVED_PKG_CONFIG_PATH)
|
||||
set(ENV{PKG_CONFIG_PATH} "${SAVED_PKG_CONFIG_PATH}")
|
||||
unset(SAVED_PKG_CONFIG_PATH)
|
||||
else()
|
||||
unset(ENV{PKG_CONFIG_PATH})
|
||||
endif()
|
||||
if (SAVED_PKG_CONFIG_LIBDIR)
|
||||
set(ENV{PKG_CONFIG_LIBDIR} "${SAVED_PKG_CONFIG_LIBDIR}")
|
||||
unset(SAVED_PKG_CONFIG_LIBDIR)
|
||||
else()
|
||||
unset(ENV{PKG_CONFIG_LIBDIR})
|
||||
endif()
|
||||
endfunction()
|
Loading…
Reference in New Issue