2018-10-24 13:20:27 +00:00
|
|
|
include(CheckCXXSourceCompiles)
|
2019-04-08 15:23:57 +00:00
|
|
|
|
2019-11-13 13:03:20 +00:00
|
|
|
function(qt_run_config_test_architecture)
|
2019-11-07 14:52:33 +00:00
|
|
|
set(QT_BASE_CONFIGURE_TESTS_VARS_TO_EXPORT
|
|
|
|
"" CACHE INTERNAL "Test variables that should be exported" FORCE)
|
2019-08-28 13:01:23 +00:00
|
|
|
|
2019-04-08 15:23:57 +00:00
|
|
|
# Compile test to find the target architecture and sub-architectures.
|
|
|
|
set(flags "")
|
|
|
|
qt_get_platform_try_compile_vars(platform_try_compile_vars)
|
|
|
|
list(APPEND flags ${platform_try_compile_vars})
|
2019-08-28 13:01:23 +00:00
|
|
|
|
2019-04-08 15:23:57 +00:00
|
|
|
try_compile(
|
|
|
|
_arch_result
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/config.tests/arch"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/config.tests/arch"
|
|
|
|
arch
|
|
|
|
CMAKE_FLAGS ${flags}
|
|
|
|
)
|
2019-08-28 13:01:23 +00:00
|
|
|
|
2018-10-24 13:20:27 +00:00
|
|
|
if (NOT _arch_result)
|
|
|
|
message(FATAL_ERROR "Failed to compile architecture detection file.")
|
|
|
|
endif()
|
|
|
|
|
2019-04-08 15:23:57 +00:00
|
|
|
set(_arch_file_suffix "${CMAKE_EXECUTABLE_SUFFIX}")
|
|
|
|
# With emscripten the application entry point is a .js file (to be run with node for example),
|
|
|
|
# but the real "data" is in the .wasm file, so that's where we need to look for the ABI, etc.
|
|
|
|
# information.
|
|
|
|
if (EMSCRIPTEN)
|
|
|
|
set(_arch_file_suffix ".wasm")
|
|
|
|
endif()
|
2019-12-06 14:12:17 +00:00
|
|
|
|
|
|
|
set(arch_test_location "config.tests/arch")
|
|
|
|
if(QT_MULTI_CONFIG_FIRST_CONFIG)
|
|
|
|
string(APPEND arch_test_location "/${QT_MULTI_CONFIG_FIRST_CONFIG}")
|
|
|
|
endif()
|
|
|
|
|
2019-04-08 15:23:57 +00:00
|
|
|
set(_arch_file
|
2019-12-06 14:12:17 +00:00
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/${arch_test_location}/architecture_test${_arch_file_suffix}")
|
2019-04-08 15:23:57 +00:00
|
|
|
if (NOT EXISTS "${_arch_file}")
|
|
|
|
message(FATAL_ERROR
|
|
|
|
"Failed to find compiled architecture detection executable at ${_arch_file}.")
|
|
|
|
endif()
|
|
|
|
message(STATUS "Extracting architecture info from ${_arch_file}.")
|
|
|
|
|
2018-10-24 13:20:27 +00:00
|
|
|
file(STRINGS "${_arch_file}" _arch_lines LENGTH_MINIMUM 16 LENGTH_MAXIMUM 1024 ENCODING UTF-8)
|
|
|
|
|
|
|
|
foreach (_line ${_arch_lines})
|
2019-06-26 12:08:02 +00:00
|
|
|
string(LENGTH "${_line}" lineLength)
|
2018-10-24 13:20:27 +00:00
|
|
|
string(FIND "${_line}" "==Qt=magic=Qt== Architecture:" _pos)
|
|
|
|
if (_pos GREATER -1)
|
|
|
|
math(EXPR _pos "${_pos}+29")
|
|
|
|
string(SUBSTRING "${_line}" ${_pos} -1 _architecture)
|
|
|
|
endif()
|
|
|
|
string(FIND "${_line}" "==Qt=magic=Qt== Sub-architecture:" _pos)
|
2019-05-29 08:09:52 +00:00
|
|
|
if (_pos GREATER -1 AND ${lineLength} GREATER 33)
|
2018-10-24 13:20:27 +00:00
|
|
|
math(EXPR _pos "${_pos}+34")
|
|
|
|
string(SUBSTRING "${_line}" ${_pos} -1 _sub_architecture)
|
|
|
|
string(REPLACE " " ";" _sub_architecture "${_sub_architecture}")
|
|
|
|
endif()
|
|
|
|
string(FIND "${_line}" "==Qt=magic=Qt== Build-ABI:" _pos)
|
|
|
|
if (_pos GREATER -1)
|
|
|
|
math(EXPR _pos "${_pos}+26")
|
|
|
|
string(SUBSTRING "${_line}" ${_pos} -1 _build_abi)
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
2019-05-29 08:09:52 +00:00
|
|
|
if (NOT _architecture OR NOT _build_abi)
|
2018-10-24 13:20:27 +00:00
|
|
|
message(FATAL_ERROR "Failed to extract architecture data from file.")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(TEST_architecture 1 CACHE INTERNAL "Ran the architecture test")
|
|
|
|
set(TEST_architecture_arch "${_architecture}" CACHE INTERNAL "Target machine architecture")
|
2019-11-07 14:52:33 +00:00
|
|
|
list(APPEND QT_BASE_CONFIGURE_TESTS_VARS_TO_EXPORT TEST_architecture_arch)
|
2018-10-24 13:20:27 +00:00
|
|
|
set(TEST_subarch 1 CACHE INTERNAL "Ran machine subArchitecture test")
|
|
|
|
foreach(it ${_sub_architecture})
|
2019-03-21 12:14:09 +00:00
|
|
|
# Equivalent to qmake's QT_CPU_FEATURES.$arch.
|
|
|
|
set(TEST_arch_${TEST_architecture_arch}_subarch_${it} 1 CACHE INTERNAL "Target sub architecture result")
|
2019-11-07 14:52:33 +00:00
|
|
|
list(APPEND QT_BASE_CONFIGURE_TESTS_VARS_TO_EXPORT TEST_arch_${TEST_architecture_arch}_subarch_${it})
|
2018-10-24 13:20:27 +00:00
|
|
|
endforeach()
|
|
|
|
set(TEST_buildAbi "${_build_abi}" CACHE INTERNAL "Target machine buildAbi")
|
2019-11-07 14:52:33 +00:00
|
|
|
list(APPEND QT_BASE_CONFIGURE_TESTS_VARS_TO_EXPORT TEST_buildAbi)
|
|
|
|
set(QT_BASE_CONFIGURE_TESTS_VARS_TO_EXPORT ${QT_BASE_CONFIGURE_TESTS_VARS_TO_EXPORT} CACHE INTERNAL "Test variables that should be exported")
|
2019-04-08 15:23:57 +00:00
|
|
|
|
|
|
|
list(JOIN _sub_architecture " " subarch_summary)
|
|
|
|
message(STATUS "Building for: ${QT_QMAKE_TARGET_MKSPEC} (${TEST_architecture_arch}, CPU features: ${subarch_summary})")
|
2018-10-24 13:20:27 +00:00
|
|
|
endfunction()
|
|
|
|
|
|
|
|
|
2019-11-13 13:03:20 +00:00
|
|
|
function(qt_run_config_test_posix_iconv)
|
2018-10-24 13:20:27 +00:00
|
|
|
set(source "#include <iconv.h>
|
|
|
|
|
|
|
|
int main(int, char **)
|
|
|
|
{
|
|
|
|
iconv_t x = iconv_open(\"\", \"\");
|
|
|
|
|
|
|
|
char *inp;
|
|
|
|
char *outp;
|
|
|
|
size_t inbytes, outbytes;
|
|
|
|
iconv(x, &inp, &inbytes, &outp, &outbytes);
|
|
|
|
|
|
|
|
iconv_close(x);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}")
|
|
|
|
check_cxx_source_compiles("${source}" HAVE_POSIX_ICONV)
|
|
|
|
|
|
|
|
if(NOT HAVE_POSIX_ICONV)
|
|
|
|
set(_req_libraries "${CMAKE_REQUIRE_LIBRARIES}")
|
|
|
|
set(CMAKE_REQUIRE_LIBRARIES "iconv")
|
|
|
|
check_cxx_source_compiles("${source}" HAVE_POSIX_ICONV)
|
|
|
|
set(CMAKE_REQUIRE_LIBRARIES "${_req_libraries}")
|
|
|
|
if(HAVE_POSIX_ICONV)
|
|
|
|
set(TEST_iconv_needlib 1 CACHE INTERNAL "Need to link against libiconv")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(TEST_posix_iconv "${HAVE_POSIX_ICONV}" CACHE INTERNAL "POSIX iconv")
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
|
2019-11-13 13:03:20 +00:00
|
|
|
function(qt_run_config_test_sun_iconv)
|
2018-10-24 13:20:27 +00:00
|
|
|
set(source "#include <iconv.h>
|
|
|
|
|
|
|
|
int main(int, char **)
|
|
|
|
{
|
|
|
|
iconv_t x = iconv_open(\"\", \"\");
|
|
|
|
|
|
|
|
const char *inp;
|
|
|
|
char *outp;
|
|
|
|
size_t inbytes, outbytes;
|
|
|
|
iconv(x, &inp, &inbytes, &outp, &outbytes);
|
|
|
|
|
|
|
|
iconv_close(x);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}")
|
|
|
|
if(DARWIN)
|
|
|
|
# as per !config.darwin in configure.json
|
|
|
|
set(HAVE_SUN_ICONV OFF)
|
|
|
|
else()
|
|
|
|
check_cxx_source_compiles("${source}" HAVE_SUN_ICONV)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(TEST_sun_iconv "${HAVE_SUN_ICONV}" CACHE INTERNAL "SUN libiconv")
|
|
|
|
endfunction()
|
|
|
|
|
2019-11-13 13:03:20 +00:00
|
|
|
function(qt_run_linker_version_script_support)
|
2018-10-24 13:20:27 +00:00
|
|
|
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/version_flag.map" "VERS_1 { global: sym; };
|
|
|
|
VERS_2 { global: sym; }
|
|
|
|
VERS_1;
|
|
|
|
")
|
|
|
|
if(DEFINED CMAKE_REQUIRED_FLAGS)
|
|
|
|
set(CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS})
|
|
|
|
else()
|
|
|
|
set(CMAKE_REQUIRED_FLAGS "")
|
|
|
|
endif()
|
|
|
|
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} "-Wl,--version-script=\"${CMAKE_CURRENT_BINARY_DIR}/version_flag.map\"")
|
|
|
|
check_cxx_source_compiles("int main(void){return 0;}" HAVE_LD_VERSION_SCRIPT)
|
|
|
|
if(DEFINED CMAKE_REQUIRED_FLAGS_SAVE)
|
|
|
|
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE})
|
|
|
|
endif()
|
|
|
|
file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map")
|
|
|
|
|
2019-04-08 15:10:23 +00:00
|
|
|
# For some reason the linker command line written by the XCode generator, which is
|
|
|
|
# subsequently executed by xcodebuild, ignores the linker flag, and thus the test
|
|
|
|
# seemingly succeeds. Explicitly disable the version script test on darwin platforms.
|
|
|
|
if(APPLE)
|
|
|
|
set(HAVE_LD_VERSION_SCRIPT OFF)
|
|
|
|
endif()
|
|
|
|
|
2018-10-24 13:20:27 +00:00
|
|
|
set(TEST_ld_version_script "${HAVE_LD_VERSION_SCRIPT}" CACHE INTERNAL "linker version script support")
|
|
|
|
endfunction()
|
|
|
|
|
2019-11-13 13:03:20 +00:00
|
|
|
function(qt_run_qtbase_config_tests)
|
|
|
|
qt_run_config_test_posix_iconv()
|
2018-10-24 13:20:27 +00:00
|
|
|
|
|
|
|
add_library(Iconv INTERFACE)
|
|
|
|
if(TEST_iconv_needlib)
|
|
|
|
target_link_libraries(Iconv PUBLIC iconv)
|
|
|
|
endif()
|
|
|
|
|
2018-11-06 13:20:19 +00:00
|
|
|
if(NOT TEST_posix_iconv)
|
2019-11-13 13:03:20 +00:00
|
|
|
qt_run_config_test_sun_iconv()
|
2018-11-06 13:20:19 +00:00
|
|
|
endif()
|
2019-11-13 13:03:20 +00:00
|
|
|
qt_run_config_test_architecture()
|
|
|
|
qt_run_linker_version_script_support()
|
2018-10-24 13:20:27 +00:00
|
|
|
endfunction()
|
|
|
|
|
2019-11-07 14:03:33 +00:00
|
|
|
# The qmake build of android does not perform the right architecture tests and
|
|
|
|
# forcefully disables sse4 on android x86. We have to mimic this behavior
|
|
|
|
# for now
|
|
|
|
if (CMAKE_ANDROID_ARCH_ABI STREQUAL x86)
|
|
|
|
set(QT_FEATURE_sse4_1 OFF CACHE BOOL INTERNAL FORCE)
|
|
|
|
set(QT_FEATURE_sse4_2 OFF CACHE BOOL INTERNAL FORCE)
|
|
|
|
set(TEST_subarch_sse4_1 FALSE CACHE BOOL INTERNAL FORCE)
|
|
|
|
set(TEST_subarch_sse4_2 FALSE CACHE BOOL INTERNAL FORCE)
|
|
|
|
endif()
|
2019-11-13 13:03:20 +00:00
|
|
|
qt_run_qtbase_config_tests()
|