Skip to content

Commit b320bc4

Browse files
add version number to findscotch
1 parent e19653f commit b320bc4

File tree

1 file changed

+48
-1
lines changed

1 file changed

+48
-1
lines changed

cmake/FindSCOTCH.cmake

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ include(FindPackageHandleStandardArgs)
5555
find_package_handle_standard_args(
5656
${CMAKE_FIND_PACKAGE_NAME}
5757
REQUIRED_VARS scotch_lib
58-
scotch_inc)
58+
scotch_inc
59+
VERSION_VAR scotch_version)
5960

6061
find_package_handle_standard_args(
6162
${CMAKE_FIND_PACKAGE_NAME}
@@ -77,8 +78,54 @@ find_package_handle_standard_args(
7778
REQUIRED_VARS ptscotchparmetis_lib
7879
ptscotchparmetis_inc)
7980

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+
80118
message(STATUS "Found SCOTCH: ${scotch_lib}")
81119
message(STATUS "Found PTSCOTCH: ${ptscotch_lib}")
82120
message(STATUS "Found SCOTCHerr: ${scotcherr_lib}")
83121
message(STATUS "Found PTSCOTCHerr: ${ptscotcherr_lib}")
84122
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

Comments
 (0)