In another make tool like CMake, you can express something like this a lot easier.
For example, you could do
set(sources ABC.cpp DEF.cpp XYZ.cpp) ADD_LIBRARY(mylib STATIC ${sources}) add_executable(myExecutable ${sources} main.cpp)
Or you can repeatedly create the same directory with different flags by entering it several times from the logical parent directory, i.e.
set(MyTweakFlag 2) add_subdirectory("libDir" "libDir2") set(MyTweakFlag 3) add_subdirectory("libDir" "libDir3")
... and then use if() or something else in the child directory to set the correct flags.
In particular, if you have many such configurations, using make becomes pretty fragile; make will incorrectly find the transitive closure of recursive make-dependencies (and, of course, it will incorrectly find a dependency on the makefile itself - if you change the flags, say), so if you are going to make a complex makefile mask: do it with the best tool!
(CMake just happens to replace make, but various other replacements are possible)
Eamon nerbonne
source share