![]() This is likely to be the v2 of our software environment.one day. Note that gen-cmake does that (generates a CMakeLists.txt), but in a very primitive way and it apparently only supports Linux, but it may be a good start point. I doubt such generic tool exists, because it's hard to produce the CMakeLists.txt files that will make everyone happy, you'll have to write it yourself. The Python script would do things similar to what our utl.cmake does, instead it would generate a CMakeLists.txt ready to be passed CMake tool (with a format as proposed in HelloWorld, no variable, no would only call standard CMake function). So, I'm now convinced the real good approach may be to:Ģ- completly generate the CMakeLists.txt from a more powerful language like Python. And CMake script language sucks.the tool's very powerful, right, but the script's variable scope, the cache, the painful and not so well documented syntax (just to check if a list is empty you must ask for it's size and store this in a variable!), the fact it's not object oriented.make it a real pain to maintain. However, there remains a lot of CMake scripts to be written. Honestly, we are very happy with this approach, the system becomes very easy to maintain and we can easily add new dependencies, upgrade third parties, change some build/dependency strategies. Then, for all situations exposed above, you simply need to update utl.cmake, not the thousand of CMakeLists.txt you have. # TODO: Parse the simple texts files to add target_link_libraries accordingly As a MCVE that would be:įile(GLOB_RECURSE source_files "$ ) Then, our CMakeLists.txt is a two-line file and simply calls a cmake macro we wrote to automatically setup the module. Each module has a standardized file organization (sources are in src folder, includes are in inc folder.) and have simple text files to specify their dependencies (with keywords we defined, like QT to say the module needs to link with Qt). That's what we have in our software environment. Then, I see two strategies to adress those issues and likely the one mentioned by OP.ġ- Have CMakeLists.txt be well written and be smart enough not to have a frozen behaviourto update themselves on the fly. When you want a new global settings to be changed (compiler setting, predefined variable, C++ standard used), you need to update all your CMakeLists.txt.When you add a new dependency (library A now needs library B), you may need to update the CMakeLists.txt of all programs using A.When you upgrade a third party, you need to update the CMakeLists.txt of all modules using it.When you add a new file to a module, you need to update its CMakeLists.txt. ![]() I agree with celavek: maintaining those CMakeLists.txt files is a real pain: However, if you write your CMakeLists.txt as it is recommended to do (declare the module as being a library/program, importing source files, adding dependencies.). I use CMake to generate the makefiles and that's really great. This software environment hosts many programs (~50), each one picking up some libraries, programs and third parties. I read that this is now lists are stored internally, but I figured this would be taken care of by cmake when I used the variable.I'm maintaining a C++ software environment that has more than 1000 modules (shared, static libraries, programs) and uses more than 20 third parties (boost, openCV, Qt, Qwt.). However, when I do this my compile line contains the flags separated by semicolons and is a syntax error. ), like this: list(APPEND CMAKE_C_FLAGS -new -flags -here) I see that some people were using something like: set(CMAKE_C_FLAGS "$ -new -flags -here")īut then I read in the cmake docs that this is less efficient, and the right way to do it is to use list(APPEND. So I've been trying to modify CMAKE_C_FLAGS and CMAKE_CXX_FLAGS. I have some flags that I don't want passed to the preprocessor. I see some people use add_definitions but from what I can see that is intended for preprocessor flags ( -D). I need to add various flags to my C and C++ compile lines in my CMake files (CMake 2.8.10.2).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |