为什么 CMake / include_external_msproject 不传播平台参数?

Why doesn't CMake / include_external_msproject propagate platform argument?

我正在尝试 link 针对 Crypto++. To do this I made the following simple CMakeLists.txt, including the cryptlib.vcxproj project via include_external_msproject 的 Windows 应用程序,根据构建配置为 PLATFORM 指定 Win32 或 x64。

cmake_minimum_required( VERSION 3.8)

project(test)

set(CMAKE_CXX_STANDARD 14)

set(SOURCE_FILES main.cpp)

add_executable(${PROJECT_NAME} ${SOURCE_FILES})

if( ${CMAKE_SIZEOF_VOID_P} MATCHES "8" )
    set(CRYPTOPP_PLATFORM x64)
    message(STATUS "Platform: ${CRYPTOPP_PLATFORM}")
else()
    set(CRYPTOPP_PLATFORM Win32)
endif()

if( ${CMAKE_BUILD_TYPE} MATCHES "Debug" )
    set(CRYPTOPP_MODE Debug)
else()
    set(CRYPTOPP_MODE Release)
endif()

include_external_msproject(cryptopp ${CMAKE_CURRENT_LIST_DIR}/cryptopp/cryptlib.vcxproj PLATFORM ${CRYPTOPP_PLATFORM})

add_dependencies(${PROJECT_NAME} cryptopp)
target_link_libraries(${PROJECT_NAME} ${CMAKE_CURRENT_LIST_DIR}/cryptopp/${CRYPTOPP_PLATFORM}/Output/${CRYPTOPP_MODE}/cryptlib.lib)

生成Win32项目我运行cmake -G "Visual Studio 15 2017" ..,接着cmake --build . --config Release就可以了; Crypto++ 是为平台 Win32 构建的,应用程序是 link 反对它的。

cryptlib.vcxproj -> C:\code\Test\cryptopp\Win32\Output\Release\cryptlib.lib

我的问题是,在为 x64 构建时,cmake -G "Visual Studio 15 2017 Win64" ..,随后 cmake --build . --config Release Crypto++ 项目仍然为 Win32 构建,自然会导致构建失败。

在 VS2017 中打开并构建生成的 x64 项目有效 - Crypto++ 是为 x64 构建的,输出文件在 ..\cryptopp\x64\Output\Release\cryptlib.lib 符合预期。

我用最新的 CMake 3.12.1 试过了

问: 我是否误解了 include_external_msproject 的功能?在 Visual Studio 之外构建时,如何为 x64 构建 Crypto++ 项目?

这最终成为 bug and is fixed in CMake 3.13.0