TransWikia.com

Cmake headers: if the header exists in "X" directory, use it. Otherwise, use the header in "Y" directory. Is this possible?

Stack Overflow Asked by user13978178 on November 29, 2021

I am working with a relatively old code base which has a lot of header files with duplicate names. For example:

dir
 ↪ subdir1
   ↪ header1.h
   ↪ header2.h
 ↪ subdir2
   ↪ header2.h

For reasons I won’t get into here, this structure must remain as-is. I am looking for a way to build/install these headers in such a way that:

for all headers:
  if header in subdir2: use it
  else: use header from subdir1

From my example, this would mean I use subdir1/header1.h and subdir2/header2.h, while ignoreing subdir1/header2.h completely.
I wrote some functions to handle this in my cmake files (basically following the pseudo-code provided above), but they are sloppy. I am looking for a built-in way to handle this type of thing, rather then DIY bandaids.

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP