diff options
author | Slávek Banko <slavek.banko@axis.cz> | 2022-01-03 17:55:46 +0100 |
---|---|---|
committer | Slávek Banko <slavek.banko@axis.cz> | 2022-01-04 04:06:38 +0100 |
commit | 2971f209dbecd56266de42030d226b9085c6bf63 (patch) | |
tree | dadecfc99544e994f11c55a70e9957ae67d0e788 | |
parent | 27ea6ede3cc480e4680fcc56b29df6ea824f7877 (diff) | |
download | polkit-tqt-2971f209dbecd56266de42030d226b9085c6bf63.tar.gz polkit-tqt-2971f209dbecd56266de42030d226b9085c6bf63.zip |
CMake rules adjustments:
+ Use the usual TDESetupPaths macros.
+ Install libraries according to multi-arch rules.
+ Use `install( DIRECTORY ... )` for headers in CXX style.
+ Remove linking unused variables ${..._MOCS}.
+ Remove linking for indirectly used libraries.
+ Use private linking for exported CMake targets.
+ Add the installation of exported CMake targets.
+ Use keyword TEST for tde_add_check_executable.
Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
-rw-r--r-- | CMakeLists.txt | 55 | ||||
-rw-r--r-- | agent/CMakeLists.txt | 7 | ||||
-rw-r--r-- | core/CMakeLists.txt | 7 | ||||
-rw-r--r-- | examples/CMakeLists.txt | 5 | ||||
-rw-r--r-- | examples/agent/CMakeLists.txt | 4 | ||||
-rw-r--r-- | gui/CMakeLists.txt | 7 | ||||
-rw-r--r-- | tests/CMakeLists.txt | 6 |
7 files changed, 32 insertions, 59 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 6525cf505..6e9bd716a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,10 +26,21 @@ cmake_minimum_required( VERSION 3.1 ) include( FindPkgConfig ) include( CheckCXXSourceCompiles ) include( CheckSymbolExists ) +include( GNUInstallDirs OPTIONAL ) include( TDEMacros ) enable_testing( ) +##### setup install paths ####################### + +if( CMAKE_INSTALL_LIBDIR ) + tde_setup_install_path( LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" ) +endif( ) + +include( TDESetupPaths ) +tde_setup_paths( ) + + ##### optional stuff option( WITH_ALL_OPTIONS "Enable all optional support" OFF ) @@ -48,21 +59,10 @@ option( BUILD_TESTS "Builds unit tests" ${BUILD_ALL} ) include( ConfigureChecks.cmake ) -##### install paths setup ####################### - -tde_setup_install_path( EXEC_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" ) -tde_setup_install_path( BIN_INSTALL_DIR "${EXEC_INSTALL_PREFIX}/bin" ) -tde_setup_install_path( LIB_INSTALL_DIR "${EXEC_INSTALL_PREFIX}/lib${LIB_SUFFIX}" ) -tde_setup_install_path( INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include/${CMAKE_PROJECT_NAME}" ) -tde_setup_install_path( PKGCONFIG_INSTALL_DIR "${LIB_INSTALL_DIR}/pkgconfig" ) -tde_setup_install_path( SHARE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/share" ) -tde_setup_install_path( DATA_INSTALL_DIR "${SHARE_INSTALL_PREFIX}/apps" ) - - ##### write pkgconfig file ###################### string( REGEX REPLACE "^${CMAKE_INSTALL_PREFIX}" "\${prefix}" PC_EXEC_PREFIX ${EXEC_INSTALL_PREFIX} ) -string( REGEX REPLACE "^${CMAKE_INSTALL_PREFIX}" "\${prefix}" PC_INCLUDE_DIR ${INCLUDE_INSTALL_DIR} ) +string( REGEX REPLACE "^${CMAKE_INSTALL_PREFIX}" "\${prefix}" PC_INCLUDE_DIR ${INCLUDE_INSTALL_DIR}/${CMAKE_PROJECT_NAME} ) string( REGEX REPLACE "^${CMAKE_INSTALL_PREFIX}" "\${prefix}" PC_LIB_DIR ${LIB_INSTALL_DIR} ) configure_file( polkit-tqt.pc.cmake polkit-tqt.pc @ONLY ) @@ -99,36 +99,13 @@ tde_conditional_add_subdirectory( BUILD_TESTS tests ) ##### install files #### ######################## install( - FILES - includes/PolkitTQt/Authority - includes/PolkitTQt/Details - includes/PolkitTQt/Identity - includes/PolkitTQt/Subject - includes/PolkitTQt/TemporaryAuthorization - includes/PolkitTQt/ActionDescription - DESTINATION - ${INCLUDE_INSTALL_DIR}/PolkitTQt -) - -install( - FILES - includes/PolkitTQt/Gui/Action - includes/PolkitTQt/Gui/ActionButton - includes/PolkitTQt/Gui/ActionButtons - DESTINATION - ${INCLUDE_INSTALL_DIR}/PolkitTQt/Gui -) - -install( - FILES - includes/PolkitTQt/Agent/Listener - includes/PolkitTQt/Agent/Session - DESTINATION - ${INCLUDE_INSTALL_DIR}/PolkitTQt/Agent + DIRECTORY includes/ + DESTINATION ${INCLUDE_INSTALL_DIR}/${CMAKE_PROJECT_NAME} ) install( FILES polkit-tqt-export.h - DESTINATION ${INCLUDE_INSTALL_DIR} + DESTINATION ${INCLUDE_INSTALL_DIR}/${CMAKE_PROJECT_NAME} ) +tde_install_export( ) diff --git a/agent/CMakeLists.txt b/agent/CMakeLists.txt index 6f2b74948..ea50d6b51 100644 --- a/agent/CMakeLists.txt +++ b/agent/CMakeLists.txt @@ -30,20 +30,21 @@ install( FILES polkit-tqt-agent-session.h polkit-tqt-agent-listener.h - DESTINATION ${INCLUDE_INSTALL_DIR} + DESTINATION ${INCLUDE_INSTALL_DIR}/${CMAKE_PROJECT_NAME} ) ##### polkit-tqt-agent (shared) ######################### tde_add_library( polkit-tqt-agent SHARED AUTOMOC - SOURCES ${polkit_tqt_agent_MOCS} + SOURCES polkit-tqt-agent-session.cpp polkit-tqt-agent-listener.cpp listeneradapter.cpp polkit-tqt-listener.cpp VERSION 0.0.0 CXX_FEATURES cxx_nullptr - LINK ${TQT_LIBRARIES} ${POLKIT_GOBJECT_LIBRARIES} ${POLKIT_AGENT_LIBRARIES} polkit-tqt-core-shared + LINK polkit-tqt-core-shared + LINK_PRIVATE ${POLKIT_GOBJECT_LIBRARIES} ${POLKIT_AGENT_LIBRARIES} DESTINATION ${LIB_INSTALL_DIR} ) diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 0d0e22859..5f20a6130 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -32,14 +32,14 @@ install( polkit-tqt-identity.h polkit-tqt-subject.h polkit-tqt-temporaryauthorization.h - DESTINATION ${INCLUDE_INSTALL_DIR} + DESTINATION ${INCLUDE_INSTALL_DIR}/${CMAKE_PROJECT_NAME} ) ##### polkit-tqt-core (shared) ######################### tde_add_library( polkit-tqt-core SHARED AUTOMOC - SOURCES ${polkit_tqt_core_MOCS} + SOURCES polkit-tqt-actiondescription.cpp polkit-tqt-authority.cpp polkit-tqt-details.cpp @@ -48,6 +48,7 @@ tde_add_library( polkit-tqt-core SHARED AUTOMOC polkit-tqt-temporaryauthorization.cpp VERSION 0.0.0 CXX_FEATURES cxx_nullptr - LINK ${TQT_LIBRARIES} ${POLKIT_GOBJECT_LIBRARIES} + LINK ${TQT_LIBRARIES} + LINK_PRIVATE ${POLKIT_GOBJECT_LIBRARIES} DESTINATION ${LIB_INSTALL_DIR} ) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 8cb8e8c5b..de312fe5b 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -93,13 +93,12 @@ install( tde_add_executable( polkit-tqt-example AUTOMOC SOURCES PkExample.cpp main.cpp - LINK ${TQT_LIBRARIES} ${DBUS_TQT_LIBRARIES} polkit-tqt-core-shared polkit-tqt-gui-shared + LINK ${DBUS_TQT_LIBRARIES} polkit-tqt-gui-shared DESTINATION ${BIN_INSTALL_DIR} ) tde_add_executable( polkit-tqt-example-helper AUTOMOC SOURCES PkExampleHelper.cpp mainHelper.cpp - LINK ${TQT_LIBRARIES} ${DBUS_TQT_LIBRARIES} polkit-tqt-core-shared + LINK ${DBUS_TQT_LIBRARIES} polkit-tqt-core-shared DESTINATION ${BIN_INSTALL_DIR} ) - diff --git a/examples/agent/CMakeLists.txt b/examples/agent/CMakeLists.txt index 4ce78eddb..358875c03 100644 --- a/examples/agent/CMakeLists.txt +++ b/examples/agent/CMakeLists.txt @@ -37,8 +37,6 @@ install( tde_add_executable( polkit-tqt-agent-example AUTOMOC SOURCES main.cpp pkagentexample.cpp tqtlistener.cpp - LINK ${TQT_LIBRARIES} ${POLKIT_GOBJECT_LIBRARIES} ${POLKIT_AGENT_LIBRARIES} - polkit-tqt-core-shared polkit-tqt-agent-shared + LINK polkit-tqt-agent-shared DESTINATION ${BIN_INSTALL_DIR} ) - diff --git a/gui/CMakeLists.txt b/gui/CMakeLists.txt index 0627613a7..8a1f39695 100644 --- a/gui/CMakeLists.txt +++ b/gui/CMakeLists.txt @@ -30,19 +30,20 @@ install( polkit-tqt-gui-action.h polkit-tqt-gui-actionbutton.h polkit-tqt-gui-actionbuttons.h - DESTINATION ${INCLUDE_INSTALL_DIR} + DESTINATION ${INCLUDE_INSTALL_DIR}/${CMAKE_PROJECT_NAME} ) ##### polkit-tqt-gui (shared) ######################### tde_add_library( polkit-tqt-gui SHARED AUTOMOC - SOURCES ${polkit_tqt_gui_MOCS} + SOURCES polkit-tqt-gui-action.cpp polkit-tqt-gui-actionbutton.cpp polkit-tqt-gui-actionbuttons.cpp VERSION 0.0.0 CXX_FEATURES cxx_nullptr - LINK ${TQT_LIBRARIES} ${POLKIT_GOBJECT_LIBRARIES} polkit-tqt-core-shared + LINK polkit-tqt-core-shared + LINK_PRIVATE ${POLKIT_GOBJECT_LIBRARIES} DESTINATION ${LIB_INSTALL_DIR} ) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 92a8543d0..638cacc65 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -22,8 +22,6 @@ include_directories( ) set( link-polkit-tqt-test - ${TQT_LIBRARIES} - polkit-tqt-core-shared polkit-tqt-gui-shared polkit-tqt-agent-shared ) @@ -57,9 +55,8 @@ foreach( _test_name ${_test_auto_executables} ) tde_add_check_executable( ${_test_name} SOURCES ${_test_name}.cpp AUTOMOC LINK ${link-polkit-tqt-test} + TEST ) - - add_test( ${_test_name} ${_test_name} ) endforeach( ) foreach( _test_name ${_test_manual_executables} ) @@ -68,4 +65,3 @@ foreach( _test_name ${_test_manual_executables} ) LINK ${link-polkit-tqt-test} ) endforeach( ) - |