Skip to content
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

Improve the CMake project wizard template #105

Merged
merged 1 commit into from
Oct 17, 2022

Conversation

mbooth101
Copy link
Member

The hello world CMake project template is extremely basic and generates deprecation warnings out-of-the-box:

Configuring in: /home/mbooth/runtime-cdt-0/MrProj/build/default
cmake -G Unix Makefiles -DCMAKE_EXPORT_COMPILE_COMMANDS=ON /home/mbooth/runtime-cdt-0/MrProj
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

And will not build at all if you name the project something containing a space:

CMake Error: Could not find cmake module file: CMakeDetermineProjCompiler.cmake
CMake Error: Error required internal CMake variable not set, cmake may not be built correctly.
-- Configuring incomplete, errors occurred!
See also "/home/mbooth/runtime-cdt-0/A Proj/build/default/CMakeFiles/CMakeOutput.log".
Missing variable is:
CMAKE_Proj_COMPILER_ENV_VAR
CMake Error: Error required internal CMake variable not set, cmake may not be built correctly.

Every currently supported distro of Linux that I checked comes with CMake > 3 so I propose we make the template a bit better. This change fixes the deprecation warnings by bumping the min version of CMake to 3.10 (still a very old version) and takes advantage of some features from CMake > 3, like showing how to set some project configuration details, and showing how to implement the common idiom of generating configuration headers.

Project names containing spaces is also allowed by this patch by using freemarker syntax to remove them where necessary in the template.

Fixes out-of-the-box deprecation warnings, the template now specifies a
minimum CMake version of 3.10

Allows project names containing spaces by using freemarker syntax to
remove them where necessary in the CMakeLists.txt file.

Demonstrates how to implement the common idiom of configuration header
files.
@mbooth101 mbooth101 requested a review from 15knots October 17, 2022 09:56
@mbooth101
Copy link
Member Author

Hi @15knots, what do you think about this improvement?

@github-actions
Copy link

Test Results

     612 files       612 suites   19m 0s ⏱️
10 253 tests 10 230 ✔️ 21 💤 2
10 216 runs  10 193 ✔️ 21 💤 2

For more details on these failures, see this check.

Results for commit 8b29717.

@15knots
Copy link
Contributor

15knots commented Oct 17, 2022

+1
(Although I'm not using CDT's core cmake build at all)

Copy link
Member

@jonahgraham jonahgraham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM too.

@mbooth101 mbooth101 merged commit 1783120 into eclipse-cdt:main Oct 17, 2022
@mbooth101 mbooth101 deleted the better_cmake_template branch October 17, 2022 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants