Also ... I dont really understand how cmake can find the x86 version of Qt. How does it even know it exists?
The magic is in the find_package() scripts. Inside the cmake installation you will find other scripts that this one calls on to locate the Qt installation (like FindQt5.cmake, etc.).
Check out the documentation for find_package(). You may have to specifiy the CMAKE_LIBRARY_ARCHITECTURE value or set the FIND_LIBRARY_USE_LIB64_PATHS variable to true. These are used internally in the find_package() scripts to locate the correct versions of libraries.
If you use a CMake generator to create your makefile / project file, you can pass a "TARGET_ARCH" variable on the command line. For example, something from one of my batch files that builds 4 different configurations (32bit and 64bit x debug and release) for two different MSVC versions (2013 and 2015):
# corresponds to %%G below
set generator=VS2015
set thisgenerator="Visual Studio 14 2015 Win64"
# corresponds to %%M below
set build = Release
set machine=amd64
# passed in as assignment to TARGET_ARCH
set arch=x64
cmake -G!thisgenerator! -DCMAKE_TOOLCHAIN_FILE=windows_toolchain.cmake -DBUILD_TYPE=%%M -DVSGEN_TYPE=%%G -DTARGET_ARCH=!arch! ..\
# corresponds to %%G below
set generator=VS2015
set thisgenerator="Visual Studio 14 2015 Win64"
# corresponds to %%M below
set build = Release
set machine=amd64
# passed in as assignment to TARGET_ARCH
set arch=x64
cmake -G!thisgenerator! -DCMAKE_TOOLCHAIN_FILE=windows_toolchain.cmake -DBUILD_TYPE=%%M -DVSGEN_TYPE=%%G -DTARGET_ARCH=!arch! ..\
To copy to clipboard, switch view to plain text mode
The toolchain file just sets up a bunch of CMake variables used by all of the Windows builds:
# target operating system
set (CMAKE_SYSTEM_NAME Windows)
set (WINDOWS true)
set (CMAKE_BUILD_TYPE ${BUILD_TYPE} CACHE STRING "Choose the type of build" FORCE)
set (CMAKE_GEN_TYPE ${VSGEN_TYPE} CACHE STRING "Visual Studio generator type" FORCE)
set (CMAKE_CXX_FLAGS "/Gs- /Gd /Zc:wchar_t /D WIN32 /EHsc /D UNICODE /D _UNICODE /D _WINDLL /D XERCES_STATIC_LIBRARY /D _USRDLL")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "c++ flags" )
# target operating system
set (CMAKE_SYSTEM_NAME Windows)
set (WINDOWS true)
set (CMAKE_BUILD_TYPE ${BUILD_TYPE} CACHE STRING "Choose the type of build" FORCE)
set (CMAKE_GEN_TYPE ${VSGEN_TYPE} CACHE STRING "Visual Studio generator type" FORCE)
set (CMAKE_CXX_FLAGS "/Gs- /Gd /Zc:wchar_t /D WIN32 /EHsc /D UNICODE /D _UNICODE /D _WINDLL /D XERCES_STATIC_LIBRARY /D _USRDLL")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "c++ flags" )
To copy to clipboard, switch view to plain text mode
Hope this is of some use. CMake is an extremely powerful build system, but the online documentation can be impenetrable. There is a pretty good book from Kitware (who wrote CMake) called "Mastering CMake" which I found to be very helpful in creating my build scripts.
Bookmarks