aboutsummaryrefslogtreecommitdiff
path: root/vcpkg/ports/qt5-base/cmake/find_qt_mkspec.cmake
blob: 161726c7fdf2d41abbf1c3ab0ada892306c09ab3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
function(find_qt_mkspec TARGET_PLATFORM_MKSPEC_OUT HOST_PLATFORM_MKSPEC_OUT EXT_HOST_TOOLS_OUT)
    ## Figure out QTs target mkspec
    if(NOT DEFINED VCPKG_QT_TARGET_MKSPEC)
        message(STATUS "Figuring out qt target mkspec. Target arch ${VCPKG_TARGET_ARCHITECTURE}") 
        if(VCPKG_TARGET_IS_WINDOWS)    
            if(VCPKG_TARGET_IS_MINGW)
                set(_tmp_targ_out "win32-g++")
            elseif(VCPKG_TARGET_IS_UWP)
                if(VCPKG_PLATFORM_TOOLSET STREQUAL "v140")
                    set(msvc_year "2015")
                elseif(VCPKG_PLATFORM_TOOLSET STREQUAL "v141")
                    set(msvc_year "2017")
                elseif(VCPKG_PLATFORM_TOOLSET STREQUAL "v142")
                    set(msvc_year "2019")
                else()
                    message(FATAL_ERROR "No target mkspec found!")
                endif()
                set(_tmp_targ_out "winrt-${VCPKG_TARGET_ARCHITECTURE}-msvc${msvc_year}")
            else()            
                if("${VCPKG_TARGET_ARCHITECTURE}" MATCHES "arm64")
                    message(STATUS "Figuring out arm64") 
                    set(_tmp_targ_out "win32-arm64-msvc2017") #mkspec does not have anything defined related to msvc2017 so this should work
                else()
                    set(_tmp_targ_out "win32-msvc")
                endif()
            endif()
        elseif(VCPKG_TARGET_IS_LINUX)
            set(_tmp_targ_out "linux-g++" )
        elseif(VCPKG_TARGET_IS_OSX)
            set(_tmp_targ_out "macx-clang") # switch to macx-g++ since vcpkg requires g++ to compile any way? 
        endif()
    else()
        set(_tmp_targ_out ${VCPKG_QT_TARGET_MKSPEC})
    endif()
    message(STATUS "Target mkspec set to: ${_tmp_targ_out}") 
    set(${TARGET_PLATFORM_MKSPEC_OUT} ${_tmp_targ_out} PARENT_SCOPE)
    
    ## Figure out QTs host mkspec
    if(NOT DEFINED VCPKG_QT_HOST_MKSPEC)
        #if(WIN32)
        #    set(_tmp_host_out "win32-msvc")
        #elseif("${CMAKE_HOST_SYSTEM}" STREQUAL "Linux")
        #    set(_tmp_host_out "linux-g++")
        #elseif("${CMAKE_HOST_SYSTEM}" STREQUAL "Darwin")
        #    set(_tmp_host_out "macx-clang")
        #endif()
        if(DEFINED _tmp_host_out)
            message(STATUS "Host mkspec set to: ${_tmp_host_out}") 
        else()
            message(STATUS "Host mkspec not set. Qt's own buildsystem will try to figure out the host system") 
        endif()
    else()
        set(_tmp_host_out ${VCPKG_QT_HOST_MKSPEC})
    endif()

    if(DEFINED _tmp_host_out)
        set(${HOST_PLATFORM_MKSPEC_OUT} ${_tmp_host_out} PARENT_SCOPE)
    endif()
    
    ## Figure out VCPKG qt-tools directory for the port. 
    if(NOT DEFINED VCPKG_QT_HOST_TOOLS_ROOT AND DEFINED VCPKG_QT_HOST_PLATFORM) ## Root dir of the required host tools 
        if(NOT "${_tmp_host_out}" MATCHES "${_tmp_host_out}")
            if(CMAKE_HOST_WIN32)
                
                if($ENV{PROCESSOR_ARCHITECTURE} MATCHES "[aA][rR][mM]64")
                    list(APPEND _test_triplets arm64-windows)
                elseif($ENV{PROCESSOR_ARCHITECTURE} MATCHES "[aA][mM][dD]64")
                    list(APPEND _test_triplets x64-windows x64-windows-static)
                    list(APPEND _test_triplets x86-windows x86-windows-static)
                elseif($ENV{PROCESSOR_ARCHITECTURE} MATCHES "x86")
                    list(APPEND _test_triplets x86-windows x86-windows-static)
                else()
                    message(FATAL_ERROR "Unknown host processor! Host Processor $ENV{PROCESSOR_ARCHITECTURE}")
                endif()
            elseif(CMAKE_HOST_SYSTEM STREQUAL "Linux")
                list(APPEND _test_triplets "x64-linux")
            elseif(CMAKE_HOST_SYSTEM STREQUAL "Darwin")
                list(APPEND _test_triplets "x64-osx")
            else()
            endif()
            foreach(_triplet ${_test_triplets})
                find_program(QMAKE_PATH qmake PATHS  ${VCPKG_INSTALLED_DIR}/${_triplet}/tools/qt5/bin NO_DEFAULT_PATHS)
                message(STATUS "Checking: ${VCPKG_INSTALLED_DIR}/${_triplet}/tools/qt5/bin. ${QMAKE_PATH}")
                if(QMAKE_PATH)
                    set(_tmp_host_root "${VCPKG_INSTALLED_DIR}/${_triplet}/tools/qt5")
                    set(_tmp_host_qmake ${QMAKE_PATH} PARENT_SCOPE)
                    message(STATUS "Qt host tools root dir within vcpkg: ${_tmp_host_root}")
                    break()
                endif()     
            endforeach()
            if(NOT DEFINED _tmp_host_root)
                message(FATAL_ERROR "Unable to locate required host tools. Please define VCPKG_QT_HOST_TOOLS_ROOT to the required root dir of the host tools") 
            endif()       
        endif()
    else()
        set(_tmp_host_root ${VCPKG_QT_HOST_TOOLS_ROOT})
    endif()
    
    if(DEFINED _tmp_host_root)
        set(${EXT_HOST_TOOLS_OUT} ${_tmp_host_root} PARENT_SCOPE)
    endif()

endfunction()