From 8b35ed5f923dc20ccb048b5aa5b2f1d7131ce8ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Okan=20A=C5=9F=C4=B1k?= Date: Tue, 12 Sep 2017 12:58:35 +0300 Subject: [PATCH 1/3] install glade file to general glade path, get cmake variables through a c++ class, fix broken library path after moving install prefix to /opt/jderobot --- src/tools/visualStates/CMakeLists.txt | 26 ++++++++++++------------- src/tools/visualStates/cmakevars.hpp | 18 +++++++++++++++++ src/tools/visualStates/cmakevars.hpp.in | 18 +++++++++++++++++ src/tools/visualStates/generate.cpp | 19 +++++++++--------- 4 files changed, 59 insertions(+), 22 deletions(-) create mode 100644 src/tools/visualStates/cmakevars.hpp create mode 100644 src/tools/visualStates/cmakevars.hpp.in diff --git a/src/tools/visualStates/CMakeLists.txt b/src/tools/visualStates/CMakeLists.txt index 9f49a5389..9bec366cb 100644 --- a/src/tools/visualStates/CMakeLists.txt +++ b/src/tools/visualStates/CMakeLists.txt @@ -81,29 +81,34 @@ TARGET_LINK_LIBRARIES ( visualStateslib ${GLOG_LIBRARIES} ) +configure_file( + cmakevars.hpp.in + cmakevars.hpp + @ONLY +) + add_custom_command(TARGET visualStates POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/gui $/gui) - install(TARGETS visualStates DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/ - COMPONENT tools - ) + COMPONENT tools) + + install(TARGETS visualStateslib + DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/ + COMPONENT tools) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/getinterfaces.sh PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) - INSTALL (FILES ${GLADE_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/jderobot/glade/visualStates) - # Install Glade FILE(GLOB_RECURSE GLADE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/gui/*.glade) - INSTALL (FILES ${GLADE_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/jderobot/glade/visualStates) + INSTALL (FILES ${GLADE_FILES} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/jderobot/glade) # install resources (jderobot logo) INSTALL (FILES ${CMAKE_CURRENT_SOURCE_DIR}/resources/jderobot.png DESTINATION ${CMAKE_INSTALL_PREFIX}/share/jderobot/resources) - # Install C++ Headers FILE(GLOB h_files "${CMAKE_CURRENT_SOURCE_DIR}/*.h") INSTALL(FILES ${h_files} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/jderobot/visualStates) @@ -111,13 +116,8 @@ add_custom_command(TARGET visualStates POST_BUILD FILE(GLOB h_files "${CMAKE_CURRENT_SOURCE_DIR}/popups/*.h") INSTALL(FILES ${h_files} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/jderobot/visualStates/popups) - # Install Python Files FILE(GLOB p_files "${CMAKE_CURRENT_SOURCE_DIR}/*.py") INSTALL(FILES ${p_files} DESTINATION ${CMAKE_INSTALL_PREFIX}/share/jderobot/python/visualStates_py) -ENDIF() - - - - +ENDIF() \ No newline at end of file diff --git a/src/tools/visualStates/cmakevars.hpp b/src/tools/visualStates/cmakevars.hpp new file mode 100644 index 000000000..fb75e6a33 --- /dev/null +++ b/src/tools/visualStates/cmakevars.hpp @@ -0,0 +1,18 @@ +// +// Created by okan on 11.09.2017. +// + +#ifndef JDEROBOT_CMAKEVARS_H +#define JDEROBOT_CMAKEVARS_H + +#include + +class CMakeVars { +public: + static const std::string& getInstallPrefix() { + static std::string installPrefix("/opt/jderobot"); + return installPrefix; + } +}; + +#endif //JDEROBOT_CMAKEVARS_H diff --git a/src/tools/visualStates/cmakevars.hpp.in b/src/tools/visualStates/cmakevars.hpp.in new file mode 100644 index 000000000..4b71adbe2 --- /dev/null +++ b/src/tools/visualStates/cmakevars.hpp.in @@ -0,0 +1,18 @@ +// +// Created by okan on 11.09.2017. +// + +#ifndef JDEROBOT_CMAKEVARS_H +#define JDEROBOT_CMAKEVARS_H + +#include + +class CMakeVars { +public: + static const std::string& getInstallPrefix() { + static std::string installPrefix("@CMAKE_INSTALL_PREFIX@"); + return installPrefix; + } +}; + +#endif //JDEROBOT_CMAKEVARS_H diff --git a/src/tools/visualStates/generate.cpp b/src/tools/visualStates/generate.cpp index 8489819ee..093d05c7f 100644 --- a/src/tools/visualStates/generate.cpp +++ b/src/tools/visualStates/generate.cpp @@ -21,6 +21,7 @@ */ #include "generate.h" +#include "cmakevars.hpp" /************************************************************* * CONSTRUCTOR @@ -637,10 +638,10 @@ void Generate::generateCmake () { this->fs << std::endl; this->fs << "pkg_check_modules(GTKMM REQUIRED gtkmm-3.0)" << std::endl; this->fs << std::endl; - this->fs << "SET( INTERFACES_CPP_DIR /opt/jderobot/include )" << std::endl; - this->fs << "SET( LIBS_DIR /usr/local/lib )" << std::endl; - this->fs << "SET( JDEROBOT_LIBS_DIR /opt/jderobot/lib )" << std::endl; - this->fs << "SET( easyiceconfig_LIBRARIES ${JDEROBOT_LIBS_DIR}/jderobot/libeasyiceconfig.so)" << std::endl; + this->fs << "SET( INTERFACES_CPP_DIR "<< CMakeVars::getInstallPrefix() << "/include )" << std::endl; + this->fs << "SET( LIBS_DIR "<< CMakeVars::getInstallPrefix() << "/lib )" << std::endl; + this->fs << "SET( JDEROBOT_LIBS_DIR " << CMakeVars::getInstallPrefix() << "/lib )" << std::endl; + this->fs << "SET( easyiceconfig_LIBRARIES ${JDEROBOT_LIBS_DIR}/libeasyiceconfig.so)" << std::endl; this->fs << std::endl; this->fs << "SET( CMAKE_CXX_FLAGS \"-pthread\" ) # Opciones para el compilador" << std::endl; this->fs << std::endl; @@ -653,7 +654,7 @@ void Generate::generateCmake () { this->fs << ")" << std::endl; this->fs << std::endl; this->fs << "include_directories (" << std::endl; - this->fs << "\t/opt/jderobot/include/jderobot" << std::endl; + this->fs << "\t" << CMakeVars::getInstallPrefix() << "/include/jderobot" << std::endl; this->fs << "\t${INTERFACES_CPP_DIR}" << std::endl; this->fs << "\t${easyiceconfig_INCLUDE_DIRS}" << std::endl; this->fs << "\t${LIBS_DIR}" << std::endl; @@ -675,9 +676,9 @@ void Generate::generateCmake () { this->fs << "\t${GTKMM_LIBRARIES}" << std::endl; this->fs << "\t${easyiceconfig_LIBRARIES}" << std::endl; this->fs << "\t${goocanvasmm_LIBRARIES}" <fs << "\t${JDEROBOT_LIBS_DIR}/jderobot/libvisualStateslib.so" << std::endl; - this->fs << "\t${JDEROBOT_LIBS_DIR}/jderobot/libJderobotInterfaces.so" << std::endl; - this->fs << "\t${JDEROBOT_LIBS_DIR}/jderobot/libjderobotutil.so" << std::endl; + this->fs << "\t${JDEROBOT_LIBS_DIR}/libvisualStateslib.so" << std::endl; + this->fs << "\t${JDEROBOT_LIBS_DIR}/libJderobotInterfaces.so" << std::endl; + this->fs << "\t${JDEROBOT_LIBS_DIR}/libjderobotutil.so" << std::endl; this->fs << "\tIce" << std::endl; this->fs << "\tIceUtil" << std::endl; this->fs << ")" << std::endl; @@ -705,7 +706,7 @@ void Generate::generateGenericHeaders_py(){ import Ice\n\ import easyiceconfig as EasyIce\n\ import sys, signal\n\ -sys.path.append('/opt/jderobot/share/jderobot/python/visualStates_py')\n\ +sys.path.append('" << CMakeVars::getInstallPrefix() << "/share/jderobot/python/visualStates_py')\n\ import traceback, threading, time\n\ from automatagui import AutomataGui, QtGui, GuiSubautomata\n\n"; From 781c5d249dcde102d679ce4488ee200c9b6066e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Okan=20A=C5=9F=C4=B1k?= Date: Tue, 12 Sep 2017 15:35:37 +0300 Subject: [PATCH 2/3] remove the generated file to prevent misunderstanding --- src/tools/visualStates/cmakevars.hpp | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 src/tools/visualStates/cmakevars.hpp diff --git a/src/tools/visualStates/cmakevars.hpp b/src/tools/visualStates/cmakevars.hpp deleted file mode 100644 index fb75e6a33..000000000 --- a/src/tools/visualStates/cmakevars.hpp +++ /dev/null @@ -1,18 +0,0 @@ -// -// Created by okan on 11.09.2017. -// - -#ifndef JDEROBOT_CMAKEVARS_H -#define JDEROBOT_CMAKEVARS_H - -#include - -class CMakeVars { -public: - static const std::string& getInstallPrefix() { - static std::string installPrefix("/opt/jderobot"); - return installPrefix; - } -}; - -#endif //JDEROBOT_CMAKEVARS_H From 7e4032005557ca1156727d17bab56120c4795a07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Okan=20A=C5=9F=C4=B1k?= Date: Thu, 14 Sep 2017 00:30:18 +0300 Subject: [PATCH 3/3] to be able to access cmakevar.hpp add build directory to include directories --- src/tools/visualStates/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tools/visualStates/CMakeLists.txt b/src/tools/visualStates/CMakeLists.txt index 9bec366cb..5ea33e73a 100644 --- a/src/tools/visualStates/CMakeLists.txt +++ b/src/tools/visualStates/CMakeLists.txt @@ -49,6 +49,7 @@ link_directories( ) include_directories ( + ${CMAKE_CURRENT_BINARY_DIR} ${INTERFACES_CPP_DIR} ${LIBS_DIR} ${CMAKE_CURRENT_SOURCE_DIR}