diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2019-04-03 13:15:03 +0200 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2019-04-29 11:20:06 +0000 |
commit | d34e70d73cb16a60c0bc359e88ab69884dae327d (patch) | |
tree | 27e346bea95f4cc2306b27598df1f0e9e2e75db6 | |
parent | 6d10eaedc8f3a7b737cd32d6093ef0fa9833f60b (diff) |
Fix CMakeLists.txt for linking against a static Qt
Change-Id: Ibc906e993046f57447caab8f006f8eb7e669a25d
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
-rw-r--r-- | src/jomlib/CMakeLists.txt | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/jomlib/CMakeLists.txt b/src/jomlib/CMakeLists.txt index e1adcd4..6ca1fab 100644 --- a/src/jomlib/CMakeLists.txt +++ b/src/jomlib/CMakeLists.txt @@ -45,6 +45,27 @@ add_library(jomlib STATIC target_include_directories(jomlib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_link_libraries(jomlib PUBLIC Qt5::Core) + +# If we're building against a static Qt on Windows, +# we must link manually against all private libraries. +# This should not be necessary. See QTBUG-38913. +get_target_property(qt_core_type Qt5::Core TYPE) +if(qt_core_type MATCHES STATIC_LIBRARY) + target_link_libraries(jomlib PRIVATE mincore userenv winmm ws2_32) + + if(CMAKE_BUILD_TYPE MATCHES Debug) + set(debug_suffix d) + set(qt_build_config DEBUG) + else() + set(debug_suffix "") + set(qt_build_config RELEASE) + endif() + + get_target_property(qt_core_lib_location Qt5::Core IMPORTED_LOCATION_${qt_build_config}) + get_filename_component(qt_core_lib_dir ${qt_core_lib_location} DIRECTORY) + target_link_libraries(jomlib PRIVATE "${qt_core_lib_dir}/qtpcre2${debug_suffix}.lib") +endif() + target_compile_definitions(jomlib PRIVATE QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII |