MantisBT - CMake | |||||
View Issue Details | |||||
ID | Project | Category | View Status | Date Submitted | Last Update |
0013846 | CMake | (No Category) | public | 2013-01-11 20:23 | 2016-06-10 14:31 |
Reporter | szx | ||||
Assigned To | Kitware Robot | ||||
Priority | normal | Severity | minor | Reproducibility | have not tried |
Status | closed | Resolution | moved | ||
Platform | OS | OS Version | |||
Product Version | |||||
Target Version | Fixed in Version | ||||
Summary | 0013846: Custom commands not working when comamnd output used in another directory | ||||
Description | At least for the Unix Makefile generator (haven't tried others) custom commands are not called when their output file is specified as a source file for a target defined in the parent directory. As soon as I move both add_custom_command() and the target to the same file, everything works fine. | ||||
Steps To Reproduce | ============ Case 1 ============= 1. Create CMakeLists.txt with the following contents cmake_minimum_required(VERSION 2.8.9) project(test) add_subdirectory("src") set_source_files_properties("src/test.c" PROPERTIES GENERATED TRUE) add_executable(test "src/test.c") 2. Create a directory called "src" and another CMakeLists.txt in it: add_custom_command( OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/test.c" COMMAND echo "int main\\(\\) \\{\\}" > "${CMAKE_CURRENT_SOURCE_DIR}/test.c" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" ) 3. You will get the following error from make: test1-build$ make make[2]: *** No rule to make target `src/test.c', needed by `CMakeFiles/test.dir/src/test.c.o'. Stop. make[1]: *** [CMakeFiles/test.dir/all] Error 2 make: *** [all] Error 2 ============ Case 2 ============= 1. Create a CMakeLists.txt with the following contents: cmake_minimum_required(VERSION 2.8.9) project(test) file(MAKE_DIRECTORY "src") add_custom_command( OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/src/test.c" COMMAND echo "int main\\(\\) \\{\\}" > "${CMAKE_CURRENT_SOURCE_DIR}/src/test.c" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" ) set_source_files_properties("src/test.c" PROPERTIES GENERATED TRUE) add_executable(test "src/test.c") 2. make will complete without errors: test2-build$ make [ 50%] Generating /home/asd/Desktop/fuck-cmake/test2/src/test.c Scanning dependencies of target test [100%] Building C object CMakeFiles/test.dir/src/test.c.o Linking C executable test [100%] Built target test | ||||
Additional Information | |||||
Tags | No tags attached. | ||||
Relationships | |||||
Attached Files | ![]() https://public.kitware.com/Bug/file/4614/test.zip | ||||
Issue History | |||||
Date Modified | Username | Field | Change | ||
2013-01-11 20:23 | szx | New Issue | |||
2013-01-11 20:23 | szx | File Added: test.zip | |||
2016-06-10 14:28 | Kitware Robot | Note Added: 0042199 | |||
2016-06-10 14:28 | Kitware Robot | Status | new => resolved | ||
2016-06-10 14:28 | Kitware Robot | Resolution | open => moved | ||
2016-06-10 14:28 | Kitware Robot | Assigned To | => Kitware Robot | ||
2016-06-10 14:31 | Kitware Robot | Status | resolved => closed |
Notes | |||||
|
|||||
|
|