Add kdevelop_add_private_library for consistent private library naming

GIT_SILENT
parent 75f2e71c
......@@ -9,9 +9,11 @@
# TYPE LIBRARY|PLUGIN|APP [IDENTIFIER <id>] [CATEGORY_BASENAME <name>]
# [HEADER <filename>] [DESCRIPTION <desc>])
# 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");
# see accompanying file Copyright.txt for details.
......@@ -21,6 +23,7 @@
# See the License for more information.
#=============================================================================
include(CMakeParseArguments)
# helper method to ensure consistent cache var names
function(_varname_for_compile_flag_check_result _varname _flag )
......@@ -313,3 +316,34 @@ function(install_qt_logging_categories)
message(FATAL_ERROR "Unknown \"${ARGS_TYPE}\" with TYPE when calling declare_qt_logging_category().")
endif()
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)
add_subdirectory(tests)
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
clangsettings/clangsettingsmanager.cpp
clangsettings/sessionsettings/sessionsettings.cpp
......@@ -106,19 +83,19 @@ ki18n_wrap_ui(kdevclangprivate_SRCS
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
LINK_PRIVATE
PUBLIC
KDev::Language
KDev::Project
KDev::Util
Clang::clang
PRIVATE
Qt5::Core
KF5::TextEditor
KF5::ThreadWeaver
KDev::DefinesAndIncludesManager
KDev::Util
LINK_PUBLIC
KDev::Language
KDev::Project
KDev::Util
Clang::clang
)
if (HAVE_DLFCN)
......
......@@ -83,32 +83,53 @@ endif()
kconfig_add_kcfg_files( cmakecommon_SRCS cmakebuilderconfig.kcfgc )
ki18n_wrap_ui( cmakecommon_SRCS ${cmakecommon_UI} )
add_library( kdevcmakecommon SHARED ${cmakecommon_SRCS} )
target_link_libraries( kdevcmakecommon
KF5::TextEditor KDev::Interfaces KDev::Project KDev::Util
KDev::Language
)
generate_export_header(kdevcmakecommon EXPORT_FILE_NAME cmakecommonexport.h)
kdevelop_add_private_library(KDevCMakeCommon SOURCES ${cmakecommon_SRCS})
target_link_libraries(KDevCMakeCommon
PUBLIC
KDev::Interfaces
KDev::Project
KDev::Util
KDev::Language
KF5::TextEditor
)
ki18n_wrap_ui( cmakemanager_SRCS ${cmakemanager_UI} )
add_library( kdevcmakemanagernosettings STATIC ${cmakemanager_SRCS})
target_link_libraries( kdevcmakemanagernosettings KF5::KIOWidgets KDev::Util
KDev::Interfaces kdevcmakecommon kdevmakefileresolver
KDev::Project KDev::Language
KDev::OutputView KF5::TextEditor Qt5::Concurrent)
target_link_libraries(kdevcmakemanagernosettings
KDevCMakeCommon
kdevmakefileresolver
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})
target_link_libraries( kdevcmakemanager KF5::KIOWidgets KDev::Util
KDev::Interfaces kdevcmakecommon kdevmakefileresolver
KDev::Project KDev::Language KDev::Shell
KDev::OutputView KF5::TextEditor Qt5::Concurrent)
target_link_libraries(kdevcmakemanager
KDevCMakeCommon
kdevmakefileresolver
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})
target_link_libraries( kdevcmakedocumentation
KDev::Interfaces kdevcmakecommon
KDev::Project KDev::Language
KDev::Documentation
KF5::ItemModels
KF5::TextEditor)
install(TARGETS kdevcmakecommon ${KDE_INSTALL_TARGETS_DEFAULT_ARGS})
KDevCMakeCommon
KDev::Interfaces
KDev::Project
KDev::Language
KDev::Documentation
KF5::ItemModels
KF5::TextEditor
)
......@@ -6,7 +6,7 @@ remove_definitions(
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(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
# this is not a unit test but a testing tool, kept here for convenience
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
)
ki18n_wrap_ui(cmakebuilder_SRCS cmakebuilderpreferences.ui)
kdevplatform_add_plugin(kdevcmakebuilder JSON kdevcmakebuilder.json SOURCES ${cmakebuilder_SRCS})
target_link_libraries(
kdevcmakebuilder
kdevcmakecommon
KF5::KIOWidgets
target_link_libraries(kdevcmakebuilder
KDevCMakeCommon
KDev::Interfaces
KDev::OutputView
KDev::Util
KDev::Shell
KDev::Project
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