Skip to content

Commit 6a83286

Browse files
committed
cmake: Fix rebuilding error with stale cache files
check_c_source_compiles would generate wrong files if the user does not set correct variables initially even given correct values later. Protect against this scenario. This should fix #418. Also remove "-MT" flags for MSVC which seems to do no good here.
1 parent 26b3cbd commit 6a83286

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

cmake_modules/FindTurboJPEG.cmake

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,15 @@ FIND_LIBRARY(TurboJPEG_LIBRARIES
3838
lib64
3939
)
4040

41+
IF(TurboJPEG_INCLUDE_DIRS AND TurboJPEG_LIBRARIES)
4142
INCLUDE(CheckCSourceCompiles)
42-
if(MSVC)
43-
set(CMAKE_REQUIRED_DEFINITIONS -MT)
44-
endif()
4543
set(CMAKE_REQUIRED_INCLUDES ${TurboJPEG_INCLUDE_DIRS})
4644
set(CMAKE_REQUIRED_LIBRARIES ${TurboJPEG_LIBRARIES})
4745
check_c_source_compiles("#include <turbojpeg.h>\nint main(void) { tjhandle h=tjInitCompress(); return 0; }" TURBOJPEG_WORKS)
4846
set(CMAKE_REQUIRED_DEFINITIONS)
4947
set(CMAKE_REQUIRED_INCLUDES)
5048
set(CMAKE_REQUIRED_LIBRARIES)
49+
ENDIF()
5150

5251
INCLUDE(FindPackageHandleStandardArgs)
5352
FIND_PACKAGE_HANDLE_STANDARD_ARGS(TurboJPEG DEFAULT_MSG TurboJPEG_LIBRARIES TurboJPEG_INCLUDE_DIRS TURBOJPEG_WORKS)

0 commit comments

Comments
 (0)