- improve CMake handling Signed-off-by: SSE4 <tomskside@gmail.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
diff --git a/appveyor.yml b/appveyor.yml
index efb568d..21cf72a 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -3,6 +3,7 @@ build: false
environment:
matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
+ CMAKE_SH: "CMAKE_SH-NOTFOUND"
CMAKE_GENERATOR: "MinGW Makefiles"
CMAKE_MAKE_PROGRAM: "C:\\mingw-w64\\x86_64-7.2.0-posix-seh-rt_v5-rev1\\mingw64\\bin\\mingw32-make.exe"
CC: "C:\\mingw-w64\\x86_64-7.2.0-posix-seh-rt_v5-rev1\\mingw64\\bin\\gcc.exe"
@@ -20,5 +21,4 @@ environment:
CMAKE_GENERATOR: "Visual Studio 15 2017 Win64"
test_script:
- - dir /B /S C:\mingw*gcc.exe
- python build.py
diff --git a/build.py b/build.py
index 4d31d84..208f41b 100644
--- a/build.py
+++ b/build.py
@@ -2,31 +2,38 @@
# -*- coding: utf-8 -*-
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
+from __future__ import print_function
import os
import sys
+def show_file(filename):
+ if os.path.isfile(filename):
+ with open(filename, 'r') as f:
+ contents = f.read()
+ print("%s:" % filename)
+ print(contents)
+
def run(command):
status = os.system(command)
if 0 != status:
+ show_file(os.path.join("CMakeFiles", "CMakeOutput.log"))
+ show_file(os.path.join("CMakeFiles", "CMakeError.log"))
sys.exit(command)
-def remove_sh_from_path():
- path = os.environ["PATH"]
- path = path.split(os.pathsep)
- for entry in path:
- if os.path.isfile(os.path.join(entry, "sh.exe")):
- path.remove(entry)
- path = os.pathsep.join(path)
- os.environ["PATH"] = path
-
def main():
- remove_sh_from_path()
generator = os.environ["CMAKE_GENERATOR"]
+ multi_config = generator.startswith("Visual")
command = 'cmake . -G "%s"' % generator
- if "CMAKE_MAKE_PROGRAM" in os.environ:
- command += ' -DCMAKE_MAKE_PROGRAM="%s"' % os.environ["CMAKE_MAKE_PROGRAM"]
+ for env in os.environ:
+ if env.startswith("CMAKE"):
+ command += ' -D%s="%s"' % (env, os.environ[env])
+ if not multi_config:
+ command += ' -DCMAKE_BUILD_TYPE=Release'
+ run(command)
+ command = 'cmake --build .'
+ if multi_config:
+ command += ' --config Release'
run(command)
- run('cmake --build . --config Release')
if __name__ == '__main__':
main()