MantisBT - CMake | |||||
View Issue Details | |||||
ID | Project | Category | View Status | Date Submitted | Last Update |
0015614 | CMake | CCMake | public | 2015-06-12 16:03 | 2016-01-04 11:51 |
Reporter | FlorianM | ||||
Assigned To | |||||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | won't fix | ||
Platform | OS | OS Version | |||
Product Version | CMake 3.2.2 | ||||
Target Version | Fixed in Version | ||||
Summary | 0015614: add_custom_target/command: Can't give Target the same name as one of the Outputs | ||||
Description | Let's say you want to transfer the following makefile into a CMake equivalent: foo_in: foo.c $(CC) $< -o $@ foo_out: foo_in post_process $< > $@ And you don't want to add the second step as a post-build step. You still want to be able to build foo_in or foo_out separately. | ||||
Steps To Reproduce | I'm using the "MSYS Makefiles" generator with the following test script: --- cmake_minimum_required(VERSION 2.8) project(MakeTargetTest C) file(WRITE foo.c "#include <windows.h>\nint main() {}") file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/post_process "echo Process something") add_executable(foo_in foo.c) set_target_properties(foo_in PROPERTIES SUFFIX "") add_custom_command( OUTPUT foo_out COMMAND post_process foo_in > foo_out DEPENDS foo_in ) add_custom_target(foo_out DEPENDS foo_out) --- $ make foo_out Built target foo_out --- [build.make] ... CMakeFiles/foo_out: foo_out: CMakeFiles/foo_out foo_out: CMakeFiles/foo_out.dir/build.make .PHONY : foo_out --- If I rename the custom target to something like "foo_out_test" it works correctly: $ make foo_out_test Scanning dependencies of target foo_in [ 50%] Building C object CMakeFiles/foo_in.dir/foo.c.obj Linking C executable foo_in. [ 50%] Built target foo_in [100%] Generating foo_out [100%] Built target foo_out_test --- [build.make] ... CMakeFiles/foo_out_test: foo_out foo_out: foo_in. $(CMAKE_COMMAND) -E cmake_progress_report CMakeFiles $(CMAKE_PROGRESS_1) @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --blue --bold "Generating foo_out" post_process foo_in > foo_out foo_out_test: CMakeFiles/foo_out_test foo_out_test: foo_out foo_out_test: CMakeFiles/foo_out_test.dir/build.make .PHONY : foo_out_test | ||||
Additional Information | I understand that the Makefile generator could get confused by dependency that could be a file and a target dependency, but why should this be possible for executables and not for custom commands? And why could I not at least get a warning or error by CMake during generation (since the rule generated is just empty, see "Steps to Reproduce")? I can see 3 possible solutions: 1. The generator detects that there is a file and a target with the same name and does add a suffix or prefix to its internal build rules for that file. 2. The add_custom_target() command is extended to allow to define its "final" output which is then handled the same way a and add_executable() command output file. 3. Add an GENERIC (linker) language. So you could use files with any extensions with add_executable() that are directly given to a definable "linker". | ||||
Tags | CMake, dependency, makefile, mingw | ||||
Relationships | |||||
Attached Files | |||||
Issue History | |||||
Date Modified | Username | Field | Change | ||
2015-06-12 16:03 | FlorianM | New Issue | |||
2015-06-12 16:07 | FlorianM | Note Added: 0038917 | |||
2015-06-12 16:09 | FlorianM | Tag Attached: CMake | |||
2015-06-12 16:09 | FlorianM | Tag Attached: dependency | |||
2015-06-12 16:09 | FlorianM | Tag Attached: makefile | |||
2015-06-12 16:09 | FlorianM | Tag Attached: mingw | |||
2015-06-15 08:46 | Brad King | Note Added: 0038923 | |||
2015-06-15 08:47 | Brad King | Status | new => resolved | ||
2015-06-15 08:47 | Brad King | Resolution | open => won't fix | ||
2016-01-04 11:51 | Robert Maynard | Note Added: 0040068 | |||
2016-01-04 11:51 | Robert Maynard | Status | resolved => closed |
Notes | |||||
|
|||||
|
|
||||
|
|||||
|
|
||||
|
|||||
|
|