Description | As it came up in issue 0014029, I discovered that currently no attempt is made to populate CMAKE_CXX_LIBRARY_ARCHTECTURE for the Windows-MSVC Platform.
The attached patch should do so, for both MSVC and Clang-CL (pretending to be MSVC), based on the path to the MSVC-bundled runtime libraries.
The main outstanding issue is that CMAKE_CXX_LIBRARY_ARCHITECTURE's not as useful on this platform as it could be, as there's no solid consensus on what this value should be (Microsoft appear to have changed their opinion about it as they've gone through Visual Studio and Platform SDK releases.
I don't have Visual Studio 2013 here or extra platforms installed for the Visual Studio installations I do have, so it's possible the regex is missing some options. It'd be nice if the "/lib/" in the path match was part of the regex variable instead of being always present, as then "/VC/lib/(.*)" would be a safer match.
http://cmake.org/Bug/view.php?id=14029 [^] |
Attached Files | 0001-MSVC-Populate-CMAKE_CXX_LIBRARY_ARCHITECTURE.patch [^] (5,537 bytes) 2013-10-10 06:20 [Show Content] [Hide Content]From 6fb90a55479b4017f4eb47970b2eb87be01e65e2 Mon Sep 17 00:00:00 2001
From: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
Date: Thu, 10 Oct 2013 16:59:02 +0700
Subject: [PATCH] MSVC: Populate CMAKE_CXX_LIBRARY_ARCHITECTURE
CMAKE_CXX_LIBRARY_ARCHITECTURE is based on the directory name under
<Visual Studio Install Dir>/VC/lib/ recognising "", "amd64", "IA64" and
"arm".
This value isn't as immediately useful as it is on other platforms, as a
lot of other SDKs, including the Windows Platform SDK version 8 and the
DirectX SDK, use "x86" for 32-bit Intel and "x64" for the 64-bit AMD64
platform.
Signed-off-by: Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
---
Modules/CMakeParseImplicitLinkInfo.cmake | 14 ++++++++++++++
Modules/Compiler/Clang.cmake | 2 ++
Modules/Compiler/MSVC-C.cmake | 2 ++
Modules/Compiler/MSVC-CXX.cmake | 2 ++
Modules/Compiler/{Clang.cmake => MSVC.cmake} | 24 +++++++-----------------
Modules/Platform/Windows-MSVC.cmake | 3 +++
6 files changed, 30 insertions(+), 17 deletions(-)
create mode 100644 Modules/Compiler/MSVC-C.cmake
create mode 100644 Modules/Compiler/MSVC-CXX.cmake
copy Modules/Compiler/{Clang.cmake => MSVC.cmake} (57%)
diff --git a/Modules/CMakeParseImplicitLinkInfo.cmake b/Modules/CMakeParseImplicitLinkInfo.cmake
index 4724a8c..528032b 100644
--- a/Modules/CMakeParseImplicitLinkInfo.cmake
+++ b/Modules/CMakeParseImplicitLinkInfo.cmake
@@ -104,6 +104,19 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj
string(REPLACE ":" ";" paths "${paths}")
list(APPEND implicit_dirs_tmp ${paths})
set(log "${log} dirs [${paths}]\n")
+ elseif("${line}" MATCHES "Searching .*:$")
+ set(log "${log} LINK.EXE Searching line: [${line}]\n")
+ # MSVC Linker object search
+ string(REGEX REPLACE ".*Searching " "" fullpath "${line}")
+ string(REGEX REPLACE ":$" "" fullpath "${fullpath}")
+ string(FIND "${fullpath}" "\\" lastslash REVERSE)
+ string(SUBSTRING "${fullpath}" 0 ${lastslash} path)
+ math(EXPR startoflib "${lastslash} + 1")
+ string(SUBSTRING "${fullpath}" ${startoflib} -1 libname)
+ list(APPEND implicit_dirs_tmp ${path})
+ list(APPEND implicit_libs_tmp ${libname})
+ set(log "${log} dir [${path}]\n")
+ set(log "${log} lib [${libname}]\n")
else()
set(log "${log} ignore line: [${line}]\n")
endif()
@@ -137,6 +150,7 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj
list(APPEND implicit_libs "${lib}")
endif()
endforeach()
+ list(REMOVE_DUPLICATES implicit_libs)
# Cleanup list of library and framework directories.
set(desc_dirs "library")
diff --git a/Modules/Compiler/Clang.cmake b/Modules/Compiler/Clang.cmake
index 7d7be5c..58559b1 100644
--- a/Modules/Compiler/Clang.cmake
+++ b/Modules/Compiler/Clang.cmake
@@ -20,7 +20,9 @@ set(__COMPILER_CLANG 1)
if(CMAKE_C_SIMULATE_ID STREQUAL "MSVC"
OR CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
+ include(Compiler/MSVC)
macro(__compiler_clang lang)
+ __compiler_msvc(${lang})
endmacro()
else()
include(Compiler/GNU)
diff --git a/Modules/Compiler/MSVC-C.cmake b/Modules/Compiler/MSVC-C.cmake
new file mode 100644
index 0000000..ad9d6a3
--- /dev/null
+++ b/Modules/Compiler/MSVC-C.cmake
@@ -0,0 +1,2 @@
+include(Compiler/MSVC)
+__compiler_msvc(C)
diff --git a/Modules/Compiler/MSVC-CXX.cmake b/Modules/Compiler/MSVC-CXX.cmake
new file mode 100644
index 0000000..9122534
--- /dev/null
+++ b/Modules/Compiler/MSVC-CXX.cmake
@@ -0,0 +1,2 @@
+include(Compiler/MSVC)
+__compiler_msvc(CXX)
diff --git a/Modules/Compiler/Clang.cmake b/Modules/Compiler/MSVC.cmake
similarity index 57%
copy from Modules/Compiler/Clang.cmake
copy to Modules/Compiler/MSVC.cmake
index 7d7be5c..0a73826 100644
--- a/Modules/Compiler/Clang.cmake
+++ b/Modules/Compiler/MSVC.cmake
@@ -1,6 +1,6 @@
#=============================================================================
-# Copyright 2002-2012 Kitware, Inc.
+# Copyright 2002-2013 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
@@ -13,22 +13,12 @@
# License text for the above reference.)
# This module is shared by multiple languages; use include blocker.
-if(__COMPILER_CLANG)
+if(__COMPILER_MSVC)
return()
endif()
-set(__COMPILER_CLANG 1)
+set(__COMPILER_MSVC 1)
-if(CMAKE_C_SIMULATE_ID STREQUAL "MSVC"
- OR CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
- macro(__compiler_clang lang)
- endmacro()
-else()
- include(Compiler/GNU)
-
- macro(__compiler_clang lang)
- __compiler_gnu(${lang})
- set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE")
- set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ")
- set(CMAKE_${lang}_COMPILE_OPTIONS_VISIBILITY "-fvisibility=")
- endmacro()
-endif()
+macro(__compiler_msvc lang)
+ # Feature flags.
+ set(CMAKE_${lang}_VERBOSE_FLAG "/VERBOSE")
+endmacro()
diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake
index a2cfe33..da9f8b2 100644
--- a/Modules/Platform/Windows-MSVC.cmake
+++ b/Modules/Platform/Windows-MSVC.cmake
@@ -127,6 +127,9 @@ endif()
# default to Debug builds
set(CMAKE_BUILD_TYPE_INIT Debug)
+# Match known multiarch library directory names.
+set(CMAKE_LIBRARY_ARCHITECTURE_REGEX "(|amd64|arm|IA64)")
+
if(WINCE)
foreach(lang C CXX)
set(_MSVC_${lang}_ARCHITECTURE_FAMILY "${MSVC_${lang}_ARCHITECTURE_ID}")
--
1.7.1
|