|
56 | 56 | #include "AsyncProcess/processreaderthread.h" |
57 | 57 | #include "CMakeBuilder.h" |
58 | 58 | #include "ICompilerLocator.h" |
59 | | -#include "StdToWX.h" |
60 | 59 | #include "StringUtils.h" |
61 | 60 | #include "build_config.h" |
62 | 61 | #include "environmentconfig.h" |
@@ -515,11 +514,10 @@ bool CMakePlugin::IsCMakeListsExists() const |
515 | 514 | return false; |
516 | 515 | } |
517 | 516 |
|
518 | | -wxString CMakePlugin::WriteCMakeListsAndOpenIt(const std::vector<wxString>& lines) const |
| 517 | +wxString CMakePlugin::WriteCMakeListsAndOpenIt(const wxString& lines) const |
519 | 518 | { |
520 | 519 | wxFileName cmakelists_txt{::wxGetCwd(), "CMakeLists.txt"}; |
521 | | - const wxArrayString wx_lines = StdToWX::ToArrayString(lines); |
522 | | - FileUtils::WriteFileContent(cmakelists_txt, wxJoin(wx_lines, '\n')); |
| 520 | + FileUtils::WriteFileContent(cmakelists_txt, lines); |
523 | 521 | clGetManager()->OpenFile(cmakelists_txt.GetFullPath()); |
524 | 522 | return cmakelists_txt.GetFullPath(); |
525 | 523 | } |
@@ -552,28 +550,30 @@ clStatusOr<wxString> CMakePlugin::CreateCMakeListsFile(CMakePlugin::TargetType t |
552 | 550 | return StatusOther("User cancelled"); |
553 | 551 | } |
554 | 552 |
|
555 | | - wxString cmakelists_txt = WriteCMakeListsAndOpenIt({ |
556 | | - "cmake_minimum_required(VERSION 3.16)", |
557 | | - wxString::Format("project(%s)", name), |
558 | | - wxEmptyString, |
559 | | - wxEmptyString, |
560 | | - "set(CMAKE_EXPORT_COMPILE_COMMANDS 1)", |
561 | | - "set(CMAKE_CXX_STANDARD 17)", |
562 | | - "set(CMAKE_CXX_STANDARD_REQUIRED ON)", |
563 | | - wxEmptyString, |
564 | | - "file(GLOB CXX_SRCS \"*.cpp\")", |
565 | | - "file(GLOB C_SRCS \"*.c\")", |
566 | | - wxEmptyString, |
567 | | - target_line, |
568 | | - "if(NOT ${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR})", |
569 | | - " add_custom_command(", |
570 | | - wxString::Format(" TARGET %s", name), |
571 | | - " POST_BUILD", |
572 | | - " COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/compile_commands.json", |
573 | | - " ${CMAKE_SOURCE_DIR}/compile_commands.json)", |
574 | | - "endif()", |
575 | | - wxEmptyString, |
576 | | - }); |
| 553 | + wxString cmakelists_txt = WriteCMakeListsAndOpenIt( |
| 554 | + wxString::Format("cmake_minimum_required(VERSION 3.16)\n" |
| 555 | + "project(%s)\n" |
| 556 | + "\n" |
| 557 | + "\n" |
| 558 | + "set(CMAKE_EXPORT_COMPILE_COMMANDS 1)\n" |
| 559 | + "set(CMAKE_CXX_STANDARD 17)\n" |
| 560 | + "set(CMAKE_CXX_STANDARD_REQUIRED ON)\n" |
| 561 | + "\n" |
| 562 | + "file(GLOB CXX_SRCS \"*.cpp\")\n" |
| 563 | + "file(GLOB C_SRCS \"*.c\")\n" |
| 564 | + "\n" |
| 565 | + "%s\n" |
| 566 | + "if(NOT ${CMAKE_BINARY_DIR} STREQUAL ${CMAKE_SOURCE_DIR})\n" |
| 567 | + " add_custom_command(\n" |
| 568 | + " TARGET %s\n" |
| 569 | + " POST_BUILD\n" |
| 570 | + " COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/compile_commands.json\n" |
| 571 | + " ${CMAKE_SOURCE_DIR}/compile_commands.json)\n" |
| 572 | + "endif()\n" |
| 573 | + "\n", |
| 574 | + name, |
| 575 | + target_line, |
| 576 | + name)); |
577 | 577 | return cmakelists_txt; |
578 | 578 | } |
579 | 579 |
|
|
0 commit comments