mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
* [ptxdist] [PATCH] template: src-cmake-prog: Modernize CMake file
@ 2022-07-07  9:11 Alexander Dahl
  2022-07-29  6:23 ` [ptxdist] [APPLIED] " Michael Olbrich
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Dahl @ 2022-07-07  9:11 UTC (permalink / raw)
  To: ptxdist

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




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [ptxdist] [APPLIED] template: src-cmake-prog: Modernize CMake file
  2022-07-07  9:11 [ptxdist] [PATCH] template: src-cmake-prog: Modernize CMake file Alexander Dahl
@ 2022-07-29  6:23 ` Michael Olbrich
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Olbrich @ 2022-07-29  6:23 UTC (permalink / raw)
  To: ptxdist; +Cc: Alexander Dahl

Thanks, applied as 7b0eaf35f9a01a047a345c3b053f663a3b838cf5.

Michael

[sent from post-receive hook]

On Fri, 29 Jul 2022 08:23:43 +0200, Alexander Dahl <ada@thorsis.com> wrote:
> 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>
> Message-Id: <20220707091152.11519-1-ada@thorsis.com>
> Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
> 
> 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 bc81d861c721..8baf3f64ec0f 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 253eedca9cce..8f2903bf0f24 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



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-07-29  6:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-07  9:11 [ptxdist] [PATCH] template: src-cmake-prog: Modernize CMake file Alexander Dahl
2022-07-29  6:23 ` [ptxdist] [APPLIED] " Michael Olbrich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox