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

CMake variables are now in the cache; fixed issue with macros; introduced BOB_SOURCE_DIR

parent c26d09d0
......@@ -39,7 +39,7 @@ 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 ${CMAKE_SOURCE_DIR}/bin)
set(_possible_paths ${BOB_SOURCE_DIR}/bin)
if (BOB_PREFIX_PATH)
list(APPEND _possible_paths ${BOB_PREFIX_PATH}/bin)
endif()
......@@ -93,10 +93,10 @@ function(find_bob_package package)
# define possible path
set(_possible_paths
${CMAKE_SOURCE_DIR}/src/${package}
${BOB_SOURCE_DIR}/src/${package}
)
# .. egg directory
file(GLOB _egg_dir ${CMAKE_SOURCE_DIR}/eggs/${package}*.egg)
file(GLOB _egg_dir ${BOB_SOURCE_DIR}/eggs/${package}*.egg)
if (_egg_dir)
list(APPEND _possible_paths ${_egg_dir})
endif()
......@@ -128,7 +128,7 @@ function(find_bob_package package)
return()
endif()
set(${PACKAGE}_FOUND TRUE PARENT_SCOPE)
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
# get the base directory of the currently found package
......@@ -159,21 +159,18 @@ function(find_bob_package package)
HINTS ${_package_dir}
)
if (_include_dir)
list(APPEND Bob_INCLUDE_DIRS ${_include_dir}/include)
set(Bob_INCLUDE_DIRS ${Bob_INCLUDE_DIRS} PARENT_SCOPE)
set(Bob_INCLUDE_DIRS ${Bob_INCLUDE_DIRS} ${_include_dir}/include CACHE STRING "The list of Bob include directories" FORCE)
endif()
# find external dependencies
_get_external_includes(${package})
if (_external_includes)
list(APPEND Bob_INCLUDE_DIRS ${_external_includes})
set(Bob_INCLUDE_DIRS ${Bob_INCLUDE_DIRS} PARENT_SCOPE)
set(Bob_INCLUDE_DIRS ${Bob_INCLUDE_DIRS} ${_external_includes} CACHE STRING "The list of Bob include directories" FORCE)
endif()
# find macros
_get_external_macros(${package})
if (_external_includes)
list(APPEND Bob_DEFINITIONS ${_external_macros})
set(Bob_DEFINITIONS ${Bob_DEFINITIONS} PARENT_SCOPE)
if (_external_macros)
set(Bob_DEFINITIONS ${Bob_DEFINITIONS} ${_external_macros} CACHE STRING "The list of Bob definitions" FORCE)
endif()
# find library
......@@ -182,8 +179,8 @@ function(find_bob_package package)
HINTS ${_package_dir}
)
if (_library)
set(Bob_LIBRARY_DIRS ${Bob_LIBRARY_DIRS} ${_package_dir} PARENT_SCOPE)
set(Bob_LIBRARIES ${Bob_LIBRARIES} ${PACKAGE_LIB} PARENT_SCOPE)
set(Bob_LIBRARY_DIRS ${Bob_LIBRARY_DIRS} ${_package_dir} CACHE STRING "The list of Bob library directories" FORCE)
set(Bob_LIBRARIES ${Bob_LIBRARIES} ${PACKAGE_LIB} CACHE STRING "The list of Bob libraries" FORCE)
endif()
# clean up so that the next package is acually searched and not skipped
......@@ -200,6 +197,10 @@ if (NOT Bob_FIND_COMPONENTS)
message(FATAL_ERROR "Please specify the bob packages that you want to search for as COMPONENTS")
endif()
if (NOT BOB_SOURCE_DIR)
set(BOB_SOURCE_DIR ${CMAKE_SOURCE_DIR})
endif()
# set BOB_PREFIX_PATH as CMake variable when given in as environment variable
if (NOT "$ENV{BOB_PREFIX_PATH}" STREQUAL "")
if (BOB_PREFIX_PATH)
......@@ -207,7 +208,7 @@ if (NOT "$ENV{BOB_PREFIX_PATH}" STREQUAL "")
message(WARNING "Ignoring the BOB_PREFIX_PATH environment variable '$ENV{BOB_PREFIX_PATH}' and using '${BOB_PREFIX_PATH}' instead")
endif()
else()
set(BOB_PREFIX_PATH $ENV{BOB_PREFIX_PATH} CACHE STRING "Bob installation path" FORCE)
set(BOB_PREFIX_PATH $ENV{BOB_PREFIX_PATH} CACHE STRING "Bob installation prefix path" FORCE)
endif()
endif()
......
......@@ -58,7 +58,7 @@ Later, you can use three CMake_ variables ``Bob_INCLUDE_DIRS``, ``Bob_LIBRARY_DI
# create an "my_test" executable from file "test.cpp"
add_executable(my_test test.cpp)
For some reason (that I do not understand) we also need to add the ``boost_system`` library, although it shoud theoretically be linked to the Bob_ libraries already.
For some reason (that I do not understand) we also need to add the ``boost_system`` library, although it should theoretically be linked to the Bob_ libraries already.
So, now we can go ahead and compile our package using CMake_::
......@@ -70,9 +70,19 @@ So, now we can go ahead and compile our package using CMake_::
and we should get an executable ``my_test`` inside the build directory.
Note that you can pass a variable to CMake to use a custom Bob_ installation::
$ cmake -DBOB_PREFIX_PATH=/path/to/your/bob/installation
$ cmake .. -DBOB_PREFIX_PATH=/path/to/your/bob/installation
or set the ``BOB_PREFIX_PATH`` environment variable accordingly.
If you have a local directory containing (some of) the Bob packages inside ``src`` or ``eggs`` sub-directories, you can set the ``BOB_SOURCE_DIR`` variable, which defaults to the directory where the ``CMakeLists.txt`` is located::
$ cmake .. -DBOB_SOURCE_DIR=/path/to/your/local/bob/packages
The evaluation order of the directories is:
1. ``${BOB_SOURCE_DIR}/src``
2. ``${BOB_SOURCE_DIR}/eggs``
3. ``${BOB_PREFIX_PATH}/lib/*/site-packages`` (where * typically is your python version)
4. the system path
To run the example, go back to the package base directory (otherwise it will not find the example image) and call::
......
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