From: Alexander Dahl <ada@thorsis.com>
To: ptxdist@pengutronix.de
Subject: [ptxdist] [PATCH] template: src-cmake-prog: Modernize CMake file
Date: Thu, 7 Jul 2022 11:11:52 +0200 [thread overview]
Message-ID: <20220707091152.11519-1-ada@thorsis.com> (raw)
Most things in that 'CMakeLists.txt' were out of date and/or
distracting. Rework towards a sane minimal modern version:
- bump minimum required CMake version (3.1 has most things you need for
"Modern CMake", 3.0 lacks some useful things for that)
- add recommended 'project' command
- avoid source file globbing
- throw out all comments (especially those relating to Qt4)
Additionally the source file which contained C code only, was renamed to
.c so CMake can call a C compiler for that (instead of the heavy C++
stuff).
Signed-off-by: Alexander Dahl <ada@thorsis.com>
---
.../src-cmake-prog/{@name@.cpp => @name@.c} | 0
rules/templates/src-cmake-prog/CMakeLists.txt | 32 ++-----------------
rules/templates/src-cmake-prog/wizard.sh | 4 +--
3 files changed, 5 insertions(+), 31 deletions(-)
rename rules/templates/src-cmake-prog/{@name@.cpp => @name@.c} (100%)
diff --git a/rules/templates/src-cmake-prog/@name@.cpp b/rules/templates/src-cmake-prog/@name@.c
similarity index 100%
rename from rules/templates/src-cmake-prog/@name@.cpp
rename to rules/templates/src-cmake-prog/@name@.c
diff --git a/rules/templates/src-cmake-prog/CMakeLists.txt b/rules/templates/src-cmake-prog/CMakeLists.txt
index bc81d861c..8baf3f64e 100644
--- a/rules/templates/src-cmake-prog/CMakeLists.txt
+++ b/rules/templates/src-cmake-prog/CMakeLists.txt
@@ -1,34 +1,8 @@
-
-cmake_minimum_required(VERSION 2.6.0)
-
-#SET(QT_MIN_VERSION "4.5.0")
-#FIND_PACKAGE(Qt4 REQUIRED)
-
-file (GLOB SRC_FILES *.cpp)
-
-#set (FILES_TO_TRANSLATE ${SRC_FILES})
-#file (GLOB TRANSLATIONS_FILES *.ts)
-#
-#option(UPDATE_TRANSLATIONS "Update source translation translations/*.ts
-#files(WARNING: make clean will delete the source .ts files! Danger!)")
-#
-#if(UPDATE_TRANSLATIONS)
-# qt4_create_translation(QM_FILES ${FILES_TO_TRANSLATE} ${TRANSLATIONS_FILES})
-#else(UPDATE_TRANSLATIONS)
-# qt4_add_translation(QM_FILES ${TRANSLATIONS_FILES})
-#endif(UPDATE_TRANSLATIONS)
+cmake_minimum_required(VERSION 3.1)
+project(@name@)
add_executable(@name@
- ${SRC_FILES}
-# ${QM_FILES}
+ @name@.c
)
-#target_link_libraries(@name@
-# ${QT_QTCORE_LIBRARY}
-# ${QT_QTGUI_LIBRARY}
-#)
-#
-#include_directories(${QT_INCLUDE_DIR})
-
install(TARGETS @name@ RUNTIME DESTINATION bin)
-
diff --git a/rules/templates/src-cmake-prog/wizard.sh b/rules/templates/src-cmake-prog/wizard.sh
index 253eedca9..8f2903bf0 100644
--- a/rules/templates/src-cmake-prog/wizard.sh
+++ b/rules/templates/src-cmake-prog/wizard.sh
@@ -7,11 +7,11 @@ if [ -z "$NAME" ]; then
fi
NAME_UP="$(echo $NAME | tr '[a-z-]' '[A-Z_]')"
-mv "@name@.cpp" "${NAME}.cpp"
+mv "@name@.c" "${NAME}.c"
for i in \
CMakeLists.txt \
- "${NAME}.cpp" \
+ "${NAME}.c" \
; do
sed -i -e "s/\@name\@/${NAME}/g" \
-e "s/\@NAME\@/${NAME_UP}/g" $i
base-commit: 7384b37919cb66e12ff15b4264325cb5eba911c3
--
2.30.2
next reply other threads:[~2022-07-07 9:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-07 9:11 Alexander Dahl [this message]
2022-07-29 6:23 ` [ptxdist] [APPLIED] " Michael Olbrich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220707091152.11519-1-ada@thorsis.com \
--to=ada@thorsis.com \
--cc=ptxdist@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox