Skip to content

Commit 253bd2d

Browse files
committed
Add BDIR_PRIVATE. Respect CMAKE_SYSTEM_VERSION, add it to config.
1 parent 5a0e60e commit 253bd2d

8 files changed

Lines changed: 50 additions & 11 deletions

File tree

src/client/main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ optional<int> internal(const Strings &args)
656656
if (args.size() < 6)
657657
{
658658
std::cout << "invalid number of arguments: " << args.size() << "\n";
659-
std::cout << "usage: cppan internal-parallel-vars-check vars_dir vars_file checks_file generator toolset toolchain\n";
659+
std::cout << "usage: cppan internal-parallel-vars-check vars_dir vars_file checks_file generator system_version toolset toolchain\n";
660660
return 1;
661661
}
662662

@@ -668,6 +668,7 @@ optional<int> internal(const Strings &args)
668668
ASSIGN_ARG(vars_file);
669669
ASSIGN_ARG(checks_file);
670670
ASSIGN_ARG(generator);
671+
ASSIGN_ARG(system_version);
671672
ASSIGN_ARG(toolset);
672673
ASSIGN_ARG(toolchain);
673674
#undef ASSIGN_ARG

src/common/checks.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ struct ParallelCheckOptions
210210
path vars_file;
211211
path checks_file;
212212
String generator;
213+
String system_version;
213214
String toolset;
214215
String toolchain;
215216
};

src/common/project.cpp

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ DECLARE_STATIC_LOGGER(logger, "project");
4040
using MimeType = String;
4141
using MimeTypes = std::set<MimeType>;
4242

43+
static const std::vector<String> additional_include_dirs_public{
44+
"${BDIR}",
45+
};
46+
47+
static const std::vector<String> additional_include_dirs_private{
48+
"${BDIR_PRIVATE}",
49+
};
50+
4351
const MimeTypes source_mime_types{
4452
"application/xml",
4553
"text/xml",
@@ -1339,7 +1347,8 @@ void Project::load(const yaml &root)
13391347
dirs.push_back("");
13401348
autodetect_source_dir(dirs);
13411349
}
1342-
include_directories.public_.insert("${BDIR}");
1350+
include_directories.public_.insert(additional_include_dirs_public.begin(), additional_include_dirs_public.end());
1351+
include_directories.private_.insert(additional_include_dirs_private.begin(), additional_include_dirs_private.end());
13431352
}
13441353

13451354
// files
@@ -1697,18 +1706,21 @@ String Project::print_cpp()
16971706
ctx.addLine(s);
16981707
}*/
16991708

1700-
if (!include_directories.private_.empty())
1709+
if (include_directories.private_.size() > additional_include_dirs_private.size())
17011710
{
17021711
ctx.addLine(name + ".Private +=");
17031712
String s;
17041713
for (auto &t : include_directories.private_)
1705-
s += "\"" + t.string() + "\"_id,\n";
1714+
{
1715+
if (t.string().find("BDIR") == -1)
1716+
s += "\"" + t.string() + "\"_id,\n";
1717+
}
17061718
s.resize(s.size() - 2);
17071719
s += ";\n";
17081720
ctx.addLine(s);
17091721
}
17101722

1711-
if (include_directories.public_.size() > 1)
1723+
if (include_directories.public_.size() > additional_include_dirs_public.size())
17121724
{
17131725
ctx.addLine(name + ".Public +=");
17141726
String s;
@@ -2008,20 +2020,23 @@ String Project::print_cpp2()
20082020
ctx.decreaseIndent();
20092021
}
20102022

2011-
if (!include_directories.private_.empty())
2023+
if (include_directories.private_.size() > additional_include_dirs_private.size())
20122024
{
20132025
ctx.addLine(name + ".Private +=");
20142026
String s;
20152027
for (auto &t : include_directories.private_)
2016-
s += "\"" + t.string() + "\"_id,\n";
2028+
{
2029+
if (t.string().find("BDIR") == -1)
2030+
s += "\"" + t.string() + "\"_id,\n";
2031+
}
20172032
s.resize(s.size() - 2);
20182033
s += ";\n";
20192034
ctx.increaseIndent();
20202035
ctx.addLine(s);
20212036
ctx.decreaseIndent();
20222037
}
20232038

2024-
if (include_directories.public_.size() > 1)
2039+
if (include_directories.public_.size() > additional_include_dirs_public.size())
20252040
{
20262041
String s;
20272042
for (auto &t : include_directories.public_)

src/common/settings.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ void Settings::load_build(const yaml &root)
256256
YAML_EXTRACT_AUTO(link_libraries);
257257
YAML_EXTRACT_AUTO(configuration);
258258
YAML_EXTRACT_AUTO(generator);
259+
YAML_EXTRACT_AUTO(system_version);
259260
YAML_EXTRACT_AUTO(toolset);
260261
YAML_EXTRACT_AUTO(use_shared_libs);
261262
YAML_EXTRACT_VAR(root, use_shared_libs, "build_shared_libs", bool);
@@ -345,6 +346,7 @@ String Settings::get_hash() const
345346
h |= link_flags_conf[i];
346347
h |= link_libraries;
347348
h |= generator;
349+
h |= system_version;
348350
h |= toolset;
349351
h |= use_shared_libs;
350352
h |= configuration;

src/common/settings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ struct Settings
9090
String configuration{ "Release" };
9191
String default_configuration{ "Release" }; // for global settings
9292
String generator;
93+
String system_version;
9394
String toolset;
9495

9596
std::map<String, String> env;

src/inserts/functions.cmake

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,12 @@ function(get_configuration_unhashed out)
270270
set(bits unk)
271271
endif()
272272

273+
set(sysver)
274+
if (CMAKE_SYSTEM_VERSION)
275+
prepare_config_part(sysver "${CMAKE_SYSTEM_VERSION}")
276+
set(sysver ${CPPAN_CONFIG_PART_DELIMETER}${sysver})
277+
endif()
278+
273279
set(dll)
274280
if (CPPAN_BUILD_SHARED_LIBS)
275281
set(dll ${CPPAN_CONFIG_PART_DELIMETER}dll)
@@ -319,7 +325,7 @@ function(get_configuration_unhashed out)
319325
endif()
320326

321327
set(config ${config}${CPPAN_CONFIG_PART_DELIMETER}${version})
322-
set(config ${config}${CPPAN_CONFIG_PART_DELIMETER}${bits}${msvc_arch}${mt_flag}${dll}${toolset})
328+
set(config ${config}${CPPAN_CONFIG_PART_DELIMETER}${bits}${msvc_arch}${mt_flag}${dll}${sysver}${toolset})
323329
set(config ${config}${configuration})
324330

325331
set(${out} ${config} PARENT_SCOPE)

src/inserts/generate.cmake

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,17 @@ if (NOT EXISTS ${import} OR
185185
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
186186
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
187187
-G \"${generator}\"
188-
-DVARIABLES_FILE=${variables_file}")
188+
-DVARIABLES_FILE=${variables_file}"
189+
-DCMAKE_SYSTEM_VERSION=${CMAKE_SYSTEM_VERSION}
190+
)
189191
execute_process(
190192
COMMAND ${CMAKE_COMMAND}
191193
-H${current_dir} -B${build_dir}
192194
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
193195
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
194196
-G "${generator}"
195197
-DVARIABLES_FILE=${variables_file}
198+
-DCMAKE_SYSTEM_VERSION=${CMAKE_SYSTEM_VERSION}
196199
RESULT_VARIABLE ret
197200
)
198201
check_result_variable(${ret})
@@ -202,7 +205,9 @@ if (NOT EXISTS ${import} OR
202205
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
203206
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
204207
-G \"${generator}\"
205-
-DVARIABLES_FILE=${variables_file}")
208+
-DVARIABLES_FILE=${variables_file}"
209+
-DCMAKE_SYSTEM_VERSION=${CMAKE_SYSTEM_VERSION}
210+
)
206211
execute_process(
207212
COMMAND ${CMAKE_COMMAND}
208213
-H${current_dir} -B${build_dir}
@@ -212,6 +217,7 @@ if (NOT EXISTS ${import} OR
212217
-G "${generator}"
213218
${toolset}
214219
-DVARIABLES_FILE=${variables_file}
220+
-DCMAKE_SYSTEM_VERSION=${CMAKE_SYSTEM_VERSION}
215221
RESULT_VARIABLE ret
216222
)
217223
check_result_variable(${ret})

src/printers/cmake.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,8 @@ void print_sdir_bdir(CMakeContext &ctx, const Package &d)
317317
else
318318
ctx.addLine("set(SDIR ${CMAKE_CURRENT_SOURCE_DIR})");
319319
ctx.addLine("set(BDIR ${CMAKE_CURRENT_BINARY_DIR})");
320+
ctx.addLine("set(BDIR_PRIVATE ${BDIR}/cppan_private)");
321+
ctx.addLine("execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${BDIR_PRIVATE})");
320322
ctx.emptyLines();
321323
}
322324

@@ -1124,6 +1126,8 @@ int CMakePrinter::generate(const BuildSettings &bs) const
11241126
c.args.push_back("-G");
11251127
c.args.push_back(s.generator);
11261128
}
1129+
if (!s.system_version.empty())
1130+
c.args.push_back("-DCMAKE_SYSTEM_VERSION=" + s.system_version);
11271131
if (!s.toolset.empty())
11281132
{
11291133
c.args.push_back("-T");
@@ -2924,6 +2928,7 @@ endif()
29242928
\"${vars_file}\"
29252929
\"${checks_file}\"
29262930
\"${CMAKE_GENERATOR}\"
2931+
\"${CMAKE_SYSTEM_VERSION}\"
29272932
\"${CMAKE_GENERATOR_TOOLSET}\"
29282933
\"${CMAKE_TOOLCHAIN_FILE}\"
29292934
)"s;
@@ -3082,6 +3087,8 @@ void CMakePrinter::parallel_vars_check(const ParallelCheckOptions &o) const
30823087
c.args.push_back("-B" + normalize_path(d));
30833088
c.args.push_back("-G");
30843089
c.args.push_back(o.generator);
3090+
if (!o.system_version.empty())
3091+
c.args.push_back("-DCMAKE_SYSTEM_VERSION=" + o.system_version);
30853092
if (!o.toolset.empty())
30863093
{
30873094
c.args.push_back("-T");

0 commit comments

Comments
 (0)