Propagate CMake flags to try_compile (fixes #1900) (#1905)

* Forward CMake environment flags to libjpeg tests

* Forward CMake environment flags to libpng tests
This commit is contained in:
Morwenn 2019-10-25 02:21:50 +02:00 committed by Davis E. King
parent 1b83016abd
commit e30f5e2fe8
2 changed files with 16 additions and 4 deletions

View File

@ -16,11 +16,17 @@ endif()
find_package(JPEG QUIET)
if(JPEG_FOUND)
if(JPEG_FOUND)
set(JPEG_TEST_CMAKE_FLAGS
"-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}"
"-DCMAKE_INCLUDE_PATH=${CMAKE_INCLUDE_PATH}"
"-DCMAKE_LIBRARY_PATH=${CMAKE_LIBRARY_PATH}")
try_compile(test_for_libjpeg_worked
${PROJECT_BINARY_DIR}/test_for_libjpeg_build
${CMAKE_CURRENT_LIST_DIR}/test_for_libjpeg
test_if_libjpeg_is_broken)
test_if_libjpeg_is_broken
CMAKE_FLAGS "${JPEG_TEST_CMAKE_FLAGS}")
message (STATUS "Found system copy of libjpeg: ${JPEG_LIBRARY}")
if(NOT test_for_libjpeg_worked)

View File

@ -16,11 +16,17 @@ endif()
find_package(PNG QUIET)
if(PNG_FOUND)
if(PNG_FOUND)
set(PNG_TEST_CMAKE_FLAGS
"-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}"
"-DCMAKE_INCLUDE_PATH=${CMAKE_INCLUDE_PATH}"
"-DCMAKE_LIBRARY_PATH=${CMAKE_LIBRARY_PATH}")
try_compile(test_for_libpng_worked
${PROJECT_BINARY_DIR}/test_for_libpng_build
${CMAKE_CURRENT_LIST_DIR}/test_for_libpng
test_if_libpng_is_broken)
test_if_libpng_is_broken
CMAKE_FLAGS "${PNG_TEST_CMAKE_FLAGS}")
message (STATUS "Found system copy of libpng: ${PNG_LIBRARIES}")
if(NOT test_for_libpng_worked)