Skip to content

Commit 0039305

Browse files
committed
Fix PACKAGE_VERSION_NUMs. Do not emit error on copying local package's CMakeFiles.
1 parent 47c384d commit 0039305

5 files changed

Lines changed: 42 additions & 10 deletions

File tree

src/common/database.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,11 @@ void ServiceDatabase::performStartupActions() const
502502
remove_all_from_dir(directories.storage_dir_exp);
503503
}
504504

505+
if (a.action & StartupAction::ClearStorageDirTmp)
506+
{
507+
remove_all_from_dir(directories.storage_dir_tmp);
508+
}
509+
505510
if (a.action & StartupAction::ClearStorageDirObj)
506511
{
507512
remove_all_from_dir(directories.storage_dir_obj);

src/common/database.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ struct StartupAction
5252
ClearCfgDirs = (1 << 6),
5353
ClearPackagesDatabase = (1 << 7),
5454
ClearStorageDirObj = (1 << 8),
55+
ClearStorageDirTmp = (1 << 9),
5556
};
5657

5758
int id;

src/inserts/functions.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,6 @@ function(get_configuration_unhashed out)
331331
endif()
332332
endif()
333333

334-
335334
# add suffix (configuration) to distinguish build types
336335
# for non VS/XCODE builds
337336
set(configuration)

src/inserts/generate.cmake

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ if (NOT EXISTS ${import} OR
8585
# BUG: copying bad cmake config dirs (32 - 64 bits)
8686
#set(from ${storage_dir_cfg}/${config_dir}/CMakeFiles/${CMAKE_VERSION})
8787
set(from ${CMAKE_BINARY_DIR}/CMakeFiles/${CMAKE_VERSION})
88+
#upd2 - still unknown reason here ^
89+
#do not enable
8890
else()
8991
set(from ${CMAKE_BINARY_DIR}/CMakeFiles/${CMAKE_VERSION})
9092
endif()
@@ -170,6 +172,9 @@ if (NOT EXISTS ${import} OR
170172
message(STATUS "Preparing build tree for ${target} (${config_unhashed} - ${config_dir} - ${generator})")
171173
#message(STATUS "")
172174

175+
# we also pass toolset everywhere because of MSVC's or CMake bugs with Hostx86/x64 toolchains
176+
# when you cannot just invoke it as pure x86 or x64 thing.
177+
173178
# call cmake
174179
if (EXECUTABLE)# AND NOT CPPAN_BUILD_EXECUTABLES_WITH_SAME_CONFIG)
175180
# build with the same compiler, generator and linker (in some cases)
@@ -180,6 +185,7 @@ if (NOT EXISTS ${import} OR
180185
-DCMAKE_CXX_COMPILER=${CPPAN_HOST_CXX_COMPILER}
181186
-DVARIABLES_FILE=${variables_file}
182187
-G \"${generator}\""
188+
#${toolset}"
183189
)
184190
execute_process(
185191
COMMAND ${CMAKE_COMMAND}
@@ -188,6 +194,7 @@ if (NOT EXISTS ${import} OR
188194
-DCMAKE_CXX_COMPILER=${CPPAN_HOST_CXX_COMPILER}
189195
-DVARIABLES_FILE=${variables_file}
190196
-G "${generator}"
197+
#${toolset}
191198
RESULT_VARIABLE ret
192199
)
193200
else()
@@ -198,6 +205,7 @@ if (NOT EXISTS ${import} OR
198205
${linker}
199206
-DVARIABLES_FILE=${variables_file}
200207
-G \"${generator}\""
208+
#${toolset}"
201209
)
202210
execute_process(
203211
COMMAND ${CMAKE_COMMAND}
@@ -207,6 +215,7 @@ if (NOT EXISTS ${import} OR
207215
${linker}
208216
-DVARIABLES_FILE=${variables_file}
209217
-G "${generator}"
218+
#${toolset}
210219
RESULT_VARIABLE ret
211220
)
212221
endif()
@@ -217,6 +226,7 @@ if (NOT EXISTS ${import} OR
217226
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
218227
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
219228
-G \"${generator}\"
229+
#${toolset}
220230
-DVARIABLES_FILE=${variables_file}
221231
${sysver}"
222232
)
@@ -226,6 +236,7 @@ if (NOT EXISTS ${import} OR
226236
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
227237
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
228238
-G "${generator}"
239+
#${toolset}
229240
-DVARIABLES_FILE=${variables_file}
230241
${sysver}
231242
RESULT_VARIABLE ret
@@ -236,6 +247,7 @@ if (NOT EXISTS ${import} OR
236247
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
237248
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
238249
-G \"${generator}\"
250+
${toolset}
239251
-DVARIABLES_FILE=${variables_file}
240252
${sysver}"
241253
)

src/printers/cmake.cpp

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,6 +1358,9 @@ int CMakePrinter::generate(const BuildSettings &bs) const
13581358
{
13591359
c.args.push_back("-G");
13601360
c.args.push_back(s.generator);
1361+
1362+
//if (s.generator.find("Win64") != s.generator.npos)
1363+
//c.args.push_back("-Thost=x64");
13611364
}
13621365
if (!s.system_version.empty())
13631366
c.args.push_back("-DCMAKE_SYSTEM_VERSION=" + s.system_version);
@@ -1656,10 +1659,19 @@ void CMakePrinter::print_settings(CMakeContext &ctx) const
16561659
ctx.addLine("set(PACKAGE_BUGREPORT)");
16571660
ctx.addLine();
16581661

1662+
// returns 0x010203
16591663
auto n2hex = [](int n, int w)
16601664
{
16611665
std::ostringstream ss;
1662-
ss << std::hex << std::setfill('0') << std::setw(w) << n;
1666+
ss << n / 10 << n % 10;
1667+
return ss.str();
1668+
};
1669+
1670+
// returns 0x000100020003
1671+
auto n4hex = [](int n, int w)
1672+
{
1673+
std::ostringstream ss;
1674+
ss << n / 1000 << n / 100 << n / 10 << n % 10;
16631675
return ss.str();
16641676
};
16651677

@@ -1670,17 +1682,17 @@ void CMakePrinter::print_settings(CMakeContext &ctx) const
16701682
}
16711683
else
16721684
{
1673-
auto ver2hex = [this, &n2hex](int n)
1685+
auto ver2hex = [this](int n, auto f)
16741686
{
16751687
std::ostringstream ss;
1676-
ss << n2hex(d.version.major, n);
1677-
ss << n2hex(d.version.minor, n);
1678-
ss << n2hex(d.version.patch, n);
1688+
ss << f(d.version.major, n);
1689+
ss << f(d.version.minor, n);
1690+
ss << f(d.version.patch, n);
16791691
return ss.str();
16801692
};
16811693

1682-
ctx.addLine("set(PACKAGE_VERSION_NUM \"0x" + ver2hex(2) + "\")");
1683-
ctx.addLine("set(PACKAGE_VERSION_NUM2 \"0x" + ver2hex(4) + "LL\")");
1694+
ctx.addLine("set(PACKAGE_VERSION_NUM \"0x" + ver2hex(2, n2hex) + "\")");
1695+
ctx.addLine("set(PACKAGE_VERSION_NUM2 \"0x" + ver2hex(4, n4hex) + "LL\")");
16841696
}
16851697
ctx.addLine();
16861698

@@ -1777,11 +1789,14 @@ void CMakePrinter::print_settings(CMakeContext &ctx) const
17771789
ctx.addLine();
17781790

17791791
// copy exe cmake settings
1780-
ctx.if_("EXECUTABLE AND CPPAN_USE_CACHE");
1792+
ctx.if_("EXECUTABLE AND CPPAN_USE_CACHE AND NOT CPPAN_LOCAL_PROJECT");
17811793
ctx.addLine("set(to \"" + normalize_path(directories.storage_dir_cfg) + "/${config}/CMakeFiles/${CMAKE_VERSION}\")");
1794+
ctx.addLine("set(from \"${PROJECT_BINARY_DIR}/CMakeFiles/${CMAKE_VERSION}\")");
1795+
// probably this is incorrect because from dir must be there always
1796+
//ctx.if_("NOT EXISTS ${to} AND EXISTS ${from}");
17821797
ctx.if_("NOT EXISTS ${to}");
17831798
ctx.addLine("execute_process(");
1784-
ctx.addLine("COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_BINARY_DIR}/CMakeFiles/${CMAKE_VERSION} ${to}");
1799+
ctx.addLine("COMMAND ${CMAKE_COMMAND} -E copy_directory ${from} ${to}");
17851800
ctx.addLine(" RESULT_VARIABLE ret");
17861801
ctx.addLine(")");
17871802
ctx.endif();

0 commit comments

Comments
 (0)