nick
nick

Reputation: 47

how can i make some install command run before compile process?

I will use install command in my CMakeLists like this:

install(DIRECTORY lib-mmm/src/infra/ DESTINATION /home/nick/infra FILES_MATCHING PATTERN "*.h")

this is command to install some directory to some place.

I want this run before other compile process.

but i found when i define it as install, it will be called only when make install, which is after make process.

how can i make install directory command run before real compile process?

Upvotes: 0

Views: 46

Answers (1)

fabian
fabian

Reputation: 82451

Afaik there is no way to do this by using the same project. The install target depends on the targets being build and any dependency of building on the install target would result in a circular dependency.

There are alternatives though:

  1. Use file(COPY)
  2. Use execute_process to set up, build & install another cmake project during configuration. It can be problematic though to get cmake to use the same options for that build. This could also be refined by getting add_custom_command involved...

In your case though simply adding the correct include directory using target_include_directories will probably work better though.

Upvotes: 1

Related Questions