Warning, /frameworks/extra-cmake-modules/tests/ECMPoQmToolsTest/CMakeLists.txt is written in an unsupported language. File is not indexed.
0001 cmake_minimum_required(VERSION 3.5) 0002 project(ECMPoQmToolsTest) 0003 set(ECM_MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../modules") 0004 0005 set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../modules) 0006 0007 # make sure the test install dir is clean 0008 file(REMOVE_RECURSE "${CMAKE_INSTALL_PREFIX}") 0009 0010 include(ECMPoQmTools) 0011 0012 include(../test_helpers.cmake) 0013 0014 0015 ############################## 0016 # # 0017 # ecm_process_po_files_as_qm # 0018 # # 0019 ############################## 0020 0021 0022 # Should create a process-and-install.qm file and install it 0023 ecm_process_po_files_as_qm(fr ALL 0024 INSTALL_DESTINATION share/locale 0025 PO_FILES process-and-install.po 0026 ) 0027 0028 # Should create a only-process.qm file, without installing it 0029 ecm_process_po_files_as_qm(fr ALL 0030 PO_FILES only-process.po 0031 ) 0032 0033 0034 0035 ############################## 0036 # # 0037 # ecm_install_po_files_as_qm # 0038 # # 0039 ############################## 0040 0041 # Should create a bunch of .qm files and install them in share/locale. 0042 # Should ignore files directly under po/ as well as directories under po/ which 0043 # do not contain any .po files. 0044 ecm_install_po_files_as_qm(po) 0045 0046 0047 # Should create a bunch of .qm files and install them in 0048 # ${CMAKE_INSTALL_LOCALEDIR} 0049 set(CMAKE_INSTALL_LOCALEDIR custom-dir1) 0050 ecm_install_po_files_as_qm(po-custom-dir1) 0051 0052 0053 # Should create a bunch of .qm files and install them in 0054 # ${LOCALE_INSTALL_DIR} 0055 set(LOCALE_INSTALL_DIR custom-dir2) 0056 ecm_install_po_files_as_qm(po-custom-dir2) 0057 0058 unset(CMAKE_INSTALL_LOCALEDIR) 0059 unset(LOCALE_INSTALL_DIR) 0060 0061 0062 0063 ######################## 0064 # # 0065 # ecm_create_qm_loader # 0066 # # 0067 ######################## 0068 0069 find_package(Qt${QT_MAJOR_VERSION}Core CONFIG REQUIRED) 0070 ecm_install_po_files_as_qm(tr_test-po) 0071 0072 0073 # 0074 # single-threaded test, sources var arg 0075 # 0076 set(tr_test_SRCS 0077 tr_test.cpp 0078 ) 0079 ecm_create_qm_loader(tr_test_SRCS catalog) 0080 add_executable(tr_test ${tr_test_SRCS}) 0081 target_link_libraries(tr_test PRIVATE Qt${QT_MAJOR_VERSION}::Core) 0082 0083 0084 # 0085 # single-threaded test, target arg 0086 # 0087 add_executable(tr_test_target tr_test.cpp) 0088 ecm_create_qm_loader(tr_test_target catalog) 0089 target_link_libraries(tr_test_target PRIVATE Qt${QT_MAJOR_VERSION}::Core) 0090 0091 0092 # 0093 # single-threaded test (different catalog name, automoc) 0094 # 0095 # This is to check we don't overwrite previously-generated files. 0096 set(tr_test_2_SRCS 0097 tr_test.cpp 0098 ) 0099 ecm_create_qm_loader(tr_test_2_SRCS catalog2) 0100 add_executable(tr_test_2 ${tr_test_2_SRCS}) 0101 set_target_properties(tr_test_2 PROPERTIES AUTOMOC ON) 0102 target_include_directories(tr_test_2 PRIVATE "${CMAKE_CURRENT_BINARY_DIR}") 0103 target_link_libraries(tr_test_2 PRIVATE Qt${QT_MAJOR_VERSION}::Core) 0104 0105 0106 # 0107 # module for tr_thread_test 0108 # 0109 add_library(tr_thread_module MODULE tr_thread_test_module.cpp ${QMLOADER_FILES}) 0110 target_link_libraries(tr_thread_module PRIVATE Qt${QT_MAJOR_VERSION}::Core) 0111 0112 0113 # 0114 # loading a module on a thread other than the main thread 0115 # (automoc) 0116 # 0117 set(tr_thread_test_SRCS 0118 tr_thread_test.cpp 0119 ) 0120 ecm_create_qm_loader(tr_thread_test_SRCS catalog) 0121 add_executable(tr_thread_test ${tr_thread_test_SRCS}) 0122 set_target_properties(tr_thread_test PROPERTIES AUTOMOC ON) 0123 target_include_directories(tr_thread_test PRIVATE "${CMAKE_CURRENT_BINARY_DIR}") 0124 target_compile_definitions(tr_thread_test PRIVATE "MODULE_PATH=\"$<TARGET_FILE:tr_thread_module>\"") 0125 target_link_libraries(tr_thread_test PRIVATE Qt${QT_MAJOR_VERSION}::Core) 0126 0127 0128 # 0129 # loading a module on a thread other than the main thread 0130 # (different catalog, no AUTOMOC) 0131 # 0132 # make sure the moc file is only visible to this test/target 0133 set(MOC_DIR "${CMAKE_CURRENT_BINARY_DIR}/tr_thread_test_2_moc") 0134 qt_generate_moc(tr_thread_test.cpp "${MOC_DIR}/tr_thread_test.moc") 0135 # Unset SKIP_AUTOMOC again, to not interfer with AUTOMOC as set for tr_thread_test 0136 set_source_files_properties(tr_thread_test PROPERTIES SKIP_AUTOMOC OFF) 0137 0138 set(tr_thread_test_2_SRCS 0139 tr_thread_test.cpp 0140 "${MOC_DIR}/tr_thread_test.moc" 0141 ) 0142 ecm_create_qm_loader(tr_thread_test_2_SRCS catalog2) 0143 add_executable(tr_thread_test_2 ${tr_thread_test_2_SRCS}) 0144 set_target_properties(tr_thread_test_2 PROPERTIES AUTOMOC OFF) 0145 target_include_directories(tr_thread_test_2 PRIVATE "${CMAKE_CURRENT_BINARY_DIR}" "${MOC_DIR}") 0146 target_compile_definitions(tr_thread_test_2 PRIVATE "MODULE_PATH=\"$<TARGET_FILE:tr_thread_module>\"") 0147 target_link_libraries(tr_thread_test_2 PRIVATE Qt${QT_MAJOR_VERSION}::Core) 0148 0149 0150 # 0151 # call to ecm_create_qm_loader is in a different CMakeLists.txt to where 0152 # the target it is added to is defined 0153 # 0154 # This is not something we want people to do, but it's unfortunately something 0155 # projects have done and we need to keep them building. 0156 unset(QMLOADER_FILES) 0157 ecm_create_qm_loader(QMLOADER_FILES catalog) 0158 assert_var_defined(QMLOADER_FILES) 0159 add_subdirectory(subdir) 0160 0161 0162 0163 file(GENERATE 0164 OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/check_conf.cmake" 0165 INPUT "${CMAKE_CURRENT_SOURCE_DIR}/check_conf.cmake.in" 0166 ) 0167 configure_file(check.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/check.cmake" @ONLY)