forked from 0ad/0ad
Added ICC-Linux PCH support in Premake. (It's much more like the MSVC approach than the GCC one.)
Passed --have-std to CxxTest so it always adds the same code before including precompiled.h, so that the PCH is usable. This was SVN commit r4736.
This commit is contained in:
parent
0bdc1c22c8
commit
2d4f5478de
@ -1,6 +1,6 @@
|
||||
addoption("atlas", "Include Atlas scenario editor packages")
|
||||
addoption("collada", "Include COLLADA packages (requires FCollada library)")
|
||||
addoption("icc", "Use Intel C++ Compiler (Linux only; should set CXX=icpc before calling make)")
|
||||
addoption("icc", "Use Intel C++ Compiler (Linux only; should use either \"--cc icc\" or --without-pch too, and then set CXX=icpc before calling make)")
|
||||
addoption("outpath", "Location for generated project files")
|
||||
addoption("without-tests", "Disable generation of test projects")
|
||||
addoption("without-pch", "Disable generation and usage of precompiled headers")
|
||||
@ -26,10 +26,6 @@ else
|
||||
project.cxxtestpath = "../../build/bin/cxxtestgen.pl"
|
||||
end
|
||||
|
||||
if OS == "linux" and options["icc"] then
|
||||
options["without-pch"] = 1 -- ICC9.1 doesn't support GCC-style PCH
|
||||
end
|
||||
|
||||
source_root = "../../../source/" -- default for most projects - overridden by local in others
|
||||
|
||||
-- Rationale: packages should not have any additional include paths except for
|
||||
@ -733,11 +729,12 @@ function setup_tests()
|
||||
package_create("test_3_gen", "cxxtestgen")
|
||||
package.files = hdr_files
|
||||
package.rootfile = source_root .. "test_root.cpp"
|
||||
package.testoptions = ""
|
||||
package.testoptions = "--have-std"
|
||||
package.rootoptions = "--have-std"
|
||||
if OS == "windows" then
|
||||
package.rootoptions = "--gui=Win32Gui --runner=ParenPrinter"
|
||||
package.rootoptions = package.rootoptions .. " --gui=Win32Gui --runner=ParenPrinter"
|
||||
else
|
||||
package.rootoptions = "--runner=ErrorPrinter"
|
||||
package.rootoptions = package.rootoptions .. " --runner=ErrorPrinter"
|
||||
end
|
||||
-- precompiled headers - the header is added to all generated .cpp files
|
||||
-- note that the header isn't actually precompiled here, only #included
|
||||
@ -757,6 +754,7 @@ function setup_tests()
|
||||
-- note: these are not relative to source_root and therefore can't be included via package_add_contents.
|
||||
listconcat(package.files, src_files)
|
||||
package_add_extern_libs(used_extern_libs)
|
||||
|
||||
if OS == "windows" then
|
||||
-- required for win.cpp's init mechanism
|
||||
tinsert(package.linkoptions, "/ENTRY:entry_noSEH")
|
||||
|
@ -118,7 +118,7 @@ int gnu_cpp()
|
||||
|
||||
/* Write linker flags */
|
||||
io_print(" LDFLAGS += -L$(BINDIR) -L$(LIBDIR)");
|
||||
if (prj_is_kind("dll") && (g_cc == NULL || matches(g_cc, "gcc")))
|
||||
if (prj_is_kind("dll") && (g_cc == NULL || matches(g_cc, "gcc") || matches(g_cc, "icc")))
|
||||
io_print(" -shared");
|
||||
if (prj_has_flag("no-symbols"))
|
||||
io_print(" -s");
|
||||
@ -175,13 +175,34 @@ int gnu_cpp()
|
||||
print_list(prj_get_files(), "\t$(OBJDIR)/", " \\\n", "", listCppSources);
|
||||
io_print("\n");
|
||||
|
||||
io_print("PCHS := \\\n");
|
||||
if (prj_get_pch_header() != NULL)
|
||||
if (matches(g_cc, "icc"))
|
||||
{
|
||||
const char *basename = path_getbasename(prj_get_pch_header());
|
||||
io_print("\t$(OBJDIR)/%s.h.gch \\\n", basename);
|
||||
if (prj_get_pch_source() == NULL)
|
||||
{
|
||||
io_print("PCHS := \n");
|
||||
}
|
||||
else
|
||||
{
|
||||
io_print("PCHS := \\\n");
|
||||
const char *basename = path_getbasename(prj_get_pch_source());
|
||||
io_print("\t$(OBJDIR)/%s.pchi \\\n", basename);
|
||||
io_print("\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (prj_get_pch_header() == NULL)
|
||||
{
|
||||
io_print("PCHS := \n");
|
||||
}
|
||||
else
|
||||
{
|
||||
io_print("PCHS := \\\n");
|
||||
const char *basename = path_getbasename(prj_get_pch_header());
|
||||
io_print("\t$(OBJDIR)/%s.h.gch \\\n", basename);
|
||||
io_print("\n");
|
||||
}
|
||||
}
|
||||
io_print("\n");
|
||||
|
||||
/* Write out the list of resource files for windows targets */
|
||||
if (os_is("windows"))
|
||||
@ -278,6 +299,14 @@ int gnu_cpp()
|
||||
}
|
||||
io_print("\n");
|
||||
|
||||
/* When using ICC, the .pchi is a side-effect of compiling the .o,
|
||||
* so create a pattern for that rule */
|
||||
if (matches(g_cc, "icc") && prj_get_pch_source() != NULL)
|
||||
{
|
||||
const char *basename = path_getbasename(prj_get_pch_source());
|
||||
io_print("$(OBJDIR)/%s.pchi: $(OBJDIR)/%s.o\n\n", basename, basename);
|
||||
}
|
||||
|
||||
/* Write static patterns for each source file. Note that in earlier
|
||||
* versions I used pattern rules instead of listing each file. It worked
|
||||
* fine but made it more difficult to test and also required the use of
|
||||
@ -390,6 +419,7 @@ static const char* listCppTargets(const char* name)
|
||||
const char *pchSource = prj_get_pch_source();
|
||||
|
||||
int use_pch = pchHeader?1:0, gen_pch=0;
|
||||
const char* pchExt = (matches(g_cc, "icc") ? "pchi" : "h.gch");
|
||||
|
||||
if (pchSource && matches(path_getname(name), pchSource))
|
||||
{
|
||||
@ -400,14 +430,23 @@ static const char* listCppTargets(const char* name)
|
||||
if (is_cpp(name))
|
||||
{
|
||||
const char* basename = path_getbasename(name);
|
||||
sprintf(g_buffer, "$(OBJDIR)/%s.%s: %s ",
|
||||
basename, gen_pch?"h.gch":"o", name);
|
||||
strcpy(g_buffer, "");
|
||||
|
||||
strcat(g_buffer, "$(OBJDIR)/");
|
||||
strcat(g_buffer, basename);
|
||||
strcat(g_buffer, ".");
|
||||
strcat(g_buffer, (gen_pch && !matches(g_cc, "icc")) ? pchExt : "o"); // we want ICC to generate the .o
|
||||
strcat(g_buffer, ": ");
|
||||
strcat(g_buffer, name);
|
||||
strcat(g_buffer, " ");
|
||||
|
||||
if (use_pch)
|
||||
{
|
||||
basename = path_getbasename(pchHeader);
|
||||
strcat(g_buffer, "$(OBJDIR)/");
|
||||
strcat(g_buffer, basename);
|
||||
strcat(g_buffer, ".h.gch");
|
||||
strcat(g_buffer, ".");
|
||||
strcat(g_buffer, pchExt);
|
||||
// static buffer, *sigh*
|
||||
basename = path_getbasename(name);
|
||||
}
|
||||
@ -418,7 +457,7 @@ static const char* listCppTargets(const char* name)
|
||||
|
||||
if (!g_verbose)
|
||||
strcat(g_buffer, "\t@echo $(notdir $<)\n");
|
||||
|
||||
|
||||
strcat(g_buffer, "\t");
|
||||
if (!g_verbose)
|
||||
strcat(g_buffer, "@");
|
||||
@ -469,15 +508,41 @@ static const char* listCppTargets(const char* name)
|
||||
strcat(g_buffer, ".d -o $@ -c");
|
||||
if (gen_pch)
|
||||
{
|
||||
strcat(g_buffer, " -x c++-header");
|
||||
if (matches(g_cc, "icc"))
|
||||
{
|
||||
basename = path_getbasename(pchSource);
|
||||
strcat(g_buffer, " -create-pch $(OBJDIR)/");
|
||||
strcat(g_buffer, basename);
|
||||
strcat(g_buffer, ".pchi");
|
||||
basename = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
strcat(g_buffer, " -x c++-header");
|
||||
}
|
||||
}
|
||||
else if (use_pch)
|
||||
{
|
||||
basename = path_getbasename(pchHeader);
|
||||
strcat(g_buffer, " -include $(OBJDIR)/");
|
||||
strcat(g_buffer, basename);
|
||||
strcat(g_buffer, ".h");
|
||||
basename = NULL;
|
||||
if (matches(g_cc, "icc"))
|
||||
{
|
||||
basename = path_getbasename(pchSource);
|
||||
strcat(g_buffer, " -use-pch $(OBJDIR)/");
|
||||
strcat(g_buffer, basename);
|
||||
strcat(g_buffer, ".pchi");
|
||||
basename = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
// I don't think this is necessary, since we include precompiled.h
|
||||
// manually in every source file anyway
|
||||
/*
|
||||
basename = path_getbasename(pchHeader);
|
||||
strcat(g_buffer, " -include $(OBJDIR)/");
|
||||
strcat(g_buffer, basename);
|
||||
strcat(g_buffer, ".h");
|
||||
basename = NULL;
|
||||
*/
|
||||
}
|
||||
}
|
||||
strcat(g_buffer, " $<\n");
|
||||
}
|
||||
|
@ -271,6 +271,7 @@ void showUsage()
|
||||
puts(" --cc name Choose a C/C++ compiler, if supported by target; one of:");
|
||||
puts(" gcc GNU gcc compiler");
|
||||
puts(" dmc Digital Mars C/C+ compiler (experimental)");
|
||||
puts(" icc Intel C++ Compiler (highly experimental)");
|
||||
puts("");
|
||||
puts(" --dotnet name Choose a .NET compiler set, if supported by target; one of:");
|
||||
puts(" ms Microsoft (csc)");
|
||||
|
@ -10,7 +10,7 @@ cd $premake_dir
|
||||
|
||||
# build/premake/
|
||||
|
||||
./premake --target gnu --outpath $workspace_dir --atlas $*
|
||||
./premake --outpath $workspace_dir --atlas $* --target gnu
|
||||
|
||||
# These files need to be linked; premake makefiles assume that the
|
||||
# lua file is accessible from the makefile directory
|
||||
|
@ -1 +1,8 @@
|
||||
// Got to be consistent with what the rest of the source files do before
|
||||
// including precompiled.h, so that the PCH works correctly
|
||||
#ifndef CXXTEST_RUNNING
|
||||
#define CXXTEST_RUNNING
|
||||
#endif
|
||||
#define _CXXTEST_HAVE_STD
|
||||
|
||||
#include "precompiled.h"
|
||||
|
@ -1,3 +1,10 @@
|
||||
// Got to be consistent with what the rest of the source files do before
|
||||
// including precompiled.h, so that the PCH works correctly
|
||||
#ifndef CXXTEST_RUNNING
|
||||
#define CXXTEST_RUNNING
|
||||
#endif
|
||||
#define _CXXTEST_HAVE_STD
|
||||
|
||||
#include "precompiled.h"
|
||||
|
||||
#include <cxxtest/GlobalFixture.h>
|
||||
|
Loading…
Reference in New Issue
Block a user