Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-03-25 15:42:33 +0300
committerCampbell Barton <ideasman42@gmail.com>2011-03-25 15:42:33 +0300
commitf08a227f931e869eaead63476b71a5e1acfdd274 (patch)
treebffcbef10799abf387c4388a9330b31d0fa2c4da /build_files
parent3d5898f3dcc5e19b5961112477b2e9c00be9734c (diff)
include gcc builtin defines in qtcreator project file (__VERSION__, __x86_64__, __linux__ etc)
Diffstat (limited to 'build_files')
-rw-r--r--build_files/cmake/cmake_qtcreator_project.py38
1 files changed, 37 insertions, 1 deletions
diff --git a/build_files/cmake/cmake_qtcreator_project.py b/build_files/cmake/cmake_qtcreator_project.py
index a8687e34be1..cf1da2f666f 100644
--- a/build_files/cmake/cmake_qtcreator_project.py
+++ b/build_files/cmake/cmake_qtcreator_project.py
@@ -175,6 +175,40 @@ def cmake_advanced_info():
return includes, defines
+def cmake_cache_var(var):
+ cache_file = open(os.path.join(CMAKE_DIR, "CMakeCache.txt"))
+ lines = [l_strip for l in cache_file for l_strip in (l.strip(),) if l_strip if not l_strip.startswith("//") if not l_strip.startswith("#")]
+ cache_file.close()
+
+ for l in lines:
+ if l.split(":")[0] == var:
+ return l.split("=", 1)[-1]
+ return None
+
+
+def cmake_compiler_defines():
+ compiler = cmake_cache_var("CMAKE_C_COMPILER") # could do CXX too
+
+ if compiler is None:
+ print("Couldn't find the compiler, os defines will be omitted...")
+ return
+
+ import tempfile
+ temp_c = tempfile.mkstemp(suffix=".c")[1]
+ temp_def = tempfile.mkstemp(suffix=".def")[1]
+
+ os.system("%s -dM -E %s > %s" % (compiler, temp_c, temp_def))
+
+ temp_def_file = open(temp_def)
+ lines = [l.strip() for l in temp_def_file if l.strip()]
+ temp_def_file.close()
+
+ os.remove(temp_c)
+ os.remove(temp_def)
+
+ return lines
+
+
def create_qtc_project_main():
files = list(source_list(base, filename_check=is_project_file))
files_rel = [relpath(f, start=PROJECT_DIR) for f in files]
@@ -220,7 +254,9 @@ def create_qtc_project_main():
qtc_cfg = join(PROJECT_DIR, "%s.config" % FILE_NAME)
f = open(qtc_cfg, 'w')
f.write("// ADD PREDEFINED MACROS HERE!\n")
- f.write("\n".join([("#define %s %s" % item) for item in defines]))
+ defines_final = [("#define %s %s" % item) for item in defines]
+ defines_final += cmake_compiler_defines() # defines from the compiler
+ f.write("\n".join(defines_final))
print("Blender project file written to: %s" % qtc_prj)
# --- end