Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Plugins development => Topic started by: AndrewCot on August 08, 2022, 12:42:59 pm

Title: Alpha's Project exporter - added "working" CMAKE POC
Post by: AndrewCot on August 08, 2022, 12:42:59 pm
I have taken Alpha's old project exporter plugin and got it building and running with the latest code. I then added a CMAKE export option that is "working".
The code is available from the following GITHUB directory:
"working" means:I have loaded the following file and I was able to export the all of the targets in the project file to CMakeLists.txt files:
I was then tested the following two CMakeLists.txt files and were able to produce the libraries using the standard "cmake .." and "cmake --build ." manual steps in A MSYS2 Mingw64 bash shell:
Title: Re: Aplha's Project exporter - added "working" CMAKE POC
Post by: Miguel Gimenez on August 08, 2022, 01:31:52 pm
Thanks for posting, I think this is a very useful plugin and IMHO it should be in trunk long time ago. We can polish it later, if needed.
Title: Re: Aplha's Project exporter - added "working" CMAKE POC
Post by: killerbot on August 08, 2022, 04:11:00 pm
feel free to merge it into trunk
Title: Re: Aplha's Project exporter - added "working" CMAKE POC
Post by: AndrewCot on August 09, 2022, 12:14:49 am
I still need to do the following for the CodeBlocks_Windows.cbp file:
1) Create a top level CMakeLists.txt file that builds all of the existing target CMakeLists.txt files.
2) make sure all of the rest of the targets build from the top level CMakeLists.txt
4) Ensure that I get a working Code::Blocks output

Then I need to see how it goes with the CodeBlocks_Windows.workspace file.
Where do you guys think the plugin will land? plugins or plugins/contrib? This way I can work on the project changes once I do the work above.
Title: Re: Aplha's Project exporter - added "working" CMAKE POC
Post by: Miguel Gimenez on August 09, 2022, 11:52:36 am
I prefer plugins/contrib.

I have just commited changes to the Macros Manager needed for the new plugin.
Title: Re: Aplha's Project exporter - added "working" CMAKE POC
Post by: AndrewCot on August 09, 2022, 12:14:00 pm
Thanks for making the changes to the macro manager.
Title: Re: Aplha's Project exporter - added "working" CMAKE POC
Post by: Miguel Gimenez on August 09, 2022, 01:08:56 pm
I am getting crashes in all RunExposrtXXX() methods, even if I comment the inner code.

The problem is wxMenuItems generate wxEVT_MENU events, not wxEVT_COMMAND_TOOL_CLICKED, and the connected method receives a reference to wxCommandEvent.

Code
    Connect(ID_Menu_AutotoolsExport, wxEVT_MENU, (wxObjectEventFunction)&ProjectExporter::RunExportAutotools);
    ...
void ProjectExporter::RunExportAutotools(wxCommandEvent& event)
(repeat for all methods)

Using a small project, for autotools I get:
Code
AM_OPTIONS_WXCONFIG
AM_PATH_WXCONFIG(3.1.0, wxWin=1)
    if test "$wxWin" != 1; then
        AC_MSG_ERROR([
            wxWidgets must be installed on your system.

            Please check that wx-config is in path, the directory
            where wxWidgets libraries are installed (returned by
            'wx-config --libs' or 'wx-config --static --libs' command)
            is in LD_LIBRARY_PATH or equivalent variable and
            wxWindows version is 3.1.0 or above.
        ])
    fi
Autotools build system created

For Bakefile I get 4 identical asserts:
Code
arrstr(558) iIndex != -1 failed in Remove()
and then a .bkl file is created in the project's home page (but there should be an informative message).
EDIT: this asserts are generated in EmitFlags(), calling wxArrayString::Remove() asserts if the string does not exist.

Premake shows two messages:
Code
Premake script exported
Premake script exported
and a .lua file is created in the project's home page (but there should be an informative message).

CMake shows this:
Code
RunExportCMake started
RunExportCMake started completed
but does not create anything.
Title: Re: Aplha's Project exporter - added "working" CMAKE POC
Post by: AndrewCot on August 11, 2022, 12:44:00 am
Thanks for the testing and feedback. I am working on getting the plugin incorporated into all of the build steps for all of the different processes.

I have not tested or used any of Alpha's existing export options as I am more interested in exporting to CMake. I will get to the feedback in a few days time.

What project/workspace were you using for the tests? This way when I get to look at the issues I can try the same file in case it has something that I have not catered for in the CMake exporter.

Title: Re: Aplha's Project exporter - added "working" CMAKE POC
Post by: ollydbg on August 11, 2022, 07:10:50 am
I see the code is now switched to this folder, so the web link in the first post should be adjusted.

https://github.com/acotty/CodeBlocks_Unofficial_Testing/blob/master/src/plugins/contrib/ProjectExporter/CMakeListsExporter.cpp

and good work!
Title: Re: Aplha's Project exporter - added "working" CMAKE POC
Post by: AndrewCot on August 11, 2022, 09:21:32 am
It gets a bit more complex as I now have a branch on the my Github SF mirror fork and updated the build files so the plugin now builds against this SF Trunk mirror. I have updated the branch to build on the following processes, which I have also checked load the plugin:I have not had time to test the Linux Debian build process as it takes a few hours from start to finish and in 95+% of cases if the Linux boostrap/configure/make works then the Debian build also works, apart from if I have made mistake(s) in the files in the Debian directory as the build process under the hood is the same as far as I have seen.


The github SF CB mirror branch with the changes is:This branch is the equivalent of the SF SVN trunk from 24 hrs ago (r12860) with the build and source changes for the plugin. The mirror is normally updated between 4 and 24 hrs after any SF changes, but sometimes (once every month or two) it can lag by 36 to 48 hrs. Worst I have sen it in the last year is 3 days when there were internet backbone issues in the USA.

If nothing else pops up I can start to look at Miguel's feedback tomorrow.
Title: Re: Aplha's Project exporter - added "working" CMAKE POC
Post by: Miguel Gimenez on August 11, 2022, 11:17:03 am
I made some changes to the Alpha's part addressing my findings, and was planning to make a PR in your Github on Saturday (I have never created one).

You have moved the code, how can I send patches or PR now?
Title: Re: Aplha's Project exporter - added "working" CMAKE POC
Post by: AndrewCot on August 11, 2022, 11:41:12 am
Miguel,

For the time being do not worry about which repo or branch to apply the PR to as I can manually make the changes at worst case and make sure they get applied. I remember my first PR was a complete disaster (it a number of updates to get only the files I wanted in the PR and then a few more to get the version I wanted and then it was not on the right branch etc etc), so you should do allot better than me.  If you do the PR today/tonight your time even if it is not finished it will help me tomorrow as I will be working on the updates/fixes then. I have finished doing anything more for today.

Eventually you should/will need to clone/fork the https://github.com/acotty/codeblocks_sfmirror/tree/ProjectExporter (https://github.com/acotty/codeblocks_sfmirror/tree/ProjectExporter) branch as it will allow you to compare the changes against the SF source to see what has changed to get the plugin building for the different builds.

Since my last post I have checked that the Debian build completes and produces the DEB files, but unfortunately I cannot check the resulting files as they will overwrite my currently install C::B and I do not want to do this at this point in time.
Title: Re: Aplha's Project exporter - added "working" CMAKE POC
Post by: Miguel Gimenez on August 11, 2022, 09:46:05 pm
These are the files I have changed, basically they remove the crash (I do not know why you did not get it...), take care of translations and unify the logging (removing duplicated messages).

Your CBP file using variables is the way to go, but meanwhile I have created two MSW projects similar to the rest.
Title: Re: Alpha's Project exporter - added "working" CMAKE POC
Post by: AndrewCot on August 12, 2022, 09:46:09 am
Miguel, Thanks for the zip file. So you have a way of making formatting changes that you have done (exclude the wxt _ etc changes) without manually making the changes? If you do can you let me know how you do it and the config files so I can ensure that the source code is the same.
I have made more CMake fixes/updates/enhancements and the resulting CMake ouput from the CodeBlocks_Windows.cbp I use is shown below. The updated code now outputs a top level CMakeLists.txt file that now references the target's in the CBP file. It still has a way to go, but it is progressing in the right direction.

Code
andrew@DESKTOP-5700G MINGW64 /D/Andrew_Development/Z_Testing_Apps/CB_SRC/build
$ cmake ..
-- Configuring done
-- Generating done
-- Build files have been written to: D:/Andrew_Development/Z_Testing_Apps/CB_SRC/build

andrew@DESKTOP-5700G MINGW64 /D/Andrew_Development/Z_Testing_Apps/CB_SRC/build
$ cmake ..
-- Building for: Ninja
-- The C compiler identification is GNU 12.1.0
-- The CXX compiler identification is GNU 12.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/msys64/mingw64/bin/cc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/msys64/mingw64/bin/c++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: D:/Andrew_Development/Z_Testing_Apps/CB_SRC/build

andrew@DESKTOP-5700G MINGW64 /D/Andrew_Development/Z_Testing_Apps/CB_SRC/build
$ cmake --build .
[1/470] Building CXX object base/tinyxml/CMakeFiles/tinyXML.dir/tinystr.cpp.obj
[2/470] Building CXX object base/tinyxml/CMakeFiles/tinyXML.dir/tinyxmlerror.cpp.obj
[3/470] Building CXX object sdk/scripting/squirrel/CMakeFiles/Squirrel.dir/__/sqstdlib/sqstdaux.cpp.obj
[4/470] Building CXX object sdk/scripting/squirrel/CMakeFiles/Squirrel.dir/__/sqstdlib/sqstdsystem.cpp.obj
[5/470] Building CXX object sdk/scripting/squirrel/CMakeFiles/Squirrel.dir/__/sqstdlib/sqstdio.cpp.obj
[6/470] Building CXX object sdk/scripting/squirrel/CMakeFiles/Squirrel.dir/__/sqstdlib/sqstdstring.cpp.obj
[7/470] Building CXX object sdk/scripting/squirrel/CMakeFiles/Squirrel.dir/__/sqstdlib/sqstdrex.cpp.obj
[8/470] Building CXX object sdk/scripting/squirrel/CMakeFiles/Squirrel.dir/__/sqstdlib/sqstdblob.cpp.obj
[9/470] Building CXX object sdk/scripting/squirrel/CMakeFiles/Squirrel.dir/__/sqstdlib/sqstdstream.cpp.obj
[10/470] Building CXX object base/tinyxml/CMakeFiles/tinyXML.dir/tinyxmlparser.cpp.obj
[11/470] Building CXX object sdk/scripting/squirrel/CMakeFiles/Squirrel.dir/sqmem.cpp.obj
[12/470] Building CXX object sdk/scripting/squirrel/CMakeFiles/Squirrel.dir/sqdebug.cpp.obj
[13/470] Building CXX object sdk/scripting/squirrel/CMakeFiles/Squirrel.dir/sqclass.cpp.obj
[14/470] Building CXX object sdk/scripting/squirrel/CMakeFiles/Squirrel.dir/__/sqstdlib/sqstdmath.cpp.obj
[15/470] Building CXX object base/tinyxml/CMakeFiles/tinyXML.dir/tinyxml.cpp.obj
[16/470] Building CXX object sdk/scripting/squirrel/CMakeFiles/Squirrel.dir/sqtable.cpp.obj
[17/470] Building CXX object sdk/scripting/squirrel/CMakeFiles/Squirrel.dir/sqbaselib.cpp.obj
[18/470] Building CXX object sdk/scripting/squirrel/CMakeFiles/Squirrel.dir/sqlexer.cpp.obj
[19/470] Building CXX object sdk/scripting/squirrel/CMakeFiles/Squirrel.dir/sqfuncstate.cpp.obj
[20/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexA68k.cxx.obj
[21/470] Building CXX object sdk/scripting/squirrel/CMakeFiles/Squirrel.dir/sqapi.cpp.obj
[22/470] Building CXX object sdk/scripting/squirrel/CMakeFiles/Squirrel.dir/sqstate.cpp.obj
[23/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexAPDL.cxx.obj
[24/470] Building CXX object sdk/scripting/squirrel/CMakeFiles/Squirrel.dir/sqcompiler.cpp.obj
[25/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexASY.cxx.obj
[26/470] Building CXX object sdk/scripting/squirrel/CMakeFiles/Squirrel.dir/sqobject.cpp.obj
[27/470] Building CXX object base/tinyxml2/CMakeFiles/tinyXML2.dir/tinyxml2.cpp.obj
[28/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexAVE.cxx.obj
[29/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexAU3.cxx.obj
[30/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexAVS.cxx.obj
[31/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexAbaqus.cxx.obj
[32/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexAsn1.cxx.obj
[33/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexBatch.cxx.obj
[34/470] Linking CXX static library base\tinyxml\libtinyXML.a
[35/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexBullant.cxx.obj
[36/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexBash.cxx.obj
[37/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexCOBOL.cxx.obj
[38/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexCLW.cxx.obj
[39/470] Linking CXX static library base\tinyxml2\libtinyXML2.a
[40/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexCSS.cxx.obj
[41/470] Building CXX object sdk/scripting/squirrel/CMakeFiles/Squirrel.dir/sqvm.cpp.obj
[42/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexCaml.cxx.obj
[43/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexAda.cxx.obj
[44/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexCmake.cxx.obj
[45/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexConf.cxx.obj
[46/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexCrontab.cxx.obj
[47/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexCoffeeScript.cxx.obj
[48/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexCsound.cxx.obj
[49/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexBibTeX.cxx.obj
[50/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexDMIS.cxx.obj
[51/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexDMAP.cxx.obj
[52/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexDiff.cxx.obj
[53/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexAsm.cxx.obj
[54/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexBasic.cxx.obj
[55/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexEDIFACT.cxx.obj
[56/470] Building CXX object build_tools/autorevision/CMakeFiles/AutoRevision.dir/autorevision.cpp.obj
[57/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexEScript.cxx.obj
[58/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexEiffel.cxx.obj
[59/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexBaan.cxx.obj
[60/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexForth.cxx.obj
[61/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexErrorList.cxx.obj
[62/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexFlagship.cxx.obj
[63/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexErlang.cxx.obj
[64/470] Linking CXX static library sdk\scripting\squirrel\libSquirrel.a
[65/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexGAP.cxx.obj
[66/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexGui4Cli.cxx.obj
[67/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexFortran.cxx.obj
[68/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexIndent.cxx.obj
[69/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexInno.cxx.obj
[70/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexHex.cxx.obj
[71/470] Building CXX object tools/ConsoleRunner/CMakeFiles/ConsoleRunner.dir/main.cpp.obj
[72/470] Linking CXX executable build_tools\autorevision\AutoRevision.exe
FAILED: build_tools/autorevision/AutoRevision.exe
cmd.exe /C "cd . && C:\msys64\mingw64\bin\c++.exe -Wall -std=gnu++17 -m64 -g -O0 -ggdb -pipe -fmessage-length=0 -fexceptions -Winvalid-pch -s -m64 build_tools/autorevision/CMakeFiles/AutoRevision.dir/autorevision.cpp.obj -o build_tools\autorevision\AutoRevision.exe -Wl,--out-implib,build_tools\autorevision\libAutoRevision.dll.a -Wl,--major-image-version,0,--minor-image-version,0 -LD:/Andrew_Development/Libraries/wxWidgets-3.2.0_win64/lib/gcc_dll   -LD:/Andrew_Development/Z_Testing_Apps/CB_SRC/devel32_64 -lwxmsw32u  -ltxml  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && cd ."
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -ltxml: No such file or directory
collect2.exe: error: ld returned 1 exit status
[73/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexKix.cxx.obj
[74/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexKVIrc.cxx.obj
[75/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexECL.cxx.obj
[76/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexLisp.cxx.obj
[77/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexD.cxx.obj
[78/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexLout.cxx.obj
[79/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexHTML.cxx.obj
[80/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexMMIXAL.cxx.obj
[81/470] Linking CXX executable tools\ConsoleRunner\ConsoleRunner.exe
[82/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexLua.cxx.obj
[83/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexLaTeX.cxx.obj
[84/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexMPT.cxx.obj
[85/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexHaskell.cxx.obj
[86/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexJSON.cxx.obj
[87/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/scintilla/lexers/LexCPP.cxx.obj
[88/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/ScintillaWX.cpp.obj
[89/470] Building CXX object sdk/wxscintilla/src/CMakeFiles/scintilla.dir/PlatWX.cpp.obj
ninja: build stopped: subcommand failed.

The updated source is in the repo's.
I have updated the /src/plugins/contrib/ProjectExporter/Readme_Project_Exporter.md file to include all of the info and issues I could find along with a table for testing once it gets further down th road.

Title: Re: Alpha's Project exporter - added "working" CMAKE POC
Post by: Miguel Gimenez on August 12, 2022, 11:28:09 am
These are the changes I made. Apart from fixing the event handlers, I added some _() (did not remove wxT) and fixed "RunExportCMake started completed" removing the "started"

EDIT: also fixed the Log entries for Premake, moving them to ProjectExporter.cpp and removing the duplicated call to Log().
Title: Re: Alpha's Project exporter - added "working" CMAKE POC
Post by: Miguel Gimenez on August 12, 2022, 11:59:30 am
The problem with asserts in bakefiles is inside EmitFlags(): Calling wxArrayString::Remove() asserts if the string does not exist.

IMHO the best solution for this issue is creating a wxLogNull object at the start of EmitFlags().
Title: Re: Alpha's Project exporter - added "working" CMAKE POC
Post by: AndrewCot on August 14, 2022, 05:16:52 am
I just stumbled across cacb's post about New plugin: Premake5 exporter (premake5cb) (https://forums.codeblocks.org/index.php/topic,24581.msg167777.html#msg167777) and as such I have added to the list of outstanding items updating the plugin from Premake4 to Premake5.
Title: Re: Alpha's Project exporter - added "working" CMAKE POC
Post by: AndrewCot on October 07, 2022, 03:11:00 am
While waiting for DAP debugger feedback I have gone back to the project exporter and made allot of progress with the CMAKE export feature.


I have  been able to take the C::B Windows workspace I use and export it to a set of CMAKE CMakeLists.txt & associated include files etc that can then be processed by CMAKE. To do this the SpellChecker & SmartIndent projects needed to be massaged by moving files and creating directories as the export was trying to create two or more CMakeLists.txt files in the one directory and as such the second one overwrote the first one as each target is output to a CMakeLists.txt file and these two projects had multiple target source files in the same root directory.

I am stuck with a "C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/12.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: final link failed: file truncated" error, but  I cannot figure out which file is causing the error as it's with the codeblocks.exe link and there are allot of files being linked. Attached is the build log. The error occurs if I use the default cmake or if I produce and build using make, so I do not think it's a problem with ninja or make.

Anyone got any ideas on how I can find the root cause of the failure?
Title: Re: Alpha's Project exporter - added "working" CMAKE POC
Post by: AndrewCot on October 07, 2022, 05:18:52 am
I figured it out.
Title: Re: Alpha's Project exporter - added "working" CMAKE POC
Post by: AndrewCot on October 17, 2022, 10:59:15 am
I have successfully used the new Export plugin CMAKE facility to rebuild a working C::B setup using CMAKE from the source in the https://github.com/acotty/CodeBlocks_Unofficial_Testing (https://github.com/acotty/CodeBlocks_Unofficial_Testing/blob/master/src/plugins/contrib/ProjectExporter/CMakeListsExporter.cpp) repo.
The following are the simple steps I use to build C::B is using CMAKE
    cmake  -DCMAKE_BUILD_TYPE=Release ..
    cmake --build .
If you are using a command prompt you need to add the directory where cmake.exe to the path. You may find that you need to install ninja if you have not already installed it as it is the default cmake build system

You will need to copy the following DLL's into the devel32_64 directory in order to run C::B and the plugins:
Title: Re: Alpha's Project exporter - added "working" CMAKE POC
Post by: ollydbg on October 18, 2022, 05:00:50 pm
I have successfully used the new Export plugin CMAKE facility to rebuild a working C::B setup using CMAKE from the source in the https://github.com/acotty/CodeBlocks_Unofficial_Testing (https://github.com/acotty/CodeBlocks_Unofficial_Testing/blob/master/src/plugins/contrib/ProjectExporter/CMakeListsExporter.cpp) repo.
The following are the simple steps I use to build C::B is using CMAKE
  • Build C::B from the repo and install it
  • Open the new C::B and load the CodeBlocks_Windows.workspace from the repo
  • Select the File->Export project->CMakeLists.txt (WIP) menu item
  • Create a src\Cmake_build directory
  • Open a command prompt or a bash shell and change into the src\Cmake_build directory
  • run the following two command to do the build:
    cmake  -DCMAKE_BUILD_TYPE=Release ..
    cmake --build .
If you are using a command prompt you need to add the directory where cmake.exe to the path. You may find that you need to install ninja if you have not already installed it as it is the default cmake build system

Good work.

My silly question is: does the generated CMakeLists.txt has many hard-coded paths in it? If not, can you just add those CMakeLists.txt to your git repo, so people can use it directly? I mean just clone your git repo, and run the cmake to build the whole C::B workspace.

Thanks.
Title: Re: Alpha's Project exporter - added "working" CMAKE POC
Post by: AndrewCot on October 18, 2022, 11:25:02 pm
My silly question is: does the generated CMakeLists.txt has many hard-coded paths in it? If not, can you just add those CMakeLists.txt to your git repo, so people can use it directly? I mean just clone your git repo, and run the cmake to build the whole C::B workspace.
Unfortunately the answer is yes. I need to do more work on the paths so that eventually (hopefully) remove all the hard coded paths. I am finding that CMake has so many options and it takes a while to figure out which option(s) to use to get the desired result as the CMake manual is not very intuitive for CMake noobs like me.
Title: Re: Alpha's Project exporter - added "working" CMAKE POC
Post by: sodev on October 19, 2022, 05:17:25 pm
The CMake manual is not really useful for learning CMake, but it's a great reference once you know CMake. To start learning CMake, forget about policies, use the latest available version and don't care about anything before. A really good resource to learn Modern CMake is this book: Professional CMake: A Practical Guide (https://crascit.com/professional-cmake/).
Title: Re: Alpha's Project exporter - added "working" CMAKE POC
Post by: AndrewCot on October 20, 2022, 09:59:31 am
Update the code to remove the hard coded paths, but I will not be including the CMakeLists.txt and other include CMakeLists*.txt files in the GIT repo as then it just adds to the time it takes to keep everything in sync (it's bad enough with the C::B official code having so many different project files that need to be updated for a single change......).