Commit d9bea86c authored by heretiK's avatar heretiK
Browse files

Fix bug preventing compilation to success

parent d1539695
cmake_minimum_required( VERSION 3.6 )
cmake_minimum_required( VERSION 3.0 )
project( prototypator )
......@@ -9,10 +9,8 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
add_compile_options(-Wall -Wextra -pedantic -Werror -Weffc++)
endif()
find_package( Boost REQUIRED )
find_package( Boost )
include_directories( ${Boost_INCLUDE_DIRS} )
add_executable( ${PROJECT_NAME} main.cpp )
target_link_libraries( ${PROJECT_NAME} ${Boost_LIBRARIES} stdc++fs )
......@@ -6,7 +6,6 @@ set( CMAKE_AUTOUIC ON )
set( CMAKE_AUTORCC ON )
set( CMAKE_INCLUDE_CURRENT_DIR ON )
find_package( Boost REQUIRED program_options regex )
find_package( Qt5Widgets REQUIRED )
find_package( Qt5LinguistTools REQUIRED )
......@@ -21,6 +20,6 @@ set( ${PROJECT_NAME}_SOURCES
qt5_create_translation( QM_FILES ${${PROJECT_NAME}_SOURCES} ${${PROJECT_NAME}_TS} )
# executable
include_directories( ${Boost_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/src )
include_directories( ${CMAKE_SOURCE_DIR}/src )
add_executable( ${PROJECT_NAME} ${${PROJECT_NAME}_SOURCES} ${QM_FILES} )
target_link_libraries( ${PROJECT_NAME} ${Boost_LIBRARIES} Qt5::Widgets stdc++fs )
target_link_libraries( ${PROJECT_NAME} Qt5::Widgets stdc++fs )
......@@ -33,13 +33,17 @@ void MainWindow::prepare()
throw std::runtime_error( "The program 'cmake' can't be found in the system." );
}
// erase directory
fs::remove_all( directory_ );
// create directory
const auto build_directory = directory_ / "build";
fs::create_directories( build_directory );
// copy files
QFile::copy( ":/resources/CMakeLists.txt", (directory_ / "CMakeLists.txt").c_str() );
QFile::copy( ":/resources/main.cpp", (directory_ / "main.cpp").c_str() );
QFile::copy( ":/resources/CMakeLists.txt", QString::fromStdString( directory_ / "CMakeLists.txt" ) );
QFile::copy( ":/resources/main.cpp", QString::fromStdString( directory_ / "main.cpp" ) );
fs::permissions( directory_ / "main.cpp", fs::perms::owner_write, fs::perm_options::add );
// run cmake
auto os = std::ostringstream{};
......@@ -47,7 +51,8 @@ void MainWindow::prepare()
errc = std::system( os.str().c_str() );
if( errc ) {
// TODO gestion des erreurs correctes
throw std::runtime_error( "The program 'cmake' failes" );
throw std::runtime_error( "The program"
" 'cmake' failes" );
}
// Great success !!
......@@ -72,7 +77,7 @@ void MainWindow::run()
// copy code
auto fos = std::ofstream{};
fos.exceptions( std::ifstream::failbit );
fos.open( (directory_ / "main.cpp").c_str(), std::ios_base::trunc );
fos.open( directory_ / "main.cpp", std::fstream::trunc );
fos << ui_ptr_->textEdit_code->toPlainText().toStdString();
fos.close();
......
......@@ -34,7 +34,7 @@
<translation></translation>
</message>
<message>
<location filename="../src/prototypator/mainwindow.cpp" line="112"/>
<location filename="../src/prototypator/mainwindow.cpp" line="124"/>
<source>Process finished. Exit code: </source>
<translation></translation>
</message>
......
......@@ -34,7 +34,7 @@
<translation>Entrée/sortie</translation>
</message>
<message>
<location filename="../src/prototypator/mainwindow.cpp" line="112"/>
<location filename="../src/prototypator/mainwindow.cpp" line="124"/>
<source>Process finished. Exit code: </source>
<translation>Processus terminée. Code d&apos;erreur : </translation>
</message>
......
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