From: Leonardo Flórez-Valencia Date: Fri, 29 Sep 2017 19:37:34 +0000 (-0500) Subject: ... X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=53bbbb387faaa39779d9a24b0cd068a09cf14226;p=cpPlugins.git ... --- diff --git a/CMakeLists.txt b/CMakeLists.txt index cc162d4..819a52f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -49,9 +49,9 @@ if(VTK_FOUND) endif(VTK_FOUND) ## == Build packages -subdirs(lib) +subdirs(appli lib) ## == Installation commands -## include(cmake/InstallCommands.cmake) +include(cmake/InstallCommands.cmake) ## eof - $RCSfile$ diff --git a/appli/CMakeLists.txt b/appli/CMakeLists.txt new file mode 100644 index 0000000..f53d897 --- /dev/null +++ b/appli/CMakeLists.txt @@ -0,0 +1,10 @@ +## ========================================================================= +## @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co) +## ========================================================================= + +option(cpPlugins_BUILD_APPLICATIONS "Build applications" OFF) +if(cpPlugins_BUILD_APPLICATIONS) + subdirs(bash) +endif(cpPlugins_BUILD_APPLICATIONS) + +## eof - $RCSfile$ diff --git a/appli/bash/CMakeLists.txt b/appli/bash/CMakeLists.txt new file mode 100644 index 0000000..1eb9ad5 --- /dev/null +++ b/appli/bash/CMakeLists.txt @@ -0,0 +1,20 @@ +## ========================================================================= +## @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co) +## ========================================================================= + +## == List bash applications +set(_pfx cpPlugins_bash_) +set(_apps + CreateWin32Installer + ) + +## == Compile them +foreach(_a ${_apps}) + BuildApplication( + ${_pfx}${_a} + INSTALL + SOURCE ${_a}.cxx + ) +endforeach(_a) + +## eof - $RCSfile$ diff --git a/appli/bash/CreateWin32Installer.cxx b/appli/bash/CreateWin32Installer.cxx new file mode 100644 index 0000000..57874c9 --- /dev/null +++ b/appli/bash/CreateWin32Installer.cxx @@ -0,0 +1,133 @@ +/* ========================================================================= + * @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co) + * ========================================================================= + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// ------------------------------------------------------------------------- +void Split( const std::string& s, std::string& d, std::string& f ) +{ + size_t found = s.find_last_of( "/\\" ); + d = s.substr( 0, found ); + f = s.substr( found + 1 ); +} + +// ------------------------------------------------------------------------- +inline bool Exists( const std::string& name ) +{ + struct stat buffer; + return( stat( name.c_str( ), &buffer) == 0 ); +} + +// ------------------------------------------------------------------------- +std::string Exec( const std::string& cmd ) +{ + std::array< char, 128 > buffer; + std::string result; + std::shared_ptr< FILE > pipe( popen( cmd.c_str( ), "r" ), pclose ); + if( !pipe ) + throw std::runtime_error( "popen( ) failed!" ); + while( !feof( pipe.get( ) ) ) + if( fgets( buffer.data( ), 128, pipe.get( ) ) != NULL ) + result += buffer.data( ); + return( result ); +} + +// ------------------------------------------------------------------------- +int main( int argc, char* argv[] ) +{ + if( argc < 3 ) + { + std::cerr + << "Usage: " << argv[ 0 ] + << " entry_point objdump_tool [other_dir(s)]" + << std::endl; + return( 1 ); + + } // fi + std::string entry_point, objdump_tool; + std::set< std::string > dirs; + + if( !Exists( argv[ 1 ] ) ) + { + std::cerr + << "Error: file \"" << argv[ 1 ] << "\" does not exist." + << std::endl; + return( 1 ); + + } // fi + if( !Exists( argv[ 2 ] ) ) + { + std::cerr + << "Error: file \"" << argv[ 2 ] << "\" does not exist." + << std::endl; + return( 1 ); + + } // fi + + entry_point = realpath( argv[ 1 ], NULL ); + objdump_tool = realpath( argv[ 2 ], NULL ); + + std::string entry_point_dir, entry_point_file; + Split( entry_point, entry_point_dir, entry_point_file ); + + dirs.insert( entry_point_dir ); + for( int i = 3; i < argc; ++i ) + if( Exists( argv[ i ] ) ) + dirs.insert( std::string( realpath( argv[ i ], NULL ) ) ); + + std::set< std::string > files; + std::queue< std::string > q; + q.push( entry_point ); + while( !q.empty( ) ) + { + std::string e = q.front( ); + q.pop( ); + if( files.find( e ) == files.end( ) ) + { + try + { + if( Exists( e ) ) + { + std::istringstream ss( + Exec( objdump_tool + " -x " + e + " | grep DLL\\ Name" ) + ); + files.insert( e ); + std::string line; + while( std::getline( ss, line ) ) + { + size_t p = line.find( ":" ) + 2; + std::set< std::string >::const_iterator d; + for( d = dirs.begin( ); d != dirs.end( ); ++d ) + q.push( *d + "/" + line.substr( p ) ); + + } // elihw + + } // fi + } + catch( std::exception& err ) + { + // Just ignore + } // yrt + + } // fi + + } // elihw + + for( std::string f: files ) + std::cout << "---> " << f << std::endl; + + return( 0 ); +} + +// eof - $RCSfile$ diff --git a/cmake/Functions.cmake b/cmake/Functions.cmake index 53046e6..436494f 100644 --- a/cmake/Functions.cmake +++ b/cmake/Functions.cmake @@ -160,23 +160,52 @@ endif(BuildLibrary_INSTALL_DEV) endfunction() -### ------------------------------------------------------------------------- -#function(BuildApplication app) -#option(BUILD_${app} "Build ${app}" OFF) -#if(BUILD_${app}) -# ## -- Use a static library -# BuildLibraryRecursive( -# _${app}_ STATIC ${CMAKE_CURRENT_SOURCE_DIR} 0 0 0 ${ARGN} -# ) - -# ## -- Create an empty application -# set(_m ${CMAKE_CURRENT_BINARY_DIR}/__main__${app}.cxx) -# file(WRITE ${_m} "// Automatically generated dummy file") -# add_executable(${app} ${EXECUTABLE_TYPE} ${_m}) - -# ## -- Link it against static library -# target_link_libraries(${app} PUBLIC _${app}_) -#endif(BUILD_${app}) -#endfunction() +## ------------------------------------------------------------------------- +function(BuildApplication app) + +set(options INSTALL RECURRENT) +set(oneValueArgs) +set(multiValueArgs SOURCE LINKS) +cmake_parse_arguments( + BuildApplication "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} + ) + +set(_lib __lib__${app}) +if(BuildApplication_RECURRENT) + BuildLibrary( + ${_lib} STATIC + RECURRENT + SOURCE ${BuildApplication_SOURCE} + LINKS ${BuildApplication_LINKS} + ) +else(BuildApplication_RECURRENT) + BuildLibrary( + ${_lib} STATIC + SOURCE ${BuildApplication_SOURCE} + LINKS ${BuildApplication_LINKS} + ) +endif(BuildApplication_RECURRENT) + +## -- Create an empty application +set(_m ${CMAKE_CURRENT_BINARY_DIR}/__main__${app}.cxx) +file(WRITE ${_m} "// Automatically generated dummy file") +add_executable(${app} ${EXECUTABLE_TYPE} ${_m}) + +## -- Link it against the static library +target_link_libraries(${app} PUBLIC ${_lib}) + +## -- Installation rules +if(BuildApplication_INSTALL) + install( + TARGETS ${app} + EXPORT "${targets_export_name}" + LIBRARY DESTINATION "lib" + ARCHIVE DESTINATION "lib" + RUNTIME DESTINATION "bin" + INCLUDES DESTINATION "${include_install_dir}" + ) +endif(BuildApplication_INSTALL) + +endfunction() ## eof - $RCSfile$ diff --git a/install/prerrequisites.sh b/install/prerrequisites.sh new file mode 100644 index 0000000..59c83ac --- /dev/null +++ b/install/prerrequisites.sh @@ -0,0 +1,78 @@ + +../qt-5.9.1/configure \ + -prefix ~/local \ + -shared \ + -confirm-license \ + -opensource \ + -release \ + -c++std c++11 \ + -opengl desktop \ + -nomake examples \ + -nomake tests \ + -no-harfbuzz \ + -qt-xcb \ + -qt-xkbcommon \ + -qt-pcre \ + -skip qt3d \ + -skip qtactiveqt \ + -skip qtcanvas3d \ + -skip qtconnectivity \ + -skip qtdatavis3d \ + -skip qtdeclarative \ + -skip qtdoc \ + -skip qtgamepad \ + -skip qtgraphicaleffects \ + -skip qtimageformats \ + -skip qtlocation \ + -skip qtmultimedia \ + -skip qtnetworkauth \ + -skip qtpurchasing \ + -skip qtquickcontrols \ + -skip qtquickcontrols2 \ + -skip qtscript \ + -skip qtscxml \ + -skip qtsensors \ + -skip qtserialbus \ + -skip qtserialport \ + -skip qtspeech \ + -skip qtsvg \ + -skip qttranslations \ + -skip qtvirtualkeyboard \ + -skip qtwayland \ + -skip qtwebchannel \ + -skip qtwebengine \ + -skip qtwebsockets \ + -skip qtwebview \ + -skip qtxmlpatterns + +../cmake-3.8.2/bootstrap \ + --parallel=12 --prefix=~/local \ + --no-qt-gui + +~/local/bin/cmake \ + -DCMAKE_CXX_FLAGS:STRING=-std=c++11 \ + -DBUILD_SHARED_LIBS:BOOL=ON \ + -DCMAKE_BUILD_TYPE:STRING=Release \ + -DCMAKE_INSTALL_PREFIX:PATH=~/local \ + -DBUILD_DOCUMENTATION:BOOL=OFF \ + -DBUILD_EXAMPLES:BOOL=OFF \ + -DBUILD_TESTING:BOOL=OFF \ + -DVTK_Group_Qt:BOOL=ON \ + -DVTK_QT_VERSION:STRING=5 \ + -DQt5_DIR:PATH=~/local/lib/cmake/Qt5 \ + -DQT_QMAKE_EXECUTABLE:PATH=~/local/bin/qmake \ + -DModule_vtkGUISupportQtOpenGL:BOOL=ON \ + ../VTK-8.0.0 + +~/local/bin/cmake \ + -DCMAKE_CXX_FLAGS:STRING=-std=c++11 \ + -DBUILD_SHARED_LIBS:BOOL=ON \ + -DCMAKE_BUILD_TYPE:STRING=Release \ + -DCMAKE_INSTALL_PREFIX:PATH=~/local \ + -DBUILD_DOCUMENTATION:BOOL=OFF \ + -DBUILD_EXAMPLES:BOOL=OFF \ + -DBUILD_TESTING:BOOL=OFF \ + -DModule_ITKReview:BOOL=ON \ + -DModule_ITKVtkGlue:BOOL=ON \ + -DVTK_DIR:PATH=~/local/lib/cmake/vtk-8.0 \ + ../InsightToolkit-4.12.0