forked from platformio/platformio-core
Fix CMakeLists.txt add_executable has only one source file // Resolve #421
This commit is contained in:
@ -16,6 +16,8 @@ PlatformIO 2.0
|
||||
(`issue #422 <https://github.com/platformio/platformio/issues/422>`_)
|
||||
* Fixed package ``shasum`` validation on Mac OS X 10.11.2
|
||||
(`issue #429 <https://github.com/platformio/platformio/issues/429>`_)
|
||||
* Fixed CMakeLists.txt ``add_executable`` has only one source file
|
||||
(`issue #421 <https://github.com/platformio/platformio/issues/421>`_)
|
||||
|
||||
2.7.0 (2015-12-30)
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
@ -91,14 +91,6 @@ class ProjectGenerator(object):
|
||||
result.append(relpath(join(root, f)))
|
||||
return result
|
||||
|
||||
@staticmethod
|
||||
def get_main_src_file(src_files):
|
||||
for f in src_files:
|
||||
for ext in ("c", "cpp"):
|
||||
if f.endswith(".%s" % ext):
|
||||
return f
|
||||
return None
|
||||
|
||||
def get_tpls(self):
|
||||
tpls = []
|
||||
tpls_dir = join(util.get_source_dir(), "ide", "tpls", self.ide)
|
||||
@ -132,9 +124,9 @@ class ProjectGenerator(object):
|
||||
|
||||
def _gather_tplvars(self):
|
||||
src_files = self.get_src_files()
|
||||
main_src_file = self.get_main_src_file(src_files)
|
||||
|
||||
if not main_src_file and self.ide == "clion":
|
||||
if (not any([f.endswith((".c", ".cpp")) for f in src_files]) and
|
||||
self.ide == "clion"):
|
||||
click.secho(
|
||||
"Warning! Can not find main source file (*.c, *.cpp). So, "
|
||||
"code auto-completion is disabled. Please add source files "
|
||||
@ -147,7 +139,6 @@ class ProjectGenerator(object):
|
||||
self._tplvars.update({
|
||||
"project_name": self.get_project_name(),
|
||||
"src_files": src_files,
|
||||
"main_src_file": main_src_file,
|
||||
"user_home_dir": abspath(expanduser("~")),
|
||||
"project_dir": self.project_dir,
|
||||
"systype": util.get_systype(),
|
||||
|
@ -38,8 +38,14 @@ add_custom_target(
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
% if main_src_file:
|
||||
add_executable({{project_name}} {{main_src_file.replace("\\", "/")}})
|
||||
% if src_files and any([f.endswith((".c", ".cpp")) for f in src_files]):
|
||||
add_executable({{project_name}}
|
||||
% for f in src_files:
|
||||
% if f.endswith((".c", ".cpp")):
|
||||
{{f.replace("\\", "/")}}
|
||||
% end
|
||||
% end
|
||||
)
|
||||
% else:
|
||||
#
|
||||
# To enable code auto-completion, please specify path
|
||||
|
Reference in New Issue
Block a user