Setting up a project for cross-platform development
#1 Crossbones+ - Reputation: 1375
Posted 08 March 2012 - 02:14 PM
#2 Members - Reputation: 2049
Posted 08 March 2012 - 02:43 PM
<project-name>/
include/
<project_name>/
# client headers go here
src/
# portable source and private headers go here
mac/
# mac-specific source and private headers
posix/
# posix-specific source and private headers
windows/
# windows-specific source and private headers
docs/
# docs go here.
I've never felt the need for anything more complicated. To some extent, the layout might depend on the particulars of your build system. I can do things like this in my build scripts, which makes this layout convenient in my case:
sources = here/'src/*.cpp' + here/'src'/cfg.platform/'*.cpp' # etc
#3 Crossbones+ - Reputation: 1375
Posted 08 March 2012 - 02:59 PM
There's no "one true way", but my projects tend to look something like this as far as directory layout is concerned, assuming there are platform-specific components for Mac, POSIX and Windows:
<project-name>/ include/ <project_name>/ # client headers go here src/ # portable source and private headers go here mac/ # mac-specific source and private headers posix/ # posix-specific source and private headers windows/ # windows-specific source and private headers docs/ # docs go here.
I've never felt the need for anything more complicated. To some extent, the layout might depend on the particulars of your build system. I can do things like this in my build scripts, which makes this layout convenient in my case:sources = here/'src/*.cpp' + here/'src'/cfg.platform/'*.cpp' # etc
I don't really have a build system per se ... just use VS2010 for Windows and plan on using XCode for Mac/iOS. I take it you build from the command line. Is there an advantage to doing this in the case of cross-platform?
#4 Members - Reputation: 102
Posted 08 March 2012 - 03:28 PM
#5 Members - Reputation: 2049
Posted 08 March 2012 - 03:51 PM
I don't really have a build system per se ... just use VS2010 for Windows and plan on using XCode for Mac/iOS. I take it you build from the command line. Is there an advantage to doing this in the case of cross-platform?
Having to maintain multiple project files for various IDEs is a pain, especially if you don't have access to all the supported systems. For that reason, I have a platform/toolchain agnostic build system written as a DSL in Python. Sane people would probably use CMake instead, as Caanon suggests.
Of course, if you still use multiple IDEs, you'll have to maintain multiple project files just to make sure they all know about the new source files you add, unless they support filename globbing of some sort. I switched to Vim a few years ago and simply use sub-directories to organise 'projects' (and I now wish I had taken the time to learn it sooner, FWIW).
EDIT: I should also say that the system allows me to build my projects in a variety of ways:
- Compilers: Visual C++ 2005, 2008, 2010. MinGW 4.2, 4.5, 4.6. Apple GCC 4.0.1, 4.2.1. Apple LLVM-GCC 4.2.1.
- SDKs: 3 Platform SDKs each on OSX on Windows.
- Build configurations: debug, optimized, release.
- Architectures: x86, x64.
- + any combinations configuration options available for the project in question
#6 Crossbones+ - Reputation: 1375
Posted 08 March 2012 - 04:05 PM
#7 Members - Reputation: 2049
Posted 08 March 2012 - 04:22 PM
#8 Members - Reputation: 689
Posted 09 March 2012 - 12:21 AM
I use CMake.
The build system can not only build your project, but also generate project files for IDE.
Want to work in VS? Ask CMake to generate project for VS 2010.
Want to work in Code::Block, then CMake generate the project for C::B for you.
Try to learn a build system, I prefer CMake. The hours you spend on learning the build system should be quite lower than the time you spend on manipulate different project files on different platforms for different IDEs.
http://www.cpgf.org/
cpgf library -- free C++ open source library for reflection, serialization, script binding, callbacks, and meta data for OpenGL Box2D, SFML and Irrlicht.
v1.5.5 was released. Now supports tween and timeline for ease animation.






