Skip to content

Commit

Permalink
For a given msvc compiler introduce backward compatibility
Browse files Browse the repository at this point in the history
If a project is build with msvc17, it is now possible to use ViSP build with msvc16
  • Loading branch information
fspindle committed Sep 15, 2023
1 parent 6c62eb5 commit 9de1bd8
Showing 1 changed file with 43 additions and 1 deletion.
44 changes: 43 additions & 1 deletion cmake/templates/VISPConfig.root-WIN32.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,27 @@
# include(${VISP_USE_FILE})
# endif()
#
#
#############################################################################

function(check_one_config RES)
set(${RES} "" PARENT_SCOPE)
if(NOT VISP_RUNTIME OR NOT VISP_ARCH)
return()
endif()
set(candidates)
if(VISP_STATIC)
list(APPEND candidates "${VISP_ARCH}/${VISP_RUNTIME}/staticlib")
endif()
list(APPEND candidates "${VISP_ARCH}/${VISP_RUNTIME}/lib")
foreach(c ${candidates})
set(p "${VISP_CONFIG_PATH}/${c}")
if(EXISTS "${p}/VISPConfig.cmake")
set(${RES} "${p}" PARENT_SCOPE)
return()
endif()
endforeach()
endfunction()

# similar code exist in VISPDetectPlatform.cmake
if(DEFINED VISP_ARCH AND DEFINED VISP_RUNTIME)
# custom overridden values
Expand All @@ -92,10 +110,34 @@ elseif(MSVC)
set(VISP_RUNTIME vc14)
elseif(MSVC_VERSION MATCHES "^191[0-9]$")
set(VISP_RUNTIME vc15)
check_one_config(has_VS2017)
if(NOT has_VS2017)
set(VISP_RUNTIME vc14) # selecting previous compatible runtime version
endif()
elseif(MSVC_VERSION MATCHES "^192[0-9]$")
set(VISP_RUNTIME vc16)
check_one_config(has_VS2019)
if(NOT has_VS2019)
set(VISP_RUNTIME vc15) # selecting previous compatible runtime version
check_one_config(has_VS2017)
if(NOT has_VS2017)
set(VISP_RUNTIME vc14) # selecting previous compatible runtime version
endif()
endif()
elseif(MSVC_VERSION MATCHES "^193[0-9]$")
set(VISP_RUNTIME vc17)
check_one_config(has_VS2022)
if(NOT has_VS2022)
set(VISP_RUNTIME vc16)
check_one_config(has_VS2019)
if(NOT has_VS2019)
set(VISP_RUNTIME vc15) # selecting previous compatible runtime version
check_one_config(has_VS2017)
if(NOT has_VS2017)
set(VISP_RUNTIME vc14) # selecting previous compatible runtime version
endif()
endif()
endif()
else()
message(WARNING "ViSP does not recognize MSVC_VERSION \"${MSVC_VERSION}\". Cannot set VISP_RUNTIME")
endif()
Expand Down

0 comments on commit 9de1bd8

Please sign in to comment.