@@ -55,7 +55,8 @@ include(FindPackageHandleStandardArgs)
55
55
find_package_handle_standard_args(
56
56
${CMAKE_FIND_PACKAGE_NAME}
57
57
REQUIRED_VARS scotch_lib
58
- scotch_inc)
58
+ scotch_inc
59
+ VERSION_VAR scotch_version)
59
60
60
61
find_package_handle_standard_args(
61
62
${CMAKE_FIND_PACKAGE_NAME}
@@ -77,8 +78,54 @@ find_package_handle_standard_args(
77
78
REQUIRED_VARS ptscotchparmetis_lib
78
79
ptscotchparmetis_inc)
79
80
81
+
82
+ ## Find version of scotch if possible
83
+ if ( EXISTS "${scotch_inc} /scotch.h" )
84
+
85
+ file (READ "${scotch_inc} /scotch.h" header_content)
86
+
87
+ # Extract the major version number using regex
88
+ string (REGEX MATCH "SCOTCH_VERSION ([0-9]+)" VERSION_MAJOR_MATCH "${header_content} " )
89
+ if (VERSION_MAJOR_MATCH)
90
+ set (SCOTCH_VERSION_MAJOR "${CMAKE_MATCH_1} " )
91
+ message (STATUS "SCOTCH_VERSION_MAJOR: ${SCOTCH_VERSION_MAJOR} " )
92
+ else ()
93
+ message (WARNING "Could not find SCOTCH_VERSION in scotch.h" )
94
+ endif ()
95
+
96
+ # Extract the minor version number using regex
97
+ string (REGEX MATCH "SCOTCH_RELEASE ([0-9]+)" VERSION_MINOR_MATCH "${header_content} " )
98
+ if (VERSION_MINOR_MATCH)
99
+ set (SCOTCH_RELEASE "${CMAKE_MATCH_1} " )
100
+ message (STATUS "SCOTCH_RELEASE: ${SCOTCH_RELEASE} " )
101
+ else ()
102
+ message (WARNING "Could not find SCOTCH_RELEASE in scotch.h" )
103
+ endif ()
104
+
105
+ # Extract the patch version number using regex
106
+ string (REGEX MATCH "SCOTCH_PATCHLEVEL ([0-9]+)" VERSION_PATCH_MATCH "${header_content} " )
107
+ if (VERSION_PATCH_MATCH)
108
+ set (SCOTCH_PATCHLEVEL "${CMAKE_MATCH_1} " )
109
+ message (STATUS "SCOTCH_PATCHLEVEL: ${SCOTCH_PATCHLEVEL} " )
110
+ else ()
111
+ message (WARNING "Could not find VERSION_PATCH in scotch.h" )
112
+ endif ()
113
+ set (SCOTCH_VERSION "${SCOTCH_VERSION_MAJOR} .${SCOTCH_RELEASE} .${SCOTCH_PATCHLEVEL} " )
114
+ endif ()
115
+
116
+
117
+
80
118
message (STATUS "Found SCOTCH: ${scotch_lib} " )
81
119
message (STATUS "Found PTSCOTCH: ${ptscotch_lib} " )
82
120
message (STATUS "Found SCOTCHerr: ${scotcherr_lib} " )
83
121
message (STATUS "Found PTSCOTCHerr: ${ptscotcherr_lib} " )
84
122
message (STATUS "Found PTSCOTCHparmetis: ${ptscotchparmetis_lib} " )
123
+ message (STATUS "SCOTCH version: ${SCOTCH_VERSION} " )
124
+
125
+
126
+
127
+ #if(SCOTCH_VERSION VERSION_GREATER "7.0.6")
128
+ # add_definitions(-DSCOTCH_7.0.7)
129
+ # message(STATUS "SOCTCH version 7.0.7 or higher")
130
+ #endif
131
+
0 commit comments