diff options
| author | Charles Karney <charles.karney@sri.com> | 2019-09-21 08:43:57 -0400 |
|---|---|---|
| committer | Charles Karney <charles.karney@sri.com> | 2019-09-21 08:43:57 -0400 |
| commit | ddadb683bd6c1ed82c7069b2fcb917499dcb1923 (patch) | |
| tree | d1286510a0a6d72bce6a041e5f52d5993a04cb28 /cmake/CMakeLists.txt | |
| parent | cd505feb34aaa60158bb9034d3e45d198058350c (diff) | |
| download | PROJ-ddadb683bd6c1ed82c7069b2fcb917499dcb1923.tar.gz PROJ-ddadb683bd6c1ed82c7069b2fcb917499dcb1923.zip | |
Improve Visual Studio compatibility check in CMake.
Make the setting of major toolset version variables parallel that for
cross-compilation. Add comments so it's easier for the next person
looking at this code to figure what's going on. Note: no need to unset
variables at the end of the version check file (the file is read in a
nested scope).
Diffstat (limited to 'cmake/CMakeLists.txt')
| -rw-r--r-- | cmake/CMakeLists.txt | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 61c69f7c..b9cff123 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -5,11 +5,24 @@ file(RELATIVE_PATH PROJECT_ROOT_DIR ${CMAKE_INSTALL_PREFIX}/${CMAKECONFIGDIR} ${CMAKE_INSTALL_PREFIX}) -if(CMAKE_CROSSCOMPILING) - set(CMAKE_CROSSCOMPILING_STR "ON") -else() - set(CMAKE_CROSSCOMPILING_STR "OFF") -endif() +# Variables needed by ${PROJECT_NAME_LOWER}-config-version.cmake +if (MSVC) + # For checking the compatibility of MSVC_TOOLSET_VERSION; see + # https://docs.microsoft.com/en-us/cpp/porting/overview-of-potential-upgrade-issues-visual-cpp + # Assume major version number is obtained by dropping the last decimal + # digit. + math (EXPR MSVC_TOOLSET_MAJOR "${MSVC_TOOLSET_VERSION}/10") +else () + set (MSVC_TOOLSET_VERSION 0) + set (MSVC_TOOLSET_MAJOR 0) +endif () +if (CMAKE_CROSSCOMPILING) + # Ensure that all "true" (resp. "false") settings are represented by + # the same string. + set (CMAKE_CROSSCOMPILING_STR "ON") +else () + set (CMAKE_CROSSCOMPILING_STR "OFF") +endif () string(TOLOWER "${PROJECT_NAME}" PROJECT_NAME_LOWER) configure_file(project-config.cmake.in project-config.cmake @ONLY) |
