Skip to content

Commit e859760

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 9e1d879 commit e859760

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
@@ -97,48 +97,12 @@ if(WITH_JPEG)
9797
if(JPEG_FOUND)
9898
# Check whether the version of libjpeg we found was libjpeg-turbo and print a
9999
# warning if not.
100-
set(CMAKE_REQUIRED_LIBRARIES ${JPEG_LIBRARIES})
101-
if(JPEG_INCLUDE_DIRS) # this was not present in 3.4
102-
set(CMAKE_REQUIRED_INCLUDES ${JPEG_INCLUDE_DIRS})
103-
else()
104-
set(CMAKE_REQUIRED_INCLUDES ${JPEG_INCLUDE_DIR})
105-
endif()
106-
107-
set(JPEG_TEST_SOURCE "\n
108-
#include <stdio.h>\n
109-
#include <jpeglib.h>\n
110-
int main(void) {\n
111-
struct jpeg_compress_struct cinfo;\n
112-
struct jpeg_error_mgr jerr;\n
113-
cinfo.err=jpeg_std_error(&jerr);\n
114-
jpeg_create_compress(&cinfo);\n
115-
cinfo.input_components = 3;\n
116-
jpeg_set_defaults(&cinfo);\n
117-
cinfo.in_color_space = JCS_EXT_RGB;\n
118-
jpeg_default_colorspace(&cinfo);\n
119-
return 0;\n
120-
}")
121-
122-
if(CMAKE_CROSSCOMPILING)
123-
check_c_source_compiles("${JPEG_TEST_SOURCE}" FOUND_LIBJPEG_TURBO)
124-
else()
125-
check_c_source_runs("${JPEG_TEST_SOURCE}" FOUND_LIBJPEG_TURBO)
126-
endif()
127-
128-
set(CMAKE_REQUIRED_LIBRARIES)
129-
set(CMAKE_REQUIRED_INCLUDES)
130-
set(CMAKE_REQUIRED_DEFINITIONS)
131-
100+
get_filename_component(JPEGLIB_H_PATH "${JPEG_INCLUDE_DIR}/jpeglib.h" REALPATH BASE_DIR "${CMAKE_SOURCE_DIR}")
101+
file(STRINGS ${JPEGLIB_H_PATH} FOUND_LIBJPEG_TURBO REGEX "JCS_EXT_RGB")
132102
if(NOT FOUND_LIBJPEG_TURBO)
133-
# 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)
134-
get_filename_component(JPEGLIB_H_PATH "${JPEG_INCLUDE_DIR}/jpeglib.h" REALPATH BASE_DIR "${CMAKE_SOURCE_DIR}")
135-
message(STATUS "Runtime check for libjpeg-turbo failed, inspecting ${JPEGLIB_H_PATH}")
136-
file(STRINGS ${JPEGLIB_H_PATH} FOUND_LIBJPEG_TURBO REGEX "JCS_EXT_RGB")
137-
if(NOT FOUND_LIBJPEG_TURBO)
138-
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/ ***")
139-
else()
140-
message(STATUS "Detected libjpeg-turbo via ${JPEGLIB_H_PATH}")
141-
endif()
103+
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/ ***")
104+
else()
105+
message(STATUS "Detected libjpeg-turbo via ${JPEGLIB_H_PATH}")
142106
endif()
143107
endif(JPEG_FOUND)
144108
endif(WITH_JPEG)

0 commit comments

Comments
 (0)