Hello, We currently have kde4_add_plugin calls in our cmake files, they can be replaced with: add_library(foo MODULE ${foo_SRCS}) set_target_properties(foo PROPERTIES PREFIX "")
It's not exactly nice API wise, so after discussing with David, he got the idea of an extra option to add_library which automates the properties call, so the attached patch implements support for the following: add_library(foo MODULE NO_PREFIX ${foo_SRCS}) Any comment? Anyone to sponsor that patch in cmake upstream? Regards. -- Kévin Ottens, http://ervin.ipsquad.net KDAB - proud patron of KDE, http://www.kdab.com
>From c02099dc3948c99b94c0a0150cbb4731e55e46b8 Mon Sep 17 00:00:00 2001 From: Kevin Ottens <er...@kde.org> Date: Thu, 29 Nov 2012 08:10:35 +0100 Subject: [PATCH] Add a NO_PREFIX option to ADD_LIBRARY For plugins it is in fact common to ask for a module and then force to have an empty PREFIX for the target (so that plugin ends up being named foo.so and not libfoo.so for instance). This patch adds a NO_PREFIX convenience which empty the prefix for you. This way, instead of having two calls: add_library(foo MODULE ${foo_SRCS}) set_target_properties(foo PROPERTIES PREFIX "") #remove lib prefix You can just specify: add_library(foo MODULE NO_PREFIX ${foo_SRCS}) --- Source/cmAddLibraryCommand.cxx | 8 +++++++- Source/cmAddLibraryCommand.h | 6 ++++++ Source/cmMakefile.cxx | 7 ++++++- Source/cmMakefile.h | 3 ++- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx index fd39eec..a829957 100644 --- a/Source/cmAddLibraryCommand.cxx +++ b/Source/cmAddLibraryCommand.cxx @@ -32,6 +32,7 @@ bool cmAddLibraryCommand bool excludeFromAll = false; bool importTarget = false; bool importGlobal = false; + bool noPrefix = false; std::vector<std::string>::const_iterator s = args.begin(); @@ -76,6 +77,11 @@ bool cmAddLibraryCommand type = cmTarget::UNKNOWN_LIBRARY; haveSpecifiedType = true; } + else if(*s == "NO_PREFIX") + { + ++s; + noPrefix = true; + } else if(*s == "EXCLUDE_FROM_ALL") { ++s; @@ -185,7 +191,7 @@ bool cmAddLibraryCommand ++s; } - this->Makefile->AddLibrary(libName.c_str(), type, srclists, excludeFromAll); + this->Makefile->AddLibrary(libName.c_str(), type, srclists, excludeFromAll, noPrefix); return true; } diff --git a/Source/cmAddLibraryCommand.h b/Source/cmAddLibraryCommand.h index c144565..a0e0bb1 100644 --- a/Source/cmAddLibraryCommand.h +++ b/Source/cmAddLibraryCommand.h @@ -58,6 +58,7 @@ public: { return " add_library(<name> [STATIC | SHARED | MODULE]\n" + " [NO_PREFIX]\n" " [EXCLUDE_FROM_ALL]\n" " source1 source2 ... sourceN)\n" "Adds a library target called <name> to be built from the " @@ -91,6 +92,11 @@ public: "See documentation of the OUTPUT_NAME target property to change " "the <name> part of the final file name. " "\n" + "If NO_PREFIX is given the corresponding property will be " + "set to being empty on the created target. " + "See documentation of the PREFIX target property for " + "details." + "\n" "If EXCLUDE_FROM_ALL is given the corresponding property will be " "set on the created target. " "See documentation of the EXCLUDE_FROM_ALL target property for " diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 8498d72..811ef90 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1918,7 +1918,8 @@ void cmMakefile::AddGlobalLinkInformation(const char* name, cmTarget& target) cmTarget* cmMakefile::AddLibrary(const char* lname, cmTarget::TargetType type, const std::vector<std::string> &srcs, - bool excludeFromAll) + bool excludeFromAll, + bool noPrefix) { // wrong type ? default to STATIC if ( (type != cmTarget::STATIC_LIBRARY) @@ -1940,6 +1941,10 @@ cmTarget* cmMakefile::AddLibrary(const char* lname, cmTarget::TargetType type, { target->SetProperty("EXCLUDE_FROM_ALL", "TRUE"); } + if(noPrefix) + { + target->SetProperty("PREFIX", ""); + } target->AddSources(srcs); this->AddGlobalLinkInformation(lname, *target); return target; diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 70cfe54..b8a6efd 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -334,7 +334,8 @@ public: */ cmTarget* AddLibrary(const char *libname, cmTarget::TargetType type, const std::vector<std::string> &srcs, - bool excludeFromAll = false); + bool excludeFromAll = false, + bool noPrefix = false); #if defined(CMAKE_BUILD_WITH_CMAKE) /** -- 1.7.10.4
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Kde-frameworks-devel mailing list Kde-frameworks-devel@kde.org https://mail.kde.org/mailman/listinfo/kde-frameworks-devel