Skip to content

Commit

Permalink
Move env dependent directories to appropriate CMAKE_BUILD_TYPE // Issue
Browse files Browse the repository at this point in the history
#3460

This will allow to dynamically populate list of sources depending on
selected environment. At the same time "src" and "lib" folders remain
common for all environments
  • Loading branch information
valeros committed Apr 21, 2020
1 parent fd91819 commit a556573
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions platformio/ide/tpls/clion/CMakeListsPrivate.txt.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
% return to_unix_path(text).replace('"', '\\"')
% end
%
% def _get_lib_dirs(envname):
% env_libdeps_dir = os.path.join(config.get_optional_dir("libdeps"), envname)
% env_lib_extra_dirs = config.get("env:" + envname, "lib_extra_dirs", [])
% return _fix_lib_dirs([env_libdeps_dir] + env_lib_extra_dirs)
% end
%
% envs = config.envs()


Expand Down Expand Up @@ -75,6 +81,12 @@ if (CMAKE_BUILD_TYPE MATCHES "{{ env_name }}")
% for include in filter_includes(includes):
include_directories("{{ _normalize_path(include) }}")
% end

FILE(GLOB_RECURSE EXTRA_LIB_SOURCES
% for dir in _get_lib_dirs(env_name):
{{ _normalize_path(dir) + "/*.*" }}
% end
)
endif()

% leftover_envs = list(set(envs) ^ set([env_name]))
Expand All @@ -93,13 +105,19 @@ if (CMAKE_BUILD_TYPE MATCHES "{{ env }}")
% for include in filter_includes(data["includes"]):
include_directories("{{ _normalize_path(to_unix_path(include)) }}")
% end

FILE(GLOB_RECURSE EXTRA_LIB_SOURCES
% for dir in _get_lib_dirs(env):
{{ _normalize_path(dir) + "/*.*" }}
% end
)
endif()
% end
%
% lib_extra_dirs = _fix_lib_dirs(config.get("env:" + env_name, "lib_extra_dirs", []))
% src_paths = [project_src_dir, project_lib_dir, project_libdeps_dir] + lib_extra_dirs

FILE(GLOB_RECURSE SRC_LIST
% for path in src_paths:
% for path in (project_src_dir, project_lib_dir):
{{ _normalize_path(path) + "/*.*" }}
% end
)

list(APPEND SRC_LIST ${EXTRA_LIB_SOURCES})

0 comments on commit a556573

Please sign in to comment.