Add kdevelop_add_private_library for consistent private library naming

GIT_SILENT
parent 75f2e71c
...@@ -9,9 +9,11 @@ ...@@ -9,9 +9,11 @@
# TYPE LIBRARY|PLUGIN|APP [IDENTIFIER <id>] [CATEGORY_BASENAME <name>] # TYPE LIBRARY|PLUGIN|APP [IDENTIFIER <id>] [CATEGORY_BASENAME <name>]
# [HEADER <filename>] [DESCRIPTION <desc>]) # [HEADER <filename>] [DESCRIPTION <desc>])
# install_qt_logging_categories(TYPE LIBRARY|APP_PLUGIN) # install_qt_logging_categories(TYPE LIBRARY|APP_PLUGIN)
# kdevelop_add_private_library(<target> SOURCES <source1> [<source2> [...]])
# #
#============================================================================= #=============================================================================
# Copyright 2018 Friedrich W. H. Kossebau <kossebau@kde.org> # Copyright 2018, 2020 Friedrich W. H. Kossebau <kossebau@kde.org>
# 2007 Andreas Pakulat <apaku@gmx.de>
# #
# Distributed under the OSI-approved BSD License (the "License"); # Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details. # see accompanying file Copyright.txt for details.
...@@ -21,6 +23,7 @@ ...@@ -21,6 +23,7 @@
# See the License for more information. # See the License for more information.
#============================================================================= #=============================================================================
include(CMakeParseArguments)
# helper method to ensure consistent cache var names # helper method to ensure consistent cache var names
function(_varname_for_compile_flag_check_result _varname _flag ) function(_varname_for_compile_flag_check_result _varname _flag )
...@@ -313,3 +316,34 @@ function(install_qt_logging_categories) ...@@ -313,3 +316,34 @@ function(install_qt_logging_categories)
message(FATAL_ERROR "Unknown \"${ARGS_TYPE}\" with TYPE when calling declare_qt_logging_category().") message(FATAL_ERROR "Unknown \"${ARGS_TYPE}\" with TYPE when calling declare_qt_logging_category().")
endif() endif()
endfunction() endfunction()
# kdevelop_add_private_library(<target> SOURCES <source1> [<source2> [...]])
function(kdevelop_add_private_library target)
set(options)
set(oneValueArgs)
set(multiValueArgs SOURCES)
cmake_parse_arguments(ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
string(REPLACE "KDev" "" shortTargetName ${target})
if (${shortTargetName} STREQUAL ${target})
message(FATAL_ERROR "Target passed to kdevelop_add_private_library needs to start with \"KDev\", was \"${target}\"")
endif()
string(TOLOWER ${shortTargetName} shortTargetNameToLower)
add_library(${target} SHARED ${ARGS_SOURCES})
add_library(KDev::${shortTargetName} ALIAS ${target})
generate_export_header(${target} EXPORT_FILE_NAME ${shortTargetNameToLower}export.h)
target_include_directories(${target}
INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>" # useful for the "something.export.h" includes
)
set_target_properties(${target} PROPERTIES
VERSION ${KDEV_PLUGIN_VERSION}
SOVERSION ${KDEV_PLUGIN_VERSION}
)
install(TARGETS ${target} ${KDE_INSTALL_TARGETS_DEFAULT_ARGS} LIBRARY NAMELINK_SKIP)
endfunction()
...@@ -17,29 +17,6 @@ if(BUILD_TESTING) ...@@ -17,29 +17,6 @@ if(BUILD_TESTING)
add_subdirectory(tests) add_subdirectory(tests)
endif() endif()
# TODO: Move to kdevplatform
function(add_private_library target)
set(options)
set(oneValueArgs)
set(multiValueArgs SOURCES)
cmake_parse_arguments(KDEV_ADD_PRIVATE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
string(REPLACE "KDev" "" shortTargetName ${target})
if (${shortTargetName} STREQUAL ${target})
message(FATAL_ERROR "Target passed to add_private_library needs to start with \"KDev\", was \"${target}\"")
endif()
string(TOLOWER ${shortTargetName} shortTargetNameToLower)
add_library(${target} SHARED ${KDEV_ADD_PRIVATE_SOURCES})
generate_export_header(${target} EXPORT_FILE_NAME ${shortTargetNameToLower}export.h)
set_target_properties(${target} PROPERTIES
VERSION ${KDEV_PLUGIN_VERSION}
SOVERSION ${KDEV_PLUGIN_VERSION}
)
install(TARGETS ${target} ${KDE_INSTALL_TARGETS_DEFAULT_ARGS} LIBRARY NAMELINK_SKIP)
endfunction()
set(kdevclangprivate_SRCS set(kdevclangprivate_SRCS
clangsettings/clangsettingsmanager.cpp clangsettings/clangsettingsmanager.cpp
clangsettings/sessionsettings/sessionsettings.cpp clangsettings/sessionsettings/sessionsettings.cpp
...@@ -106,19 +83,19 @@ ki18n_wrap_ui(kdevclangprivate_SRCS ...@@ -106,19 +83,19 @@ ki18n_wrap_ui(kdevclangprivate_SRCS
kconfig_add_kcfg_files(kdevclangprivate_SRCS clangsettings/sessionsettings/sessionconfig.kcfgc) kconfig_add_kcfg_files(kdevclangprivate_SRCS clangsettings/sessionsettings/sessionconfig.kcfgc)
add_private_library(KDevClangPrivate SOURCES ${kdevclangprivate_SRCS}) kdevelop_add_private_library(KDevClangPrivate SOURCES ${kdevclangprivate_SRCS})
target_link_libraries(KDevClangPrivate target_link_libraries(KDevClangPrivate
LINK_PRIVATE PUBLIC
KDev::Language
KDev::Project
KDev::Util
Clang::clang
PRIVATE
Qt5::Core Qt5::Core
KF5::TextEditor KF5::TextEditor
KF5::ThreadWeaver KF5::ThreadWeaver
KDev::DefinesAndIncludesManager KDev::DefinesAndIncludesManager
KDev::Util KDev::Util
LINK_PUBLIC
KDev::Language
KDev::Project
KDev::Util
Clang::clang
) )
if (HAVE_DLFCN) if (HAVE_DLFCN)
......
...@@ -83,32 +83,53 @@ endif() ...@@ -83,32 +83,53 @@ endif()
kconfig_add_kcfg_files( cmakecommon_SRCS cmakebuilderconfig.kcfgc ) kconfig_add_kcfg_files( cmakecommon_SRCS cmakebuilderconfig.kcfgc )
ki18n_wrap_ui( cmakecommon_SRCS ${cmakecommon_UI} ) ki18n_wrap_ui( cmakecommon_SRCS ${cmakecommon_UI} )
add_library( kdevcmakecommon SHARED ${cmakecommon_SRCS} ) kdevelop_add_private_library(KDevCMakeCommon SOURCES ${cmakecommon_SRCS})
target_link_libraries( kdevcmakecommon target_link_libraries(KDevCMakeCommon
KF5::TextEditor KDev::Interfaces KDev::Project KDev::Util PUBLIC
KDev::Language KDev::Interfaces
) KDev::Project
generate_export_header(kdevcmakecommon EXPORT_FILE_NAME cmakecommonexport.h) KDev::Util
KDev::Language
KF5::TextEditor
)
ki18n_wrap_ui( cmakemanager_SRCS ${cmakemanager_UI} ) ki18n_wrap_ui( cmakemanager_SRCS ${cmakemanager_UI} )
add_library( kdevcmakemanagernosettings STATIC ${cmakemanager_SRCS}) add_library( kdevcmakemanagernosettings STATIC ${cmakemanager_SRCS})
target_link_libraries( kdevcmakemanagernosettings KF5::KIOWidgets KDev::Util target_link_libraries(kdevcmakemanagernosettings
KDev::Interfaces kdevcmakecommon kdevmakefileresolver KDevCMakeCommon
KDev::Project KDev::Language kdevmakefileresolver
KDev::OutputView KF5::TextEditor Qt5::Concurrent) KDev::Util
KDev::Interfaces
KDev::Project
KDev::Language
KDev::OutputView
KF5::KIOWidgets
KF5::TextEditor
Qt5::Concurrent
)
kdevplatform_add_plugin(kdevcmakemanager JSON kdevcmakemanager.json SOURCES ${cmakemanager_SRCS} ${cmakesettings_SRCS}) kdevplatform_add_plugin(kdevcmakemanager JSON kdevcmakemanager.json SOURCES ${cmakemanager_SRCS} ${cmakesettings_SRCS})
target_link_libraries( kdevcmakemanager KF5::KIOWidgets KDev::Util target_link_libraries(kdevcmakemanager
KDev::Interfaces kdevcmakecommon kdevmakefileresolver KDevCMakeCommon
KDev::Project KDev::Language KDev::Shell kdevmakefileresolver
KDev::OutputView KF5::TextEditor Qt5::Concurrent) KDev::Util
KDev::Interfaces
KDev::Project
KDev::Language
KDev::Shell
KDev::OutputView
KF5::KIOWidgets
KF5::TextEditor
Qt5::Concurrent
)
kdevplatform_add_plugin(kdevcmakedocumentation JSON kdevcmakedocumentation.json SOURCES ${cmakedoc_SRCS}) kdevplatform_add_plugin(kdevcmakedocumentation JSON kdevcmakedocumentation.json SOURCES ${cmakedoc_SRCS})
target_link_libraries( kdevcmakedocumentation target_link_libraries( kdevcmakedocumentation
KDev::Interfaces kdevcmakecommon KDevCMakeCommon
KDev::Project KDev::Language KDev::Interfaces
KDev::Documentation KDev::Project
KF5::ItemModels KDev::Language
KF5::TextEditor) KDev::Documentation
KF5::ItemModels
install(TARGETS kdevcmakecommon ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) KF5::TextEditor
)
...@@ -6,7 +6,7 @@ remove_definitions( ...@@ -6,7 +6,7 @@ remove_definitions(
configure_file("paths.h.cmake" "cmake-test-paths.h" ESCAPE_QUOTES) configure_file("paths.h.cmake" "cmake-test-paths.h" ESCAPE_QUOTES)
set(commonlibs Qt5::Test Qt5::Core KDev::Interfaces kdevcmakecommon) set(commonlibs Qt5::Test Qt5::Core KDev::Interfaces KDevCMakeCommon)
ecm_add_test(cmakeparsertest.cpp ../parser/cmListFileLexer.c TEST_NAME test_cmakeparser LINK_LIBRARIES ${commonlibs}) ecm_add_test(cmakeparsertest.cpp ../parser/cmListFileLexer.c TEST_NAME test_cmakeparser LINK_LIBRARIES ${commonlibs})
ecm_add_test(test_cmakemanager.cpp LINK_LIBRARIES ${commonlibs} KDev::Language KDev::Tests KDev::Project kdevcmakemanagernosettings) ecm_add_test(test_cmakemanager.cpp LINK_LIBRARIES ${commonlibs} KDev::Language KDev::Tests KDev::Project kdevcmakemanagernosettings)
...@@ -15,4 +15,4 @@ ecm_add_test(test_cmakeserver.cpp LINK_LIBRARIES ${commonlibs} KDev::Languag ...@@ -15,4 +15,4 @@ ecm_add_test(test_cmakeserver.cpp LINK_LIBRARIES ${commonlibs} KDev::Languag
# this is not a unit test but a testing tool, kept here for convenience # this is not a unit test but a testing tool, kept here for convenience
add_executable(kdevprojectopen kdevprojectopen.cpp) add_executable(kdevprojectopen kdevprojectopen.cpp)
target_link_libraries(kdevprojectopen Qt5::Test KDev::Project KDev::Tests kdevcmakecommon) target_link_libraries(kdevprojectopen Qt5::Test KDev::Project KDev::Tests KDevCMakeCommon)
...@@ -16,16 +16,13 @@ declare_qt_logging_category(cmakebuilder_SRCS ...@@ -16,16 +16,13 @@ declare_qt_logging_category(cmakebuilder_SRCS
) )
ki18n_wrap_ui(cmakebuilder_SRCS cmakebuilderpreferences.ui) ki18n_wrap_ui(cmakebuilder_SRCS cmakebuilderpreferences.ui)
kdevplatform_add_plugin(kdevcmakebuilder JSON kdevcmakebuilder.json SOURCES ${cmakebuilder_SRCS}) kdevplatform_add_plugin(kdevcmakebuilder JSON kdevcmakebuilder.json SOURCES ${cmakebuilder_SRCS})
target_link_libraries( target_link_libraries(kdevcmakebuilder
kdevcmakebuilder KDevCMakeCommon
kdevcmakecommon
KF5::KIOWidgets
KDev::Interfaces KDev::Interfaces
KDev::OutputView KDev::OutputView
KDev::Util KDev::Util
KDev::Shell KDev::Shell
KDev::Project KDev::Project
KDev::IMakeBuilder KDev::IMakeBuilder
KF5::KIOWidgets
) )
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment