-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added initial CMakeLists file to compile with cmake #5
Conversation
This looks nice and tidy! As mentioned in issue #3, is it possible to do Lines 44 to 50 in dea7ea0
The logic is essentially that Also, is it possible to have a Make target Lines 10 to 12 in dea7ea0
Some files have missing newlines. |
Hi, thank you for the quick reply! Dependency GenerationNot sure if I understand the question, I'm rusty on Makefile syntax :) if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
# using Clang
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# using GCC
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
# using Intel C++
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
# using Visual Studio C++
endif() You can use this to add preprocessor definitions to be used in your header files: add_definitions(-DFOO -DBAR ...) and then on the header file one can use: #ifdef FOO
...
#endif
#ifdef BAR
...
#endif For the rest, the build process is done automatically, even if you change the CMake or the source files, you only have to do Make, CMake will re-run itself when required (example: adding a new source file). By looking at the project I can't see any dependency on headers. If you mean automatic header creation by the use of Custom targetsYes, sure thing. It is possible. CMake has also built in functions to add tests to the project. Missing newlinesMaybe Github has an action to format files on commit to avoid those issues. I'll check. Let me know your thoughts, |
It’s much better to check whether a particular compiler feature works, than naming particular compilers, because GCC and Clang, for example, have many features in common, and different features in different versions, and may obtain new features in the future. Likewise with MSVC. What I believe CMake should do is to run the shell script (or similar) Lines 45 to 47 in dea7ea0
and if the answer is Line 49 in dea7ea0
These header dependencies mean that whenever one edits a header file, all the C files that depend on ( Git Hub indicates red icons for c720812 on the last line of certain files, for example the file |
CMake build systemWith cmake builds you do not need to care about header dependencies. The build system will take care of that for you. Now what build system you use, depends vastly on the platform: On unix it may be makefiles or ninja, but on windows for example one can use nmake, ninja or even generate visual studio projects. That can all be done with cmake. The only important thing to consider is to always add the header files as part of the project build rules on CMakeLists.txt. Everything is taken care automatically after that. However it is always possible to add additional flags to the compiler if required, but usually I don't see that very often. When you run CMake for the first time it will automatically detect the compiler and the features available on the system NewlinesWell I am using Visual Studio 2022, should have a setting for that otherwise I'll fix it manually. |
Great, @Talhada! :-) Indeed, CMake has the dependencies I was looking for:
How would you propose the tests be made and run with CMake? The Makefiles offered two variants, a somewhat quiet
and another with the verbosity flag
the latter which runs |
Nice! Would the printing from testing with |
Thanks, it looks great! This seems ready to merge to me, unless you want to adjust anything? The last lines in commit e9096ff has red warning icons again displaying |
Thank tou for your time doing the merges and explain all the requirements for me. Glad to contribute. |
Descritption
Added cmake files to build the project.
Build