diff --git a/CMakeLists.txt b/CMakeLists.txt index cd49e4d41c03ec932744db91864caa0cfeb6ce87..6e0a246f0898c4b134dcd54f0bd644cb615ec8ab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,12 +6,9 @@ include(GNUInstallDirs) include(Utils) include(third_party/get_third_party) -# Should update cmake to a more recent version which supports FindPython3. find_package(PythonInterp) -if(NOT PYTHON_EXECUTABLE OR PYTHON_VERSION_MAJOR LESS 3) - message(WARNING "Needs python3 to auto-generate most CMake files, but not found. " - "Will try `python3` directly...") - set(PYTHON_EXECUTABLE "python3") +if(NOT PYTHON_EXECUTABLE) + message(FATAL_ERROR "Needs python to auto-generate most CMake files, but not found.") endif() message(STATUS "Running gen_cmake_skeleton.py") diff --git a/cmake/gen_cmake_skeleton.py b/cmake/gen_cmake_skeleton.py index 6492f36f7c89b26315ef13533cb16b8ed78f2339..c846d988c27c525689f5d2c9466cf8b888d3066c 100644 --- a/cmake/gen_cmake_skeleton.py +++ b/cmake/gen_cmake_skeleton.py @@ -1,9 +1,14 @@ +from __future__ import print_function + import os import sys import re import fnmatch import argparse +# avoid Python>3 rewrite newline on different platforms +os.linesep = "\n" + # earily parse, will refernece args globally parser = argparse.ArgumentParser() parser.add_argument("working_dir") @@ -308,7 +313,7 @@ class CMakeListsFile(object): self.sections.append(section) def write_file(self): - with open(self.path, "w", newline='\n') as f: # good luck for python2 + with open(self.path, "w") as f: f.write(CMakeListsFile.GEN_CMAKE_HEADER) for s in self.sections: code = s.gen_code()