set_source_files_properties and custom targets

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

set_source_files_properties and custom targets

Pentecost, Caleb



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:



# Show CMake how to build the file we need










# Create a target that requires the output file

add_custom_target(customTarget DEPENDS out.txt


# Create a list of source files






# Make all source files depend on the new target







# 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:



# Miscellaneous assignments at the top



# Rule to make custom target

system/libs/utils/CMakeFiles/customTarget: out.txt


out.txt: C:/in.txt



# Rules to make the files

system/libs/utils/CMakeFiles/utils.dir/utils.o: customTarget



system/libs/utils/CMakeFiles/utils.dir/helpers.o: customTarget



# 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

Please keep messages on-topic and check the CMake FAQ at:

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

CMake Support:
CMake Consulting:
CMake Training Courses:

Visit other Kitware open-source projects at

Follow this link to subscribe/unsubscribe: