MantisBT - CMake
View Issue Details
0015472CMake(No Category)public2015-03-23 20:152016-06-10 14:31
Stephen Kelly 
Kitware Robot 
normalminorhave not tried
closedmoved 
 
 
0015472: CMake does not deduplicate defines which have the same name but different value
  cmake_minimum_required(VERSION 2.8)
  project(cmaketest)

  add_executable(mn main.cpp)
  target_compile_definitions(mn PRIVATE TESTD=1 TESTD=3)

  set_source_files_properties(main.cpp PROPERTIES COMPILE_DEFINITIONS TESTD=5)


CMake currently passes all of the defines, and the compiler (gcc at least) warns about redefinition.
No tags attached.
Issue History
2015-03-23 20:15Stephen KellyNew Issue
2015-03-24 08:56Brad KingNote Added: 0038284
2016-06-10 14:29Kitware RobotNote Added: 0042744
2016-06-10 14:29Kitware RobotStatusnew => resolved
2016-06-10 14:29Kitware RobotResolutionopen => moved
2016-06-10 14:29Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0038284)
Brad King   
2015-03-24 08:56   
Hmm. I'm not sure this is possible because the generators put the target-wide definitions in one place and the per-source definitions in another. They are combined by the native build tool.

Options:

a. Do nothing
b. Warn earlier
c. Transform the source file rule to use -UTESTD -DTESTD=5.
(0042744)
Kitware Robot   
2016-06-10 14:29   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.