mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-02-11 18:00:51 +08:00
Fix Windows CMake compiler/OS detection.
Replaced deprecated `DetermineVSServicePack`macro with recommended `CMAKE_CXX_COMPILER_VERSION`. Deleted custom `OSVersion` detection. The windows-specific code is highly outdated, and on other systems simply returns `CMAKE_SYSTEM`. We will get values like `windows-10.0.17763`, but this is preferable to `unknownwin`, and saves us needing to maintain a separate cmake file.
This commit is contained in:
parent
1d75fab368
commit
2bf07fa5b5
@ -1,46 +0,0 @@
|
|||||||
# The utility function DetermineOSVersion aims at providing an
|
|
||||||
# improved version of the CMake variable ${CMAKE_SYSTEM} on Windows
|
|
||||||
# machines.
|
|
||||||
#
|
|
||||||
# Usage:
|
|
||||||
# include(EigenDetermineOSVersion)
|
|
||||||
# DetermineOSVersion(OS_VERSION)
|
|
||||||
# message("OS: ${OS_VERSION}")
|
|
||||||
|
|
||||||
# - A little helper variable which should not be directly called
|
|
||||||
function(DetermineShortWindowsName WIN_VERSION win_num_version)
|
|
||||||
if (${win_num_version} VERSION_EQUAL "6.1")
|
|
||||||
set(_version "win7")
|
|
||||||
elseif(${win_num_version} VERSION_EQUAL "6.0")
|
|
||||||
set(_version "winVista")
|
|
||||||
elseif(${win_num_version} VERSION_EQUAL "5.2")
|
|
||||||
set(_version "winXpProf")
|
|
||||||
elseif(${win_num_version} VERSION_EQUAL "5.1")
|
|
||||||
set(_version "winXp")
|
|
||||||
elseif(${win_num_version} VERSION_EQUAL "5.0")
|
|
||||||
set(_version "win2000Prof")
|
|
||||||
else()
|
|
||||||
set(_version "unknownWin")
|
|
||||||
endif()
|
|
||||||
set(${WIN_VERSION} ${_version} PARENT_SCOPE)
|
|
||||||
endfunction()
|
|
||||||
|
|
||||||
function(DetermineOSVersion OS_VERSION)
|
|
||||||
if (WIN32 AND CMAKE_HOST_SYSTEM_NAME MATCHES Windows)
|
|
||||||
file (TO_NATIVE_PATH "$ENV{COMSPEC}" SHELL)
|
|
||||||
exec_program( ${SHELL} ARGS "/c" "ver" OUTPUT_VARIABLE ver_output)
|
|
||||||
|
|
||||||
string(REGEX MATCHALL "[0-9]+"
|
|
||||||
ver_list "${ver_output}")
|
|
||||||
list(GET ver_list 0 _major)
|
|
||||||
list(GET ver_list 1 _minor)
|
|
||||||
|
|
||||||
set(win_num_version ${_major}.${_minor})
|
|
||||||
DetermineShortWindowsName(win_version "${win_num_version}")
|
|
||||||
if(win_version)
|
|
||||||
set(${OS_VERSION} ${win_version} PARENT_SCOPE)
|
|
||||||
endif()
|
|
||||||
else()
|
|
||||||
set(${OS_VERSION} ${CMAKE_SYSTEM} PARENT_SCOPE)
|
|
||||||
endif()
|
|
||||||
endfunction()
|
|
@ -1,41 +0,0 @@
|
|||||||
include(CMakeDetermineVSServicePack)
|
|
||||||
|
|
||||||
# The code is almost identical to the CMake version. The only difference is that we remove
|
|
||||||
# _DetermineVSServicePack_FastCheckVersionWithCompiler which lead to errors on some systems.
|
|
||||||
function(EigenDetermineVSServicePack _pack)
|
|
||||||
if(NOT DETERMINED_VS_SERVICE_PACK OR NOT ${_pack})
|
|
||||||
if(NOT DETERMINED_VS_SERVICE_PACK)
|
|
||||||
_DetermineVSServicePack_CheckVersionWithTryCompile(DETERMINED_VS_SERVICE_PACK _cl_version)
|
|
||||||
if(NOT DETERMINED_VS_SERVICE_PACK)
|
|
||||||
_DetermineVSServicePack_CheckVersionWithTryRun(DETERMINED_VS_SERVICE_PACK _cl_version)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(DETERMINED_VS_SERVICE_PACK)
|
|
||||||
if(_cl_version)
|
|
||||||
# Call helper function to determine VS version
|
|
||||||
_DetermineVSServicePackFromCompiler(_sp "${_cl_version}")
|
|
||||||
|
|
||||||
# temporary fix, until CMake catches up
|
|
||||||
if (NOT _sp)
|
|
||||||
if(${_cl_version} VERSION_EQUAL "17.00.50727.1")
|
|
||||||
set(_sp "vc110")
|
|
||||||
elseif(${_cl_version} VERSION_EQUAL "17.00.51106.1")
|
|
||||||
set(_sp "vc110sp1")
|
|
||||||
elseif(${_cl_version} VERSION_EQUAL "17.00.60315.1")
|
|
||||||
set(_sp "vc110sp2")
|
|
||||||
elseif(${_cl_version} VERSION_EQUAL "17.00.60610.1")
|
|
||||||
set(_sp "vc110sp3")
|
|
||||||
else()
|
|
||||||
set(_sp ${CMAKE_CXX_COMPILER_VERSION})
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(_sp)
|
|
||||||
set(${_pack} ${_sp} CACHE INTERNAL
|
|
||||||
"The Visual Studio Release with Service Pack")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endfunction()
|
|
@ -462,15 +462,7 @@ endmacro()
|
|||||||
|
|
||||||
macro(ei_get_compilerver VAR)
|
macro(ei_get_compilerver VAR)
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
# on windows system, we use a modified CMake script
|
set(${VAR} "${CMAKE_CXX_COMPILER_VERSION}")
|
||||||
include(EigenDetermineVSServicePack)
|
|
||||||
EigenDetermineVSServicePack( my_service_pack )
|
|
||||||
|
|
||||||
if( my_service_pack )
|
|
||||||
set(${VAR} ${my_service_pack})
|
|
||||||
else()
|
|
||||||
set(${VAR} "na")
|
|
||||||
endif()
|
|
||||||
elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "PGI")
|
elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "PGI")
|
||||||
set(${VAR} "${CMAKE_CXX_COMPILER_ID}-${CMAKE_CXX_COMPILER_VERSION}")
|
set(${VAR} "${CMAKE_CXX_COMPILER_ID}-${CMAKE_CXX_COMPILER_VERSION}")
|
||||||
else()
|
else()
|
||||||
@ -605,10 +597,7 @@ macro(ei_set_build_string)
|
|||||||
ei_get_compilerver(LOCAL_COMPILER_VERSION)
|
ei_get_compilerver(LOCAL_COMPILER_VERSION)
|
||||||
ei_get_cxxflags(LOCAL_COMPILER_FLAGS)
|
ei_get_cxxflags(LOCAL_COMPILER_FLAGS)
|
||||||
|
|
||||||
include(EigenDetermineOSVersion)
|
set(TMP_BUILD_STRING ${CMAKE_SYSTEM}-${LOCAL_COMPILER_VERSION})
|
||||||
DetermineOSVersion(OS_VERSION)
|
|
||||||
|
|
||||||
set(TMP_BUILD_STRING ${OS_VERSION}-${LOCAL_COMPILER_VERSION})
|
|
||||||
|
|
||||||
if (NOT ${LOCAL_COMPILER_FLAGS} STREQUAL "")
|
if (NOT ${LOCAL_COMPILER_FLAGS} STREQUAL "")
|
||||||
set(TMP_BUILD_STRING ${TMP_BUILD_STRING}-${LOCAL_COMPILER_FLAGS})
|
set(TMP_BUILD_STRING ${TMP_BUILD_STRING}-${LOCAL_COMPILER_FLAGS})
|
||||||
|
Loading…
Reference in New Issue
Block a user