Use .obj extension on Windows.

The Windows linker LINK insists on the .obj extension. The following changes are made:
- CMake uses the same extension as the C compiler
- global.obj_ext_alt (aka .obj) is recognized as objectfile extension
- global.obj_ext_alt is used on Windows
This commit is contained in:
kai
2012-09-05 18:09:07 +02:00
parent af69672dc7
commit 9a3cdf2e10
5 changed files with 10 additions and 15 deletions

View File

@@ -72,9 +72,7 @@ Global::Global()
bc_ext = "bc";
s_ext = "s";
obj_ext = "o";
#if _WIN32
obj_ext_alt = "obj";
#endif
#else
#if TARGET_WINDOS
obj_ext = "obj";

View File

@@ -285,12 +285,10 @@ struct Global
const char *sym_ext;
const char *obj_ext;
#if IN_LLVM
#if _WIN32
char *obj_ext_alt;
#endif
char *ll_ext;
char *bc_ext;
char *s_ext;
const char *obj_ext_alt;
const char *ll_ext;
const char *bc_ext;
const char *s_ext;
#endif
const char *lib_ext;
const char *dll_ext;

View File

@@ -358,10 +358,10 @@ void Module::buildTargetFiles(bool singleObj)
if(!objfile)
{
if (global.params.output_o)
objfile = Module::buildFilePath(global.params.objname, global.params.objdir, global.obj_ext);
objfile = Module::buildFilePath(global.params.objname, global.params.objdir, global.params.os == OSWindows ? global.obj_ext_alt : global.obj_ext);
else if (global.params.output_bc)
objfile = Module::buildFilePath(global.params.objname, global.params.objdir, global.bc_ext);
else if (global.params.output_ll)
else if (global.params.output_ll)
objfile = Module::buildFilePath(global.params.objname, global.params.objdir, global.ll_ext);
else if (global.params.output_s)
objfile = Module::buildFilePath(global.params.objname, global.params.objdir, global.s_ext);

View File

@@ -391,17 +391,16 @@ int main(int argc, char** argv)
} else if (strcmp(ext, global.s_ext) == 0) {
global.params.output_s = OUTPUTFLAGset;
autofound = true;
} else if (strcmp(ext, global.obj_ext) == 0) {
} else if (strcmp(ext, global.obj_ext) == 0 || strcmp(ext, global.obj_ext_alt) == 0) {
global.params.output_o = OUTPUTFLAGset;
autofound = true;
} else {
// append dot, so forceExt won't change existing name even if it contains dots
size_t len = strlen(global.params.objname);
size_t extlen = strlen(".");
char* s = static_cast<char *>(mem.malloc(len + 1 + extlen + 1));
char* s = static_cast<char *>(mem.malloc(len + 1 + 1));
memcpy(s, global.params.objname, len);
s[len] = '.';
s[len+1+extlen] = 0;
s[len+1] = 0;
global.params.objname = s;
}

View File

@@ -187,7 +187,7 @@ macro(dc INPUT_D OUTLIST_O OUTLIST_BC MOREFLAGS PATH SUFFIX)
else ("${path}" STREQUAL "")
set(output ${path}/${name})
endif ("${path}" STREQUAL "")
set(OUTPUT_O ${PROJECT_BINARY_DIR}/${output}${SUFFIX}.o)
set(OUTPUT_O ${PROJECT_BINARY_DIR}/${output}${SUFFIX}${CMAKE_C_OUTPUT_EXTENSION})
set(OUTPUT_BC ${PROJECT_BINARY_DIR}/${output}${SUFFIX}.bc)
list(APPEND ${OUTLIST_O} ${OUTPUT_O})
list(APPEND ${OUTLIST_BC} ${OUTPUT_BC})