Commit d877b155 authored by Manuel Günther's avatar Manuel Günther
Browse files

Added possibility to search in conda environment via CMAKE_PREFIX_PATH

parent 4a58beab
......@@ -39,11 +39,16 @@ endmacro()
# finds the python executable, which might be in ./bin, BOB_PREFIX_PATH/bin or in the system path
macro(_find_python)
if (NOT _python)
set(_possible_paths ${BOB_SOURCE_DIR}/bin)
set(_possible_paths ${CMAKE_PREFIX_PATH}/bin ${BOB_SOURCE_DIR}/bin)
if (BOB_PREFIX_PATH)
list(APPEND _possible_paths ${BOB_PREFIX_PATH}/bin)
endif()
find_program(_python python HINTS ${_possible_paths})
# first, find python in bob's paths, if possible
find_program(_python python HINTS ${_possible_paths} NO_CMAKE_PATH)
if (NOT _python)
# now, search in the system path
find_program(_python python)
endif()
endif()
endmacro()
......@@ -68,6 +73,15 @@ macro(_recurse_requirements requirements)
# check if string starts with bob
string(FIND ${_req} bob _pos)
if (NOT ${_pos} EQUAL -1)
# check if any versioning is added
set(_chars "=;<;>; ")
foreach (_char IN LISTS _chars)
string(FIND ${_req} ${_char} _pos)
if (NOT ${_pos} EQUAL -1)
string(REPLACE "${_char}" ";" _temp ${_req})
list(GET _temp 0 _req)
endif()
endforeach()
# find bob package recursively (will not run if pacakge was already found)
find_bob_package(${_req})
endif()
......@@ -89,11 +103,10 @@ function(find_bob_package package)
return()
endif()
message(STATUS "Searching for Bob package '${package}'")
# define possible path
set(_possible_paths
${BOB_SOURCE_DIR}/src/${package}
${CMAKE_PREFIX_PATH}/lib/*/site-packages
)
# .. egg directory
file(GLOB _egg_dir ${BOB_SOURCE_DIR}/eggs/${package}*.egg)
......@@ -104,6 +117,9 @@ function(find_bob_package package)
if (BOB_PREFIX_PATH)
list(APPEND _possible_paths ${BOB_PREFIX_PATH}/lib/*/site-packages)
endif()
if (CMAKE_PREFIX_PATH)
list(APPEND _possible_paths ${CMAKE_PREFIX_PATH}/lib/*/site-packages)
endif()
# add common path to locations
set(_bob_paths)
......@@ -129,6 +145,8 @@ function(find_bob_package package)
return()
endif()
message(STATUS "Found Bob package '${package}' at '${_package_dir}'")
set(${PACKAGE}_FOUND TRUE CACHE BOOL "The package ${package} has been found." FORCE)
# first, parse the requirements (requires.txt) from the requires.txt inside ${PACKAGE_BASE_DIR}/${package}*.egg-info or ${PACKAGE_BASE_DIR}/EGG-INFO
......@@ -156,7 +174,7 @@ function(find_bob_package package)
# find include directories
find_path(_include_dir
NAMES include
NAMES include/${package}
HINTS ${_package_dir}
)
if (_include_dir)
......@@ -199,7 +217,9 @@ if (NOT Bob_FIND_COMPONENTS)
endif()
# set Bob source directory, if not given yet (i.e., no FORCE option here)
set(BOB_SOURCE_DIR ${CMAKE_SOURCE_DIR} CACHE STRING "Source directory of Bob packages")
if (NOT BOB_SOURCE_DIR)
set(BOB_SOURCE_DIR ${CMAKE_SOURCE_DIR} CACHE STRING "Source directory of Bob packages")
endif()
# set BOB_PREFIX_PATH as CMake variable when given in as environment variable
if (NOT "$ENV{BOB_PREFIX_PATH}" STREQUAL "")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment