Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 38 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@
cmake_minimum_required(VERSION 3.0.0)
project(quickflux VERSION 1.1.3)

option(quickflux_INSTALL "Enable the installation of targets." ON)
option(BUILD_SHARED_LIBS "Build using shared libraries" OFF)

set(SOVERSION_MAJOR 1)
set(SOVERSION_MINOR 1)
set(SOVERSION_PATCH 3)

option(quickflux_INSTALL "Enable the installation of targets." ON)
if(MSVC)
set_property (GLOBAL PROPERTY USE_FOLDERS ON)
endif()
Expand Down Expand Up @@ -88,7 +93,7 @@ if(MSVC)
source_group("Source Files\\MOC" REGULAR_EXPRESSION "moc*")
endif()

add_library(quickflux STATIC
add_library(quickflux
${quickflux_PRIVATE_SOURCES}
${quickflux_PRIVATE_HEADERS}
${quickflux_PUBLIC_SOURCES}
Expand All @@ -97,6 +102,21 @@ add_library(quickflux STATIC
)
add_library(QuickFlux::quickflux ALIAS quickflux)

if(BUILD_SHARED_LIBS)
set_target_properties(quickflux
PROPERTIES
VERSION ${SOVERSION_MAJOR}.${SOVERSION_MINOR}.${SOVERSION_PATCH}
SOVERSION ${SOVERSION_MAJOR}
)

# copy qmldir file to build dir so QML unit tests can use it to import the plugin
configure_file(
qmldir.in
qmldir
@ONLY
)
endif()

target_link_libraries(quickflux
PUBLIC
Qt5::Qml
Expand Down Expand Up @@ -168,4 +188,20 @@ if(quickflux_INSTALL)
DESTINATION ${CONFIG_PACKAGE_LOCATION}
)

if(BUILD_SHARED_LIBS)
# Qt5's cmake does not export QT_IMPORTS_DIR, lets query qmake on our own for now
get_target_property(QMAKE_EXECUTABLE Qt5::qmake LOCATION)
function(QUERY_QMAKE VAR RESULT)
exec_program(${QMAKE_EXECUTABLE} ARGS "-query ${VAR}" RETURN_VALUE return_code OUTPUT_VARIABLE output )
if(NOT return_code)
file(TO_CMAKE_PATH "${output}" output)
set(${RESULT} ${output} PARENT_SCOPE)
endif(NOT return_code)
endfunction(QUERY_QMAKE)
query_qmake(QT_INSTALL_QML QT_IMPORTS_DIR)

set(PLUGIN_DIR ${QT_IMPORTS_DIR}/QuickFlux)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qmldir DESTINATION ${PLUGIN_DIR})
endif()

endif()
2 changes: 2 additions & 0 deletions qmldir.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module QuickFlux
plugin quickflux @CMAKE_INSTALL_FULL_LIBDIR@