I'm trying to link a Windows application against Crypto++. To do this I made the following simple CMakeLists.txt
, including the cryptlib.vcxproj
project via include_external_msproject
, specifying Win32 or x64 for PLATFORM
depending on build configuration.
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)
To generate the Win32 project I run cmake -G "Visual Studio 15 2017" ..
, followed by cmake --build . --config Release
and all is fine; Crypto++ is built for platform Win32 and the application is linked against it.
cryptlib.vcxproj -> C:\code\Test\cryptopp\Win32\Output\Release\cryptlib.lib
My problem is that when building for x64, cmake -G "Visual Studio 15 2017 Win64" ..
, followed by cmake --build . --config Release
the Crypto++ project is still built for Win32, naturally resulting in a failed build.
Opening and building the generated x64 project in VS2017 works - Crypto++ is built for x64 with an output file in
..\cryptopp\x64\Output\Release\cryptlib.lib
as expected.
I've tried this with the latest CMake, 3.12.1
Q: Have I misunderstood how include_external_msproject
functions? How do I make the Crypto++ project build for x64 when built outside of Visual Studio?
This ended up as a bug and is fixed in CMake 3.13.0