View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0011793CMakeCMakepublic2011-02-03 11:102014-06-02 08:37
ReporterPeter Kuemmel 
Assigned ToPeter Kuemmel 
PrioritynormalSeverityfeatureReproducibilityalways
StatusclosedResolutionwon't fix 
PlatformAll platformsOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0011793: namespace support
DescriptionSeveral commands have the directory as scope,
for instance add_definitions:

add_definitions(-DX)
add_library(X x.cpp)
add_library(antiX antiX.cpp)

When antiX.cpp doesn't compile with the definition X set
then it is not possible to write such a cmake file.

Support of namespace could fix this:

namespace(x)
  add_definitions(-DX)
  add_library(X x.cpp)
endnamespace()
add_library/antiX antiX.cpp)


Attached a patch which adds this feature.

The only critical part is the usage of the new
member variables current*, otherwise not using
namespace() is 100% backward compatible when no
variable with that name is used.



TagsNo tags attached.
Attached Filespatch file icon namespace.patch [^] (33,452 bytes) 2011-02-03 11:10 [Show Content]
patch file icon namespace-2.patch [^] (33,457 bytes) 2011-02-03 11:43 [Show Content]

 Relationships

  Notes
(0025236)
Peter Kuemmel (developer)
2011-02-03 11:44

namespace.patch is buggy use namespace-2.patch.
(0025247)
Brad King (manager)
2011-02-03 13:50

Instead of

add_definitions(-DX)
add_library(X x.cpp)
add_library(antiX antiX.cpp)

use

add_library(X x.cpp)
set_property(TARGET X PROPERTY COMPILE_DEFINITIONS X)
add_library(antiX antiX.cpp)
(0025252)
Peter Kuemmel (developer)
2011-02-03 15:48

> set_property(TARGET X PROPERTY COMPILE_DEFINITIONS X)
add_definitions was an example only.

What about include_directories? Even adding a
INCLUDE_DIRECTORIES property wouldn't do the same:

set(x x1)
message(STATUS "x = ${x}")
namespace(nx)
    set(x x2)
    message(STATUS "x = ${x}")
endnamespace()
message(STATUS "x = ${x}")

Output:
-- x = x1
-- x = x2
-- x = x1


The patch isn't perfect, it's a proposal to see
if there is any chance to get it upstream.

E.g.'namespace' as command name is misleading because
entering the namespace again wouldn't make previously
settings available. A better name must be found.

And cmMakefile::AddNamespace could be merged with
cmMakefile::AddSubDirectory.
(0025253)
Brad King (manager)
2011-02-03 15:56

Why not just organize your project with an actual subdirectory? I think the scoping rules are complicated enough.
(0025254)
Peter Kuemmel (developer)
2011-02-03 16:08

I already have subdirectories but I find it much more
elegant and simpler to maintain if I could write all
the identical build rules in one file.

And the scoping rule are so complicated that I (as normal
user) only know that all the settings done in a subdirectory
are only visible in this directory or below.

Adding something like namespace would simplify the scoping rules
because everybody understands the concept of namespaces.
(0030228)
David Cole (manager)
2012-08-11 11:09

Sending old, never assigned issues to the backlog.

(The age of the bug, plus the fact that it's never been assigned to anyone means that nobody is actively working on it...)

If an issue you care about is sent to the backlog when you feel it should have been addressed in a different manner, please bring it up on the CMake mailing list for discussion. Sign up for the mailing list here, if you're not already on it: http://www.cmake.org/mailman/listinfo/cmake [^]

It's easy to re-activate a bug here if you can find a CMake developer who has the bandwidth to take it on, and ferry a fix through to our 'next' branch for dashboard testing.
(0030467)
Peter Kuemmel (developer)
2012-08-13 08:41

postpone
(0030773)
Stephen Kelly (developer)
2012-08-27 07:04

Is this still needed? We have target-scoped include directories since CMake 2.8.8. Are there other commands where directory-scoping is a problem but there is no target-scoped property? We can fill those gaps.
(0034318)
Stephen Kelly (developer)
2013-11-02 09:45

We have target_compile_options, target_compile_definitions, and target_include_directories now. I'm sure this is not needed.
(0034337)
Peter Kuemmel (developer)
2013-11-03 02:44

I still like this feature.
Especially when using only one CMake file for several directories the namespace is very comfortable, for instance just use add_definitions() like before.

But it seems all love it to pollute the directory tree CMakeLists.txt file.

So the status is "won't fix", or similar, decided by others.
(0035996)
Robert Maynard (manager)
2014-06-02 08:37

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2011-02-03 11:10 Peter Kuemmel New Issue
2011-02-03 11:10 Peter Kuemmel File Added: namespace.patch
2011-02-03 11:43 Peter Kuemmel File Added: namespace-2.patch
2011-02-03 11:44 Peter Kuemmel Note Added: 0025236
2011-02-03 13:50 Brad King Note Added: 0025247
2011-02-03 15:48 Peter Kuemmel Note Added: 0025252
2011-02-03 15:56 Brad King Note Added: 0025253
2011-02-03 16:08 Peter Kuemmel Note Added: 0025254
2012-08-11 11:09 David Cole Status new => backlog
2012-08-11 11:09 David Cole Note Added: 0030228
2012-08-13 08:40 Peter Kuemmel Assigned To => Peter Kuemmel
2012-08-13 08:40 Peter Kuemmel Status backlog => assigned
2012-08-13 08:41 Peter Kuemmel Note Added: 0030467
2012-08-13 08:41 Peter Kuemmel Status assigned => backlog
2012-08-27 07:04 Stephen Kelly Note Added: 0030773
2013-11-02 09:45 Stephen Kelly Note Added: 0034318
2013-11-02 09:45 Stephen Kelly Status backlog => resolved
2013-11-02 09:45 Stephen Kelly Resolution open => fixed
2013-11-03 02:44 Peter Kuemmel Note Added: 0034337
2013-11-03 02:44 Peter Kuemmel Status resolved => feedback
2013-11-03 02:44 Peter Kuemmel Resolution fixed => reopened
2013-11-03 02:45 Peter Kuemmel Status feedback => resolved
2013-11-03 02:45 Peter Kuemmel Resolution reopened => won't fix
2014-06-02 08:37 Robert Maynard Note Added: 0035996
2014-06-02 08:37 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team