Browse Source

cmake: add imported target for QtSingleApplication

This simplifies cmake code a bit: we remove if's and just generate
different target (imported or alias) with the same name and use it
unconditionally.
adaptive-webui-19844
Eugene Shalygin 9 years ago
parent
commit
7c0b5818b1
  1. 12
      cmake/Modules/FindQtSingleApplication.cmake
  2. 3
      src/CMakeLists.txt
  3. 9
      src/app/CMakeLists.txt
  4. 4
      src/app/qtsingleapplication/CMakeLists.txt
  5. 5
      src/gui/CMakeLists.txt

12
cmake/Modules/FindQtSingleApplication.cmake

@ -79,3 +79,15 @@ ELSE (QTSINGLEAPPLICATION_FOUND) @@ -79,3 +79,15 @@ ELSE (QTSINGLEAPPLICATION_FOUND)
ENDIF (QTSINGLEAPPLICATION_FOUND)
MARK_AS_ADVANCED(QTSINGLEAPPLICATION_INCLUDE_DIR QTSINGLEAPPLICATION_LIBRARY)
if(NOT TARGET QtSingleApplication::QtSingleApplication)
add_library(QtSingleApplication::QtSingleApplication UNKNOWN IMPORTED)
set_target_properties(QtSingleApplication::QtSingleApplication PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${QTSINGLEAPPLICATION_INCLUDE_DIR}"
)
if(EXISTS "${QTSINGLEAPPLICATION_LIBRARY}")
set_target_properties(QtSingleApplication::QtSingleApplication PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
IMPORTED_LOCATION "${QTSINGLEAPPLICATION_LIBRARY}")
endif()
endif(NOT TARGET QtSingleApplication::QtSingleApplication)

3
src/CMakeLists.txt

@ -98,9 +98,8 @@ endif (GUI) @@ -98,9 +98,8 @@ endif (GUI)
if (SYSTEM_QTSINGLEAPPLICATION)
find_package(QtSingleApplication REQUIRED)
include_directories(${QTSINGLEAPPLICATION_INCLUDE_DIR})
else (SYSTEM_QTSINGLEAPPLICATION)
include_directories(app/qtsingleapplication)
add_subdirectory(app/qtsingleapplication)
endif (SYSTEM_QTSINGLEAPPLICATION)
add_subdirectory(app)

9
src/app/CMakeLists.txt

@ -158,14 +158,7 @@ if (GUI AND WIN32) @@ -158,14 +158,7 @@ if (GUI AND WIN32)
set_target_properties(${QBT_TARGET_NAME} PROPERTIES WIN32_EXECUTABLE True)
endif (GUI AND WIN32)
target_link_libraries(${QBT_TARGET_NAME} ${QBT_TARGET_LIBRARIES})
if (SYSTEM_QTSINGLEAPPLICATION)
target_link_libraries(${QBT_TARGET_NAME} ${QTSINGLEAPPLICATION_LIBRARIES})
else (SYSTEM_QTSINGLEAPPLICATION)
add_subdirectory(qtsingleapplication)
target_link_libraries(${QBT_TARGET_NAME} qtsingleapplication)
endif (SYSTEM_QTSINGLEAPPLICATION)
target_link_libraries(${QBT_TARGET_NAME} ${QBT_TARGET_LIBRARIES} QtSingleApplication::QtSingleApplication)
if (APPLE)
set(qbt_BUNDLE_NAME "${CMAKE_PROJECT_NAME}")

4
src/app/qtsingleapplication/CMakeLists.txt

@ -1,3 +1,5 @@ @@ -1,3 +1,5 @@
project(qtsingleapplication)
set(QBT_QTSINGLEAPPLICATION_HEADERS
qtlocalpeer.h
)
@ -15,6 +17,7 @@ else (GUI) @@ -15,6 +17,7 @@ else (GUI)
endif (GUI)
add_library(qtsingleapplication ${QBT_QTSINGLEAPPLICATION_HEADERS} ${QBT_QTSINGLEAPPLICATION_SOURCES})
target_include_directories(qtsingleapplication INTERFACE "${qtsingleapplication_SOURCE_DIR}")
if (QT4_FOUND)
target_link_libraries(qtsingleapplication Qt4::QtNetwork)
@ -30,3 +33,4 @@ if (GUI) @@ -30,3 +33,4 @@ if (GUI)
endif(QT4_FOUND)
endif (GUI)
add_library(QtSingleApplication::QtSingleApplication ALIAS qtsingleapplication)

5
src/gui/CMakeLists.txt

@ -131,4 +131,7 @@ torrentcreatordlg.ui @@ -131,4 +131,7 @@ torrentcreatordlg.ui
qbt_target_sources(about.qrc)
add_library(qbt_gui STATIC ${QBT_GUI_HEADERS} ${QBT_GUI_SOURCES})
target_link_libraries(qbt_gui qbt_lineedit qbt_powermanagement qbt_rss qbt_properties qbt_searchengine ${QBT_GUI_OPTIONAL_LINK_LIBRARIES} qbt_base)
target_link_libraries(qbt_gui qbt_lineedit qbt_powermanagement qbt_rss qbt_properties qbt_searchengine
${QBT_GUI_OPTIONAL_LINK_LIBRARIES} qbt_base
QtSingleApplication::QtSingleApplication
)

Loading…
Cancel
Save