MantisBT - CMake
View Issue Details
0015995CMakeCMakepublic2016-03-01 07:422016-06-10 14:31
stw_sesa 
geoffviola 
normalmajoralways
closedmoved 
x86_64Windows7
CMake 3.4.3 
 
0015995: GHS Multi Generator: add_custom_command / add_custom_target does not work
The GHS Multi Generator does not handle custom commands added via add_custom_command() correctly / at all. The custom commands are not used in the generated project files and never executed.
Instead the default compiler seems to be called, which obviously fails.
Create a simple CMakeLists.txt like this:

# CMakeLists.txt
cmake_minimum_required (VERSION 2.8)
add_custom_target (a_txt ALL DEPENDS a.txt)
add_custom_command (OUTPUT a.txt COMMAND type b.txt > a.txt DEPENDS b.txt)
add_custom_command (OUTPUT b.txt COMMAND type c.txt > b.txt DEPENDS c.txt)
file(WRITE ${CMAKE_BINARY_DIR}/c.txt "hello world" )

-----------------------------------

Generate the GHC Project using CMake and try to build it.
Output from the build:

Building D:\cmake-ghc\build\custom_target_test_ghc\default.gpj
Output from Linking a_txt.gpj:

ccintarm: Error: output file 'a_txt' is a directory.

Error: build failed
Build failed (Tue Mar 01 13:32:50 2016)
No tags attached.
Issue History
2016-03-01 07:42stw_sesaNew Issue
2016-04-17 17:05geoffviolaAssigned To => geoffviola
2016-04-17 17:05geoffviolaStatusnew => assigned
2016-04-17 19:03geoffviolaNote Added: 0040876
2016-06-10 14:29Kitware RobotNote Added: 0042949
2016-06-10 14:29Kitware RobotStatusassigned => resolved
2016-06-10 14:29Kitware RobotResolutionopen => moved
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0040876)
geoffviola   
2016-04-17 19:03   
GHS MULTI is not as general purpose as some of the generators. add_custom_command only works with executables and libraries, but not custom_targets.

custom_targets could be supported with a few workarounds. For example, a custom_target could be treated as a [Library] in the .gpj and a junk .c file could be generated just to use the shell scripting MULTI.

Even with that workaround, there is still an issue of the order of the commands. It seems that the second command fails sometimes, because GHS MULTI runs it before b.txt is generated. I'm not sure if the shell commands run multi threaded.

I've submitted a support request with Green Hills. They may have a solution to some of these issues.
(0042949)
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.