7

I'm pretty new to CMake, and my question is:

say we have a simple project with only

main.cpp

that uses

header.h

And i want to build this project using CMake, so i have a minimal
CMakeLists.txt that only contains the following (only what's relevant):

add_executable(MyApp main.cpp)

Is there a reason to include the header.h in the CMakeLists.txt?

From what i've seen, if i modify the header.h and run cmake again,
it update as expected.

YoavKlein
  • 2,005
  • 9
  • 38
  • 2
    I don't think that this question is a duplicate, as the linked question is about `add_library` command (in contrast with the title). – Fido Dec 08 '20 at 10:12

1 Answers1

1

should CMake add_executable include header files?

I don't know if this applies to all compilers, but as far as GCC/Clang are concerned: It doesn't matter. You don't need to, but it doesn't break anything if you do.

eerorika
  • 232,697
  • 12
  • 197
  • 326