Skip to content

Commit e71ec9e

Browse files
Merge pull request #5 from LIHPC-Computational-Geometry/utilities-dev
Version 1.5.0. Debug/information utilities using cmake. common_qt.cma…
2 parents 88f283d + efe04b1 commit e71ec9e

File tree

5 files changed

+153
-2
lines changed

5 files changed

+153
-2
lines changed

cmake/common_qt.cmake

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
set (QT_5 OFF)
22
set (QT_6 OFF)
33
unset (QT_MAJOR)
4+
unset (QT_LIBRARY_PATH)
45
if (Qt6_DIR OR Qt6_ROOT)
56
find_package (Qt6 REQUIRED COMPONENTS Core)
67
if (Qt6_FOUND)
@@ -29,3 +30,16 @@ else ( ) # Spack ?
2930
endif (Qt6_FOUND)
3031
endif ( )
3132

33+
# Qt (5 et 6) créé et installe ses bibliothèques avec un RUNPATH reposant sur $ORIGIN. Le RUNPATH est moins
34+
# prioritaire que le LD_LIBRARY_PATH, lui même moins prioritaire que le RPATH.
35+
# Nos applications et bibliothèques t.q. QtUtil posent un RPATH permettant de charger la 1ère lib Qt
36+
# (Qt5Core ? Qt5Widgets ?) au bon endroit, mais celle-ci va ensuite charger les suivantes selon la directive RUNPATH,
37+
# et comme LD_LIBRARY_PATH prime ce sont celles accessibles par ce biais qui sont prises ... => mélanges de libs Qt
38+
# de versions différentes.
39+
# A noter qu'installé par Spack Qt ne pose pas nécessairement de problème car car spack fait un patchelf après installation
40+
# des binaires, en positionnant les paths à RPATH ou RUNPATH selon la configuration spack.
41+
if (NOT QT_LIBRARY_PATH)
42+
get_target_property (QT_CORE_LOCATION Qt${QT_MAJOR}::Core LOCATION)
43+
get_filename_component (QT_LIBRARY_PATH ${QT_CORE_LOCATION} DIRECTORY)
44+
endif (NOT QT_LIBRARY_PATH)
45+

cmake/common_vtk.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ set (VTK_8 OFF)
33
set (VTK_9 OFF)
44
set (USE_OPENGL_BACKEND OFF)
55
set (QVTK_WIDGET OFF)
6+
unset (VTK_LIBRARY_PATH)
67
find_package (VTK REQUIRED)
78
message (STATUS "VTK DETECTE : ${VTK_VERSION}")
89
if (VTK_VERSION_MAJOR STREQUAL "7")
@@ -17,3 +18,8 @@ else ( )
1718
message (FATAL_ERROR "Version majeure de VTK non gérée : ${VTK_VERSION}")
1819
endif ( )
1920

21+
if (VTK_9)
22+
set (VTK_LIBRARY_PATH "${VTK_PREFIX_PATH}/${CMAKE_INSTALL_LIBDIR}")
23+
else ( )
24+
set (VTK_LIBRARY_PATH "${VTK_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
25+
endif (VTK_9)

cmake/utilities.cmake

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# =========================== Colorisation des messages ===========================
2+
3+
string (ASCII 27 ESC)
4+
set (AnsiEscapeCodeReset "${ESC}[m")
5+
set (Bold "${ESC}[1m")
6+
set (BoldOff "${ESC}[22m")
7+
set (Em "${ESC}[35m")
8+
set (BoldEm "${ESC}[1;35m")
9+
set (Bold "${ESC}[1m")
10+
set (BoldOff "${ESC}[22m")
11+
set (CrossedOut "${ESC}[9m")
12+
set (CrossedOutOff "${ESC}[29m")
13+
set (ItalicOff "${ESC}[23m")
14+
set (Underline "${ESC}[4m")
15+
set (UnderlineOff "${ESC}[24m")
16+
set (BlackFg "${ESC}[30m")
17+
set (RedFg "${ESC}[31m")
18+
set (GreenFg "${ESC}[32m")
19+
set (YellowFg "${ESC}[33m")
20+
set (BlueFg "${ESC}[34m")
21+
set (MagentaFg "${ESC}[35m")
22+
set (CyanFg "${ESC}[36m")
23+
set (WhiteFg "${ESC}[37m")
24+
set (DefaultFg "${ESC}[39m")
25+
set (BlackBg "${ESC}[40m")
26+
set (RedBg "${ESC}[41m")
27+
set (GreenBg "${ESC}[42m")
28+
set (YellowBg "${ESC}[43m")
29+
set (BlueBg "${ESC}[44m")
30+
set (MagentaBg "${ESC}[45m")
31+
set (CyanBg "${ESC}[46m")
32+
set (WhiteBg "${ESC}[47m")
33+
set (DefaultBg "${ESC}[49m")
34+
set (SaveCursorPosition "${ESC}[s") # Does it work ? Even if ${ESC} 7
35+
set (RestoreCursorPosition "${ESC}[u") # Does it work ? Even if ${ESC} 8
36+
set (EraseAfterCursorPosition "${ESC}[0J")
37+
set (EraseFromBeginningToCursorPosition "${ESC}[1J")
38+
set (EraseScreen "${ESC}[2J")
39+
40+
# ========================== ! Colorisation des messages ==========================
41+
42+
43+
# ================================ print_variables ================================
44+
45+
# Affiche toutes les variables cmake contenant pattern.
46+
47+
function (print_variables pattern)
48+
49+
message (STATUS "\n** dump #${pattern}# cmake variables ***")
50+
get_cmake_property (_all_var_names VARIABLES)
51+
foreach (_var_name ${_all_var_names})
52+
string (FIND ${_var_name} "${pattern}" pos_found)
53+
if (NOT pos_found STREQUAL -1)
54+
message (STATUS "${_var_name}=${${_var_name}}")
55+
endif (NOT pos_found STREQUAL -1)
56+
endforeach ( )
57+
message (STATUS "** dump end ***\n")
58+
59+
endfunction (print_variables)
60+
61+
# =============================== ! print_variables ===============================
62+
63+
64+
# ============================ print_target_properties ============================
65+
66+
# Affiche toutes les propriétés de la target transmises en argument.
67+
# https://stackoverflow.com/questions/32183975/how-to-print-all-the-properties-of-a-target-in-cmake/56738858#56738858
68+
69+
function (print_target_properties tgt)
70+
71+
if (NOT TARGET ${tgt})
72+
message (STATUS "There is no target named '${tgt}'")
73+
return ( )
74+
endif (NOT TARGET ${tgt})
75+
76+
# On récupère toutes les propriétés supportées par cmake :
77+
execute_process (COMMAND cmake --help-property-list OUTPUT_VARIABLE CMAKE_PROPERTY_LIST)
78+
STRING (REGEX REPLACE ";" "\\\\;" CMAKE_PROPERTY_LIST "${CMAKE_PROPERTY_LIST}")
79+
STRING (REGEX REPLACE "\n" ";" CMAKE_PROPERTY_LIST "${CMAKE_PROPERTY_LIST}")
80+
list (REMOVE_DUPLICATES CMAKE_PROPERTY_LIST)
81+
82+
# Dans le cas de libs réalisées au sein du projet, de la part de CMP0026, et comme elles
83+
# n'existent pas encore (on est en phase cmake), on va avoir un message du type :
84+
#The LOCATION property may not be read from target "abc". Use the target
85+
# name directly with add_custom_command, or use the generator expression
86+
# $<TARGET_FILE>, as appropriate.
87+
# Le contournement souvent proposé sur le net est d'enlever "LOCATION", "^LOCATION"
88+
# et "_LOCATION" de CMAKE_PROPERTY_LIST. Mais on l'enlève de toutes les cibles, ce qui nous
89+
# prive du coup de cette précieuse information de tout binaire généré :(.
90+
# Contournement proposé ici : on modifie cette politique juste le temps de la fonction.
91+
# Push the current (NEW) CMake policy onto the stack, and apply the OLD policy.
92+
# https://stackoverflow.com/questions/32197663/how-can-i-remove-the-the-location-property-may-not-be-read-from-target-error-i
93+
cmake_policy (PUSH)
94+
# On efface un message d'injures du fait de l'utilisation de cmake_policy (SET CMP0026 OLD)
95+
# message (STATUS "${SaveCursorPosition}")
96+
cmake_policy (SET CMP0026 OLD)
97+
# message (STATUS "${RestoreCursorPosition} ${EraseAfterCursorPosition}")
98+
message (STATUS "${ESC}[12F ${EraseAfterCursorPosition}")
99+
100+
foreach (prop ${CMAKE_PROPERTY_LIST})
101+
string (REPLACE "<CONFIG>" "${CMAKE_BUILD_TYPE}" prop ${prop})
102+
# Ci-dessous : on ne récupère pas les propriétés définies mais vides :
103+
# get_target_property (propval ${tgt} ${prop})
104+
# if (propval)
105+
# message (STATUS "${tgt} ${prop} = ${propval}")
106+
# endif (propval)
107+
# Ci-dessous : avec SET propval vaut 1 si la propriété existe. On récupère alors la valeur de
108+
# la propriété par un seconde appel :
109+
get_property (propval TARGET ${tgt} PROPERTY ${prop} SET)
110+
if (propval)
111+
# message (STATUS "${tgt} ${prop} = ${propval}") # 1
112+
get_target_property (propval ${tgt} ${prop})
113+
message (STATUS "${tgt} ${prop} = ${propval}")
114+
endif (propval)
115+
116+
endforeach(prop)
117+
118+
# Pop the previous policy from the stack to re-apply the NEW behavior.
119+
cmake_policy (POP)
120+
121+
endfunction (print_target_properties)
122+
123+
# =========================== ! print_target_properties ===========================

cmake/version.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
#
44

55
set (GUI_TOOLKITS_VARIABLES_MAJOR_VERSION "1")
6-
set (GUI_TOOLKITS_VARIABLES_MINOR_VERSION "4")
7-
set (GUI_TOOLKITS_VARIABLES_RELEASE_VERSION "3")
6+
set (GUI_TOOLKITS_VARIABLES_MINOR_VERSION "5")
7+
set (GUI_TOOLKITS_VARIABLES_RELEASE_VERSION "0")
88
set (GUI_TOOLKITS_VARIABLES_VERSION ${GUI_TOOLKITS_VARIABLES_MAJOR_VERSION}.${GUI_TOOLKITS_VARIABLES_MINOR_VERSION}.${GUI_TOOLKITS_VARIABLES_RELEASE_VERSION})

versions.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
Version 1.5.0 : 07/06/24
2+
===============
3+
4+
cmake/utilities.cmake : divers utilitaires pour mise au point et informations.
5+
cmake/common_qt.cmake : QT_LIBRARY_PATH
6+
cmake/common_vtk.cmake : VTK_LIBRARY_PATH
7+
8+
19
Version 1.4.3 : 12/01/24
210
===============
311

0 commit comments

Comments
 (0)