@@ -72,38 +72,28 @@ if ( NOT NO_PYTHON )
7272 set(BOOST_ROOT $ENV{CONDA_PREFIX})
7373 endif()
7474
75- # libboost_python3.7 style libraries
76- message("Looking for libboost_python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR} Mode 1")
77- FIND_PACKAGE(Boost 1.58 QUIET COMPONENTS python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR})
78-
79- # libboost_python3 style libraries
80- if (NOT Boost_FOUND)
81- message("Looking for libboost_python${Python3_VERSION_MAJOR} Mode 2")
82- FIND_PACKAGE(Boost 1.58 QUIET COMPONENTS python${Python3_VERSION_MAJOR})
83- endif()
84-
85- # libboost_python style libraries
86- if (NOT Boost_FOUND)
87- message("Looking for libboost_python Mode 3")
88- FIND_PACKAGE(Boost 1.58 QUIET COMPONENTS system thread python)
89- endif()
90-
91- # libboost_python-py37 style libraries
92- if (NOT Boost_FOUND)
93- message("Looking for libboost_python-py${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR} Mode 4")
94- FIND_PACKAGE(Boost 1.58 QUIET COMPONENTS python-py${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR})
95- endif()
96-
97- # libboost_python3-py37 style libraries
98- if (NOT Boost_FOUND)
99- message("Looking for libboost_python3-py${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR} Mode 5")
100- FIND_PACKAGE(Boost 1.58 QUIET COMPONENTS python3-py${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR})
101- endif()
75+ # Loop through potential Boost Python component names
76+ set(BOOST_PYTHON_CANDIDATES
77+ "python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}" # e.g. python38
78+ "python${Python3_VERSION_MAJOR}" # e.g. python3
79+ "python" # e.g. python
80+ "python-py${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}" # e.g. python-py38
81+ "python3-py${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}" # e.g. python3-py38
82+ )
83+
84+ foreach(COMPONENT_NAME ${BOOST_PYTHON_CANDIDATES})
85+ if(NOT Boost_FOUND)
86+ message(STATUS "Checking for Boost component: ${COMPONENT_NAME}")
87+ find_package(Boost QUIET COMPONENTS ${COMPONENT_NAME})
88+ else()
89+ break()
90+ endif()
91+ endforeach()
10292
10393 # Nothing worked
10494 if (NOT Boost_FOUND)
10595 message("")
106- message(FATAL_ERROR "Failed to find boost libraries!")
96+ message(FATAL_ERROR "Failed to find boost libraries! Tried: ${BOOST_PYTHON_CANDIDATES} ")
10797 endif()
10898
10999else()
0 commit comments