@@ -2,28 +2,43 @@ if (NOT rcs_FOUND)
22 if (NOT Python3_FOUND)
33 set (rcs_FOUND FALSE )
44 if (rcs_FIND_REQUIRED)
5- message (FATAL_ERROR "Could not find rcs. Please install rcs using pip." )
5+ message (FATAL_ERROR "Could not find rcs 1. Please install rcs-core using pip." )
6+ endif ()
7+ return ()
8+ endif ()
9+
10+ execute_process (
11+ COMMAND
12+ ${Python3_EXECUTABLE}
13+ -c
14+ "import importlib.util; import pathlib; spec = importlib.util.find_spec('rcs'); print(pathlib.Path(next(iter(spec.submodule_search_locations))).resolve() if spec and spec.submodule_search_locations else '')"
15+ OUTPUT_VARIABLE rcs_package_dir
16+ OUTPUT_STRIP_TRAILING_WHITESPACE
17+ )
18+ if (NOT rcs_package_dir)
19+ set (rcs_FOUND FALSE )
20+ if (rcs_FIND_REQUIRED)
21+ message (FATAL_ERROR "Could not find rcs 2. Please install rcs-core using pip." )
622 endif ()
723 return ()
824 endif ()
925
1026 # Check if the include directory exists
11- cmake_path (APPEND Python3_SITELIB rcs include OUTPUT_VARIABLE rcs_INCLUDE_DIRS )
27+ cmake_path (APPEND rcs_package_dir include OUTPUT_VARIABLE rcs_INCLUDE_DIRS )
1228 if (NOT EXISTS ${rcs_INCLUDE_DIRS} )
1329 set (rcs_FOUND FALSE )
1430 if (rcs_FIND_REQUIRED)
15- message (FATAL_ERROR "Could not find rcs. Please install rcs using pip." )
31+ message (FATAL_ERROR "Could not find rcs 3 . Please install rcs-core using pip." )
1632 endif ()
1733 return ()
1834 endif ()
1935
2036 # Check if the library file exists
21- cmake_path (APPEND Python3_SITELIB rcs OUTPUT_VARIABLE rcs_library_path )
22- file (GLOB rcs_library_path "${rcs_library_path} /librcs.so" )
37+ set (rcs_library_path "${rcs_package_dir} /librcs.so" )
2338 if (NOT EXISTS ${rcs_library_path} )
2439 set (rcs_FOUND FALSE )
2540 if (rcs_FIND_REQUIRED)
26- message (FATAL_ERROR "Could not find rcs. Please install rcs using pip." )
41+ message (FATAL_ERROR "Could not find rcs 4 . Please install rcs-core using pip." )
2742 endif ()
2843 return ()
2944 endif ()
@@ -43,4 +58,4 @@ if (NOT rcs_FOUND)
4358 IMPORTED_LOCATION "${rcs_library_path} "
4459 )
4560 set (rcs_FOUND TRUE )
46- endif ()
61+ endif ()
0 commit comments