Howdy,

I'm running into an issue with a custom target dependency that I want to assign 
to all source files. In this case, I have a helper library (lets call it utils) 
that builds a couple source files that each depend on an output file from a 
separate process. It would look something like this:

System/libs/utils/CMakeLists.txt:
# Show CMake how to build the file we need
add_custom_command(
  OUTPUT
    out.txt
  DEPENDS
    C:/in.txt
  COMMAND
    <makeOutputFileFromInputFile>
)

# Create a target that requires the output file
add_custom_target(customTarget DEPENDS out.txt

# Create a list of source files
set (SOURCE_FILES
  utils.cpp
  helpers.cpp
)

# Make all source files depend on the new target
set_source_files_properties(
  ${SOURCE_FILES}
  OBJECT_DEPENDS
    customTarget
)

# Assign source files to utils library, etc.
<...>



When CMake runs, two folders are created (in the folder 
bin/obj/system/libs/utils/CMakeFiles). They are called utils.dir and 
customTarget.dir. In utils.dir, we find our build.make file and see the rules 
to produce the compiled object as well as the custom target:

bin/obj/system/libs/utils/CMakeFiles/build.make:
# Miscellaneous assignments at the top
<...>

# Rule to make custom target
system/libs/utils/CMakeFiles/customTarget: out.txt

out.txt: C:/in.txt
  <makeOutputFileFromInputFile>

# Rules to make the files
system/libs/utils/CMakeFiles/utils.dir/utils.o: customTarget
  <compilerToBuildObject>

system/libs/utils/CMakeFiles/utils.dir/helpers.o: customTarget
  <compilerToBuildObject>

# Other rules, assignments, etc.
<...>



The problem seems to be how the custom target is defined. For the object files, 
its simply the target name. The target itself appears to have a fully qualified 
path. This is giving me the following error:
gmake[2]: *** No rule to make target `customTarget, needed by ` 
system/libs/utils/CMakeFiles/utils.dir/helpers.o'.  Stop.


If I manually edit the make file and change the target to the fully qualified 
name (and manually execute make) then the compilation succeeds. Is there 
something that I am doing wrong that is incorrectly assigning the target name? 
Is there an alternative to the "set_source_files_properties" command that would 
behave better?

Thank you in advance for your help!
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

Reply via email to