Skip to content

Commit c1508b1

Browse files
committed
CMake: only use the simple header check for libjpeg-turbo
The build-time check does not work when: * using LibVNCServer as a CMake subdir together with turbojpeg CMake subdir, since turbojpeg is not yet built when LibVNCServer is configured * when built with MSVC and Conan
1 parent 363871e commit c1508b1

1 file changed

Lines changed: 5 additions & 41 deletions

File tree

CMakeLists.txt

Lines changed: 5 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -96,48 +96,12 @@ if(WITH_JPEG)
9696
if(JPEG_FOUND)
9797
# Check whether the version of libjpeg we found was libjpeg-turbo and print a
9898
# warning if not.
99-
set(CMAKE_REQUIRED_LIBRARIES ${JPEG_LIBRARIES})
100-
if(JPEG_INCLUDE_DIRS) # this was not present in 3.4
101-
set(CMAKE_REQUIRED_INCLUDES ${JPEG_INCLUDE_DIRS})
102-
else()
103-
set(CMAKE_REQUIRED_INCLUDES ${JPEG_INCLUDE_DIR})
104-
endif()
105-
106-
set(JPEG_TEST_SOURCE "\n
107-
#include <stdio.h>\n
108-
#include <jpeglib.h>\n
109-
int main(void) {\n
110-
struct jpeg_compress_struct cinfo;\n
111-
struct jpeg_error_mgr jerr;\n
112-
cinfo.err=jpeg_std_error(&jerr);\n
113-
jpeg_create_compress(&cinfo);\n
114-
cinfo.input_components = 3;\n
115-
jpeg_set_defaults(&cinfo);\n
116-
cinfo.in_color_space = JCS_EXT_RGB;\n
117-
jpeg_default_colorspace(&cinfo);\n
118-
return 0;\n
119-
}")
120-
121-
if(CMAKE_CROSSCOMPILING)
122-
check_c_source_compiles("${JPEG_TEST_SOURCE}" FOUND_LIBJPEG_TURBO)
123-
else()
124-
check_c_source_runs("${JPEG_TEST_SOURCE}" FOUND_LIBJPEG_TURBO)
125-
endif()
126-
127-
set(CMAKE_REQUIRED_LIBRARIES)
128-
set(CMAKE_REQUIRED_INCLUDES)
129-
set(CMAKE_REQUIRED_DEFINITIONS)
130-
99+
get_filename_component(JPEGLIB_H_PATH "${JPEG_INCLUDE_DIR}/jpeglib.h" REALPATH BASE_DIR "${CMAKE_SOURCE_DIR}")
100+
file(STRINGS ${JPEGLIB_H_PATH} FOUND_LIBJPEG_TURBO REGEX "JCS_EXT_RGB")
131101
if(NOT FOUND_LIBJPEG_TURBO)
132-
# last-resort grep check (when using LibVNCServer as a CMake subdir together with turbojpeg CMake subdir, the build check above fails since turbojpeg is not yet built when LibVNCServer is configured)
133-
get_filename_component(JPEGLIB_H_PATH "${JPEG_INCLUDE_DIR}/jpeglib.h" REALPATH BASE_DIR "${CMAKE_SOURCE_DIR}")
134-
message(STATUS "Runtime check for libjpeg-turbo failed, inspecting ${JPEGLIB_H_PATH}")
135-
file(STRINGS ${JPEGLIB_H_PATH} FOUND_LIBJPEG_TURBO REGEX "JCS_EXT_RGB")
136-
if(NOT FOUND_LIBJPEG_TURBO)
137-
message(WARNING "*** The libjpeg library you are building against is not libjpeg-turbo. Performance will be reduced. You can obtain libjpeg-turbo from: https://sourceforge.net/projects/libjpeg-turbo/files/ ***")
138-
else()
139-
message(STATUS "Detected libjpeg-turbo via ${JPEGLIB_H_PATH}")
140-
endif()
102+
message(WARNING "*** The libjpeg library you are building against is not libjpeg-turbo. Performance will be reduced. You can obtain libjpeg-turbo from: https://sourceforge.net/projects/libjpeg-turbo/files/ ***")
103+
else()
104+
message(STATUS "Detected libjpeg-turbo via ${JPEGLIB_H_PATH}")
141105
endif()
142106
endif(JPEG_FOUND)
143107
endif(WITH_JPEG)

0 commit comments

Comments
 (0)