Commit f3b00d94d14013369041c42ac05794d057acea45

Authored by Henry Fredrick Schreiner
Committed by Henry Schreiner
1 parent 521696f5

Python 2.6 support, SINGLE_FILE no longer defaults to ON

.ci/make_and_test.sh
... ... @@ -8,7 +8,7 @@ set -evx
8 8  
9 9 mkdir -p build
10 10 cd build
11   -cmake .. -DCLI11_CXX_STD=$STD -DCLI11_SINGLE_FILE_TESTS=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER_LAUNCHER=ccache $@
  11 +cmake .. -DCLI11_SINGLE_FILE=ON -DCLI11_CXX_STD=$STD -DCLI11_SINGLE_FILE_TESTS=ON -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER_LAUNCHER=ccache $@
12 12 cmake --build . -- -j2
13 13  
14 14 set +evx
... ...
CMakeLists.txt
... ... @@ -112,33 +112,16 @@ export(TARGETS CLI11
112 112 # Register in the user cmake package registry
113 113 export(PACKAGE CLI11)
114 114  
115   -# Single file test
116   -if(CMAKE_VERSION VERSION_LESS 3.12)
117   - set(Python_ADDITIONAL_VERSIONS 2.7 3.4 3.5 3.6 3.7 3.8)
118   - find_package(PythonInterp)
119   - set(Python_VERSION ${PYTHON_VERSION_STRING})
120   - set(Python_EXECUTABLE "${PYTHON_EXECUTABLE}")
121   -else()
122   - find_package(Python)
123   -endif()
124   -
125   -if(Python_Interpreter_FOUND OR PYTHONINTERP_FOUND)
126   - if(Python_VERSION VERSION_LESS 2.7)
127   - set(CLI11_PYTHON_FOUND FALSE)
128   - else()
129   - set(CLI11_PYTHON_FOUND TRUE)
130   - endif()
131   -else()
132   - set(CLI11_PYTHON_FOUND FALSE)
133   -endif()
134   -
135   -cmake_dependent_option(CLI11_SINGLE_FILE "Generate a single header file" ON "CUR_PROJ;CLI11_PYTHON_FOUND" OFF)
  115 +option(CLI11_SINGLE_FILE "Generate a single header file" OFF)
136 116  
137 117 if(CLI11_SINGLE_FILE)
138   - if(NOT CLI11_PYTHON_FOUND)
139   - message(FATAL_ERROR "CLI11_SINGLE_FILE requires Python 2.7 or 3 (not found)")
  118 +# Single file test
  119 + if(CMAKE_VERSION VERSION_LESS 3.12)
  120 + find_package(PythonInterp REQUIRED)
  121 + set(Python_VERSION ${PYTHON_VERSION_STRING})
  122 + set(Python_EXECUTABLE "${PYTHON_EXECUTABLE}")
140 123 else()
141   - message(STATUS "Building single file include using Python ${Python_VERSION} at ${Python_EXECUTABLE}")
  124 + find_package(Python REQUIRED)
142 125 endif()
143 126  
144 127 file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/include")
... ...
1   -CLI11 1.5 Copyright (c) 2017-2018 University of Cincinnati, developed by Henry
  1 +CLI11 1.6 Copyright (c) 2017-2018 University of Cincinnati, developed by Henry
2 2 Schreiner under NSF AWARD 1414736. All rights reserved.
3 3  
4 4 Redistribution and use in source and binary forms of CLI11, with or without
... ...
scripts/MakeSingleHeader.py
... ... @@ -9,7 +9,7 @@ import operator
9 9 from copy import copy
10 10 from functools import reduce
11 11  
12   -import subprocess
  12 +from subprocess import Popen, PIPE
13 13  
14 14 includes_local = re.compile(r"""^#include "(.*)"$""", re.MULTILINE)
15 15 includes_system = re.compile(r"""^#include \<(.*)\>$""", re.MULTILINE)
... ... @@ -112,12 +112,13 @@ class HeaderFile(object):
112 112 def MakeHeader(output, main_header, include_dir = '../include', namespace=None, macro=None):
113 113 # Set tag if possible to class variable
114 114 try:
115   - proc = subprocess.Popen(['git', 'describe', '--tags', '--always'], cwd=str(DIR), stdout=subprocess.PIPE)
  115 + proc = Popen(['git', 'describe', '--tags', '--always'], cwd=str(DIR), stdout=PIPE)
116 116 out, _ = proc.communicate()
117   - if proc.returncode == 0:
118   - HeaderFile.TAG = out.decode("utf-8").strip()
119 117 except OSError:
120 118 pass
  119 + else:
  120 + if proc.returncode == 0:
  121 + HeaderFile.TAG = out.decode("utf-8").strip()
121 122  
122 123 base_dir = os.path.abspath(os.path.join(DIR, include_dir))
123 124 main_header = os.path.join(base_dir, main_header)
... ...