-
Notifications
You must be signed in to change notification settings - Fork 65
Description
Describe the bug
TL/DR: I recommend replacing the file(GLOB ...) command here with a list of the files to build. I imagine the better approach will be something like the following with the caveat that both my cmake skills and my C++ skills are rusty:
add_library(MOLE SHARED
divergence.cpp
gradient.cpp
interpol.cpp
laplacian.cpp
mixedbc.cpp
robinbc.cpp
utils.cpp
)My underrating from discussions with the CMake developers years ago was that listing each file to be compiled is the best practice. If I recall correctly, one reason relates to what happens when adding or renaming files. CMake originally stood for "Cross-platform Makefile generator" so rather than being a build system itself, CMake generates build systems, e.g., Makefiles or Ninja files. Once the build system has been generated, the list of files to build is fixed. The only way to pick up new files is to regenerate the build system by rerunning cmake. This could lead to confusing behavior if the person doing the rebuilding is unaware of this issue.
A quick Google search turns up several discussions of this topic. Here's one: "Don't use file(GLOB) in projects.".