Skip to main content



      Home
Home » Language IDEs » C / C++ IDE (CDT) » Multi-platform project
Multi-platform project [message #150463] Mon, 01 August 2005 08:45 Go to next message
Eclipse UserFriend
I'm developing a program that is source compatible (GNU) for Linux and
Windows. I'd like to have a single project for both target platforms. Is
this possible and how? Is CDT able to detect the correct target platform
without changing project properties?

Mike
Re: Multi-platform project [message #150480 is a reply to message #150463] Tue, 02 August 2005 08:40 Go to previous message
Eclipse UserFriend
We are using Ant and CppTask under Eclipse & CDT for making a project.
It is possible to set all target specified issues into ant-file, so we
have same project and same platform for both platforms (Linux and Windows)

Here is simple example of ant build-file - in the beginning you can
found some conditions, depends from platform:

<project name="XPCOM String Test" default="BuildTest">
<!-- Compilation settings -->
<!-- Set compiler property depending from os -->
<condition property="win32" value="on">
<os family="windows"/>
</condition>
<condition property="unix" value="on">
<os family="unix"/>
</condition>

<condition property="compiler" value="gcc">
<os family="unix"/>
</condition>
<condition property="compiler" value="msvc">
<os family="windows"/>
</condition>
<condition property="compiler.debug" value="true" else="false">
<istrue value="${DEBUG}"/>
</condition>
<condition property="compiler.optimize" value="none" else="speed">
<istrue value="${DEBUG}"/>
</condition>
<condition property="define.os" value="_UNIX">
<os family="unix"/>
</condition>
<condition property="define.os" value="_WINDOWS">
<os family="windows"/>
</condition>

<!-- Common SDK Folder -->
<property name="dir.sdk" value="${basedir}/../../../sdk" />

<!-- Platform-depended SDK folders -->
<condition property="dir.sdk.platform" value="Windows">
<os family="windows"/>
</condition>
<condition property="dir.sdk.platform" value="Linux">
<os family="unix"/>
</condition>

<!-- XPCOM SDK & GRE -->
<!-- SDK & JRE should be in repository inder xpcom folder -->
<property name="dir.xpcom.sdk"
value="${dir.sdk}/xpcom/${dir.sdk.platform}" />
<property name="dir.xpcom.gre"
value="${basedir}/../../gre/${dir.sdk.platform}" />

<!-- General directories -->
<property name="dir.base" value="." />
<property name="dir.src" value="${dir.base}" />
<condition property="dir.out" value="${basedir}/Debug"
else="${basedir}/Release">
<istrue value="${DEBUG}"/>
</condition>
<condition property="dir.obj" value="${basedir}/Debug"
else="${basedir}/Release">
<istrue value="${DEBUG}"/>
</condition>

<!-- Shared Staff -->
<property name="dir.inc.shared" value="${basedir}/../../Shared" />

<taskdef resource="cpptasks.tasks" />
<taskdef resource="cpptasks.types" />

<target name="clean">
<delete dir="${dir.obj}" />
</target>

<target name="init">
<!-- mkdir dir="${dir.out}" / -->
<mkdir dir="${dir.obj}" />
</target>

<target name="BuildTest" depends="init"
description="compile the source">
<cc outfile="stringtest"
subsystem="other"
name="${compiler}"
exceptions="true"
objdir="${dir.obj}"
debug="${compiler.debug}"
optimize="${compiler.optimize}"
outtype="executable">

<fileset dir="${dir.src}" includes="*.cpp" />

<defineset define="MOZILLA_STRICT_API" />
<defineset define="XPCOM_GLUE" />

<defineset define="${define.os}"/>

<includepath path="${dir.src}"/>
<!-- since IDL is compiled into obj output it also should be
included into includes -->
<includepath path="${dir.obj}"/>
<includepath path="${dir.inc.shared}"/>
<includepath path="${dir.xpcom.sdk}/include"/>

<libset dir="${dir.xpcom.sdk}/lib" libs="xpcomglue" type="shared" />
<libset dir="${dir.xpcom.sdk}/lib" libs="plds4" type="shared" />
<libset dir="${dir.xpcom.sdk}/lib" libs="plc4" type="shared" />
<libset dir="${dir.xpcom.sdk}/lib" libs="nspr4" type="shared" />

<!-- \todo [AKA] Check how it will be under Win32 -->
<libset libs="stdc++" type="shared" if="unix"/>

<!-- \todo [AKA] Check how it will be under Win32 -->
<linkerarg location="end" value="advapi32.lib" if="win32"/>
</cc>
</target>
</project>

Mike Werner wrote:
> I'm developing a program that is source compatible (GNU) for Linux and
> Windows. I'd like to have a single project for both target platforms. Is
> this possible and how? Is CDT able to detect the correct target platform
> without changing project properties?
>
> Mike
>
Previous Topic:Switching between Debug and Release mode
Next Topic:Breakpoint locations to help understand the CDT code
Goto Forum:
  


Current Time: Wed May 07 19:36:30 EDT 2025

Powered by FUDForum. Page generated in 0.03724 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top