From 950cdc75258012d6a50d95ea559fc444c122e7e2 Mon Sep 17 00:00:00 2001 From: jcarpent <jcarpent@laas.fr> Date: Wed, 29 Apr 2015 10:50:36 +0200 Subject: [PATCH] [Fix bug][Python] Define flag in order to control Lua inclusion --- src/CMakeLists.txt | 8 ++++++++ src/python/parsers.hpp | 11 +++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ae99dfab1..b2fbed641 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -18,6 +18,11 @@ MACRO(ADD_SOURCE_GROUP FILENAMES) ADD_GROUP("Source Files" ${FILENAMES}) ENDMACRO(ADD_SOURCE_GROUP FILENAMES) +MACRO(ADD_TARGET_CFLAGS target flag) + GET_TARGET_PROPERTY(${target}_CFLAGS ${target} COMPILE_FLAGS) + SET_PROPERTY(TARGET ${target} PROPERTY COMPILE_FLAGS "${${target}_CFLAGS} ${flag}") +ENDMACRO(ADD_TARGET_CFLAGS) + # ---------------------------------------------------- # --- C++ -------------------------------------------- # ---------------------------------------------------- @@ -70,6 +75,9 @@ IF(EIGENPY_FOUND) TARGET_LINK_LIBRARIES(${PYWRAP} ${Boost_LIBRARIES} ${PROJECT_NAME}) SET_TARGET_PROPERTIES(${PYWRAP} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/python/${PROJECT_NAME}") + IF(LUA5_1_FOUND) + ADD_TARGET_CFLAGS (${PYWRAP} "-DWITH_LUA") + ENDIF(LUA5_1_FOUND) INSTALL(FILES "${CMAKE_BINARY_DIR}/lib/python/${PROJECT_NAME}/lib${PYWRAP}.so" DESTINATION ${PYTHON_SITELIB}/${PROJECT_NAME}) diff --git a/src/python/parsers.hpp b/src/python/parsers.hpp index ba48c52c7..fe6100ebe 100644 --- a/src/python/parsers.hpp +++ b/src/python/parsers.hpp @@ -8,7 +8,10 @@ #include "pinocchio/python/data.hpp" #include "pinocchio/multibody/parser/urdf.hpp" -#include "pinocchio/multibody/parser/lua.hpp" + +#ifdef WITH_LUA + #include "pinocchio/multibody/parser/lua.hpp" +#endif // #ifdef WITH_LUA namespace se3 { @@ -24,6 +27,7 @@ namespace se3 return ModelHandler(model,true); } +#ifdef WITH_LUA static ModelHandler buildModelFromLua(const std::string & filename, bool ff, bool verbose @@ -33,6 +37,7 @@ namespace se3 *model = se3::lua::buildModel (filename, ff, verbose); return ModelHandler (model,true); } +#endif // #ifdef WITH_LUA /* --- Expose --------------------------------------------------------- */ static void expose() @@ -43,17 +48,19 @@ namespace se3 "Parse the urdf file given in input and return a proper pinocchio model " "(remember to create the corresponding data structure)."); +#ifdef WITH_LUA bp::def("buildModelFromLua",buildModelFromLua, bp::args("Filename (string)", "Free flyer (bool, false for a fixed robot)", "Verbose option "), "Parse the urdf file given in input and return a proper pinocchio model " "(remember to create the corresponding data structure)."); +#endif // #ifdef WITH_LUA } }; }} // namespace se3::python -#endif // ifndef __se3_python_data_hpp__ +#endif // ifndef __se3_python_parsers_hpp__ -- GitLab