1

I have an external project that provides source files that I want to use to build an executable. I currently have something like the below:

ExternalProject(myproj)

add_executable(myexecutable source.c) # source.c is provided by myproj
add_depedencies(myexecutable myproj)

It errors and complains that it can't find source.c because it hasn't downloaded the external project yet. Is there a way to tell CMake that source.c comes from the external project?

Justin Buchanan
  • 404
  • 3
  • 9

2 Answers2

1

I found a solution. Using add_custom_command I can tell CMake to get the external project first.

add_custom_command(OUTPUT source.c DEPENDS myproj COMMAND "")
Justin Buchanan
  • 404
  • 3
  • 9
0

From https://stackoverflow.com/a/59794921/1203241

set_source_files_properties(source.c PROPERTIES GENERATED TRUE)
Fenjin Wang
  • 331
  • 2
  • 12