Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

1411589 Posts in 69386 Topics- by 58443 Members - Latest Member: Mansreign

May 06, 2024, 11:41:52 PM

Need hosting? Check out Digital Ocean
(more details in this thread)
TIGSource ForumsDeveloperTechnical (Moderator: ThemsAllTook)command line project management / auto makefile?
Pages: [1]
Print
Author Topic: command line project management / auto makefile?  (Read 2433 times)
Kekskiller
Guest
« on: August 01, 2010, 02:35:50 AM »

I'm used to code using Code::Blocks but I choosing another distribution instead of Ubuntu made me realize how awesome it'd be to completely drop all bulky development environments and use some buildin combination like make, enhanced gedit for editing etc. Only bothering me is how to archieve such nice things like automatic dependency generation for source files. In Code::BLocks there's an scanner building all dependencies and creating a makefile later. Does such a tool exist in the Linux world? I could also code my own one scanning for #include commands, but this might take some time to make and I originally wanted to start right. I'll need the time to prepare my environment for BIGJam.

So yea, I'm hopen to interesting concepts/ideas.
Logged
Draknek
Level 6
*


"Alan Hazelden" for short


View Profile WWW
« Reply #1 on: August 01, 2010, 02:52:01 AM »

The tool used in a lot of Linux projects is autoconf.

I believe CMake also includes dependency analysis.

Personally, I don't like either for my projects. I have a hand-written makefile (so that I know what's going on) that makes every .cpp file depend on every .h file.

This does mean some unnecessary compilation when you edit a .h file (the whole project is recompiled rather than just the parts which directly use it) but it has the advantage of being really simple.
Logged

Cimpresovec
Level 1
*


View Profile
« Reply #2 on: August 01, 2010, 04:08:32 AM »

Well I have Ubuntu but still prefer command line. I use Emacs for text management, I must say that, even if it is a text editor, it is better that Visual Studio and Code::Blocks. The only language based feature is colored text but it helps with brackets and is really nice to use.

For compilation I use a self made makefile, or just write the standard g++ compile command somewhere and then execute it. It isn't that time consuming as it seams.

But really check out Emacs. Some c++ tips for it can be found here: http://www.cs.bu.edu/teaching/tool/emacs/programming/
Logged

Programming is the closest thing I have to magic.
Kekskiller
Guest
« Reply #3 on: August 01, 2010, 04:55:10 AM »

The tool used in a lot of Linux projects is autoconf.

I believe CMake also includes dependency analysis.

autoconf seems a bit strange to me... I found a list on Wikipedia about make alternatives and will try to make my way through it (makepp looks interesting, has some automatic include scanners).

But really check out Emacs. Some c++ tips for it can be found here: http://www.cs.bu.edu/teaching/tool/emacs/programming/

Actually I don't want a new operating system. And I really, really hate line-based text editors (which I'm looking for, I'm looking for comfortable ways to automated project building/making).
Logged
BorisTheBrave
Level 10
*****


View Profile WWW
« Reply #4 on: August 01, 2010, 05:14:46 AM »

Personally, I don't like either for my projects. I have a hand-written makefile (so that I know what's going on) that makes every .cpp file depend on every .h file.

This does mean some unnecessary compilation when you edit a .h file (the whole project is recompiled rather than just the parts which directly use it) but it has the advantage of being really simple.
http://mad-scientist.net/make/autodep.htm
Essentially, use compiler switches to generate correct dependencies, with a separate dependency file per source file, and then have *those* files also have dependencies.

I use a variant of this for work, and I can vouch that it does actually work well in practise.
Logged
Kekskiller
Guest
« Reply #5 on: August 01, 2010, 07:08:29 AM »

Oh my fucking god, how can anybody only work with such horrible autmation tools like CMake, autoconf/automake, Waf and how they are all called. Damnit. Everything a new syntax and here a system plus some configs there... I'll probably use a makefile instead... Though I'm not the biggest friend of it. Still better than polluting your mind with personally unnecessary garbage.
Logged
Average Software
Level 10
*****

Fleeing all W'rkncacnter


View Profile WWW
« Reply #6 on: August 01, 2010, 09:45:38 AM »

I ended up writing a custom makefile generation script because I still can't figure out the GNU autotools.  That served my purposes until I switched to Ada, where gnatmake handles all of that for you.

Of particular interest should be GCC's -MM switch, which generates a makefile rule for the file you pass in.  Building a script around that switch really isn't too hard.

Nowadays when doing C++, I actually maintain my makefiles by hand.  This is more work, but I find I get better results than with any automated tool.  It also gives me a much clearer picture of where my dependency bottlenecks are.
Logged



What would John Carmack do?
tempestad
Level 0
**


View Profile
« Reply #7 on: August 01, 2010, 11:05:46 AM »

I personally recommend CMake, really easy to make the files needed, then CMake can generate different files, makefiles and kdevelop/eclipse/code::blocks/visual studio project files.

Let say you are starting a new project in Code::Blocks, you have to set the output directory for the binary files, the include directories (if any) where you have additional include files, the libraries dependency (at least once, then you can make a template out of this). Then for the source code you just add each to the project.

Using CMake is pretty much the same, except you have to write a file instead using a GUI (altough I think there is a GUI for CMake).

Here is a simple CMake file, still very useful:
Code:
#The directory where you have additional include files (you can use relative paths and there are some useful CMake variables that you can use).
include_directories(include)

# Let CMake found about all cpp files here (SRC is the variable).
file(GLOB SRC *.cpp)

# Create an executable of the files in SRC named project_name.
add_executable(project_name ${SRC})

# Link to the following libraries (some SFML libraries).
target_link_libraries(project_name sfml-system sfml-window sfml-graphics )

Then you can use CMake to build any of the projects I named before, just using this file. And of course, CMake has a lot of additional functions. You can ask questions when building for different options (as features, or build a debug or release version) and CMake sets the defines for you.

Also, using variables you can use a generic CMake file to build your next projects. Only by changing a very few variables, like your project name.
« Last Edit: August 01, 2010, 11:26:59 AM by tempestad » Logged
Theotherguy
Level 1
*



View Profile
« Reply #8 on: August 01, 2010, 11:14:15 AM »

I use CMake at work, and recommend it for huge projects. CMake has saved a lot of time for us in resolving dependencies across gigantic code repositories with different build requirements for each executable.

I'm not sure if it's worth it for small games, though.
Logged

Kekskiller
Guest
« Reply #9 on: August 01, 2010, 11:16:05 AM »

That sounds convincing, tempestad. Is there a short reference for all commands/actions I can use that isn't a textheavy tutorial? If it's such a nice solution, it'd be great for quick compiling during BIGJam and as compilation in general.
 
Theotherguy: I have a lot of premade files I use to shorten everything I need to code. Therefore, every small project uses a ton of existing files, making it effectly a bigger project.
« Last Edit: August 01, 2010, 11:21:42 AM by Kekskiller » Logged
tempestad
Level 0
**


View Profile
« Reply #10 on: August 01, 2010, 11:24:16 AM »

The *not so short* official documentation is here:
http://www.cmake.org/cmake/help/cmake-2-8-docs.html
Good for reference. For small projects you won't need most of them.

And here is a simple tutorial to get started:
http://www.cmake.org/cmake/help/examples.html

And of course the wiki:
http://www.cmake.org/Wiki/CMake

There are even more advanced stuff that CMake can handle, as combining it with a version control system to keep track of the version so you don't need to change anything.
Logged
BrianSlipBit
Level 1
*



View Profile WWW
« Reply #11 on: August 03, 2010, 09:25:18 AM »

Autotools and makefiles in general are pretty much ass.  Yes, I know autotools is powerful if you already know how to use them.  However, to that I say -- welcome to 1980.  Smiley

I just went through a somewhat similar process.  I weened myself off of Visual Studio project management in an effort to setup for multi-platform compilation and execution.

I'm now using SCons exclusively (currently on Windows with MinGW).  It handles dependencies like a champ.  It also supports threaded compilation, pre-compiled headers, and as an added bonus it also works great with Qt.

IMO, it's tough to go wrong with SCons.
Logged

Kekskiller
Guest
« Reply #12 on: August 03, 2010, 01:56:39 PM »

I'm already sold to CMake. Works perfect for what I'm doing.
Logged
BrianSlipBit
Level 1
*



View Profile WWW
« Reply #13 on: August 03, 2010, 02:08:14 PM »

I'm already sold to CMake. Works perfect for what I'm doing.

Fair enough.  It's cool that you're happy with it.  I was just tossing the SCons suggestion out there for both yourself and anyone else who might be in a similar situation and just for future reference.   Hand Thumbs Up Right
« Last Edit: August 04, 2010, 05:26:55 AM by BrianDFS » Logged

Kekskiller
Guest
« Reply #14 on: August 03, 2010, 10:26:47 PM »

Hehe. There are so many actual possibilites to manage code and compiling that one could make a comprehensive list of all tools, what they do and for what they work. This time Wikipedia wasn't really so helpful.

Shouldn't we have a thread for that? I mean the Developer Tools is nice, but this topic is pretty specific.
Logged
tapir
Level 0
**


View Profile
« Reply #15 on: August 03, 2010, 11:34:12 PM »

cmake also has cpack (http://www.cmake.org/Wiki/CMake:Packaging_With_CPack)
cpack lets you automatically create deb, rpm, tgz packages for linux, NSIS installer for windows and app bundles for Mac OSX
Logged
Kekskiller
Guest
« Reply #16 on: August 05, 2010, 10:13:35 AM »

Um, only one question left. I'm trying to show you how the folder looks, so I can avoid typing myself dead:

Code:
prog
|-lib
| |-geom
| | |-metrics.h
| | |-metrics.cpp
| | |-ray.h
| | |-main.cpp
| | *-CMakeLists.txt
| |-gfx
| | |-color.h
| | |-main.cpp
| | *-CMakeLists.txt
| |-mem
| | |-datmap
| | | |-datmap.h
| | | |-blender.h
| | | |-flatspriteblender.h
| | | |-rectblender.h
| | | |-surfaceblender.h
| | | |-main.cpp
| | | *-CMakeLists.txt
| | |-array.h
| | |-fifo.h
| | |-lifo.h
| | |-main.cpp
| | *-CMakeLists.txt
...

So as you can see, there are several projects in this structure. And like in case of prog/lib/mem/datmap, there are also projects inside projects. datmap does also depend on files from other projects and during make's process I always get weird linking errors aka undefined references, here's the CMake file:

Code:
cmake_minimum_required (VERSION 2.6)
project (datmap)
link_libraries (${SDL_LIBRARY})
add_executable (datmap main.cpp ../../geom/metrics.cpp)

As you can see, it uses SDL and also requires a file from prog/lib/geom. This is where it's getting weird. I previously compiled SDL code this way, but not in such a "cross project" way - I get undefined references to all used SDL functions (the code itself should be correct, I didn't do any changes since I compiled it without CMake). I'm sure but, could this happen due to all the different CMakeLists.txt? I must admit, I'm was impatient and didn't read very much of the documentation. I could just stop making test projects for each lib I'm using, but there must be another solution for it.

So yeah, if anyone knows how to solve this without directing to the documentation, I'd be very glad.
Logged
tapir
Level 0
**


View Profile
« Reply #17 on: August 05, 2010, 10:47:02 AM »

this tutorial helped me a lot with cmake: http://mathnathan.com/2010/07/11/getting-started-with-cmake/

although cmake is very powerful, it's at least as unintuitive as autotools. it's a shame, with a proper YAML like configuration file it could be the perfect build tool.
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic