Skip to content

Commit 8910da1

Browse files
committed
works on linux
1 parent b70fcd1 commit 8910da1

File tree

4 files changed

+79
-51
lines changed

4 files changed

+79
-51
lines changed

cmake/BoostLibInstaller.cmake

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ function(boost_lib_installer req_boost_version req_boost_libs)
3434
set(b2_command b2.exe)
3535
file(TO_CMAKE_PATH "${install_dir}/b2.exe" b2_path)
3636
else(WIN32)
37-
set(bootstrap sh bootstrap.sh)
38-
set(b2_command b2)
37+
set(bootstrap ./bootstrap.sh)
38+
set(b2_command ./b2)
3939
file(TO_CMAKE_PATH "${install_dir}/b2" b2_path)
4040
endif(WIN32)
4141
if (NOT EXISTS "${b2_path}")
@@ -54,10 +54,14 @@ function(boost_lib_installer req_boost_version req_boost_libs)
5454
endif()
5555

5656
# Process libs
57-
if(CMAKE_CL_64 EQUAL 1)
58-
set(stage_dir stage64)
57+
if(MSVC)
58+
if(CMAKE_CL_64 EQUAL 1)
59+
set(stage_dir stage64)
60+
else()
61+
set(stage_dir stage32)
62+
endif()
5963
else()
60-
set(stage_dir stage32)
64+
set(stage_dir stage)
6165
endif()
6266

6367
get_boots_lib_b2_args()
@@ -117,9 +121,15 @@ function(boost_lib_installer req_boost_version req_boost_libs)
117121
IMPORTED_LOCATION "${install_dir}/${stage_dir}/lib/libboost_${ComponentLibName}-${CompilerName}-mt-${lib_postfix}.lib"
118122
LINKER_LANGUAGE CXX)
119123
else()
120-
set_target_properties(${boost_lib} PROPERTIES
121-
IMPORTED_LOCATION "${install_dir}/${stage_dir}/lib/libboost_${ComponentLibName}-mt.a"
122-
LINKER_LANGUAGE CXX)
124+
if((CMAKE_BUILD_TYPE STREQUAL "Debug") OR (CMAKE_BUILD_TYPE STREQUAL "") OR (NOT DEFINED CMAKE_BUILD_TYPE))
125+
set_target_properties(${boost_lib} PROPERTIES
126+
IMPORTED_LOCATION "${install_dir}/${stage_dir}/lib/libboost_${ComponentLibName}-mt-d.a"
127+
LINKER_LANGUAGE CXX)
128+
else()
129+
set_target_properties(${boost_lib} PROPERTIES
130+
IMPORTED_LOCATION "${install_dir}/${stage_dir}/lib/libboost_${ComponentLibName}-mt.a"
131+
LINKER_LANGUAGE CXX)
132+
endif()
123133
endif()
124134

125135
set_target_properties(${jam_lib} ${boost_lib} PROPERTIES

cmake/GetBoostLibB2Args.cmake

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
function(get_boots_lib_b2_args)
2-
if(CMAKE_CL_64 EQUAL 1)
3-
set(stage_dir stage64)
2+
if(MSVC)
3+
if(CMAKE_CL_64 EQUAL 1)
4+
set(stage_dir stage64)
5+
else()
6+
set(stage_dir stage32)
7+
endif()
48
else()
5-
set(stage_dir stage32)
9+
set(stage_dir stage)
610
endif()
711

812
set(b2Args link=static
@@ -15,9 +19,9 @@ function(get_boots_lib_b2_args)
1519
--hash)
1620

1721
message(STATUS "Generating b2 args.")
18-
22+
1923
if(NOT MSVC)
20-
if((CMAKE_BUILD_TYPE STREQUAL "Debug") OR (NOT DEFINED CMAKE_BUILD_TYPE))
24+
if((CMAKE_BUILD_TYPE STREQUAL "Debug") OR (CMAKE_BUILD_TYPE STREQUAL "") OR (NOT DEFINED CMAKE_BUILD_TYPE))
2125
message(STATUS "\tvariant=debug")
2226
list(APPEND b2Args "variant=debug")
2327
else()

lib/boostDownloader.js

Lines changed: 48 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var zlib = require("zlib");
1111
var tar = require("tar");
1212
var request = require("request");
1313

14-
function downloadTo (url, result) {
14+
function downloadTo(url, result) {
1515
return new Bluebird(function (resolve, reject) {
1616
request
1717
.get(url)
@@ -22,7 +22,7 @@ function downloadTo (url, result) {
2222
});
2323
}
2424

25-
function BoostDownloader (options) {
25+
function BoostDownloader(options) {
2626
this.options = options;
2727
this.dir = path.join(environment.home, ".cmake-js", "boost");
2828
this.version = options.version;
@@ -36,7 +36,7 @@ BoostDownloader.prototype.ensureDownloaded = function () {
3636
var self = this;
3737
self.log.info("BOOST", "Searching for Boost " + self.version + " in '" + self.dir + "'.");
3838
return fs.mkdirpAsync(self.dir)
39-
.then(function() {
39+
.then(function () {
4040
return fs.readdirAsync(self.dir)
4141
})
4242
.then(function (files) {
@@ -81,7 +81,7 @@ BoostDownloader.prototype.ensureDownloaded = function () {
8181
if (stat.isFile()) {
8282
self.log.verbose("BOOST", "Deployment already downloaded. Checking submodules.");
8383
return self._downloadSubmodules(semver.valid(path.basename(foundDir)), foundDir)
84-
.then(function() {
84+
.then(function () {
8585
return foundDir;
8686
});
8787
}
@@ -119,10 +119,10 @@ BoostDownloader.prototype._download = function () {
119119
}
120120
if (downloadVersion) {
121121
self._downloadVersion(downloadVersion)
122-
.then(function(result) {
122+
.then(function (result) {
123123
resolve(result);
124124
})
125-
.catch(function(e) {
125+
.catch(function (e) {
126126
reject(e);
127127
});
128128
}
@@ -157,7 +157,7 @@ BoostDownloader.prototype._downloadVersion = function (version) {
157157
});
158158

159159
return fs.mkdirpAsync(internalPath)
160-
.then(function() {
160+
.then(function () {
161161
return new Bluebird(function (resolve, reject) {
162162
extracter.once("end", function () {
163163
self.log.verbose("BOOST", "Downloaded: " + internalPath);
@@ -174,7 +174,7 @@ BoostDownloader.prototype._downloadVersion = function (version) {
174174
.then(function () {
175175
return self._downloadSubmodules(version, internalPath);
176176
})
177-
.then(function() {
177+
.then(function () {
178178
return internalPath;
179179
});
180180
};
@@ -185,46 +185,56 @@ BoostDownloader.prototype._downloadSubmodules = function (version, internalPath)
185185
self.log.verbose("BOOST", "Checking tools.");
186186
task.push(self._downloadSubmo(version, path.join(internalPath, "tools"), "build"));
187187
task.push(self._downloadSubmo(version, path.join(internalPath, "tools"), "inspect"));
188-
var libsPath = path.join(internalPath, "libs");
189-
var done = 0;
190-
task.push(
191-
fs.readdirAsync(libsPath)
192-
.then(function (libs) {
193-
self.log.verbose("BOOST", "Checking " + libs.length + " libs.");
194-
var libTasks = [];
195-
libs.forEach(function (lib) {
196-
var fullLibPath = path.join(libsPath, lib);
197-
var stat = fs.lstatSync(fullLibPath);
198-
if (stat.isDirectory()) {
199-
libTasks.push(
200-
self._downloadSubmo(version, libsPath, lib)
201-
.then(function(internalPath) {
202-
++done;
203-
if (internalPath) {
204-
self.log.info("BOOST", ((done / libTasks.length) * 100).toFixed(1) + "% - Downloaded: " + internalPath);
205-
}
206-
else {
207-
self.log.verbose("BOOST", ((done / libTasks.length) * 100).toFixed(1) + "% - submodule " + lib + " exists.");
208-
}
209-
}));
210-
}
211-
});
212-
return Bluebird.all(libTasks);
213-
}));
214-
return Bluebird.all(task);
188+
function downloadAt(libsPath, prefix) {
189+
var dirName = path.basename(libsPath);
190+
prefix = prefix || "";
191+
self.log.info("BOOST", "Downloading submodules of director '" + dirName + "'.");
192+
var done = 0;
193+
task.push(
194+
fs.readdirAsync(libsPath)
195+
.then(function (libs) {
196+
self.log.verbose("BOOST", "Checking " + libs.length + " libs.");
197+
var libTasks = [];
198+
libs.forEach(function (lib) {
199+
var fullLibPath = path.join(libsPath, lib);
200+
var stat = fs.lstatSync(fullLibPath);
201+
if (stat.isDirectory()) {
202+
libTasks.push(
203+
self._downloadSubmo(version, libsPath, lib, prefix)
204+
.then(function (internalPath) {
205+
++done;
206+
if (internalPath) {
207+
self.log.info("BOOST", ((done / libTasks.length) * 100).toFixed(1) + "% - submodule " + dirName + "/" + lib + " downloaded.");
208+
}
209+
else {
210+
self.log.verbose("BOOST", ((done / libTasks.length) * 100).toFixed(1) + "% - submodule " + dirName + "/" + lib + " exists.");
211+
}
212+
}));
213+
}
214+
});
215+
return Bluebird.all(libTasks);
216+
}));
217+
return Bluebird.all(task);
218+
}
219+
220+
return downloadAt(path.join(internalPath, "libs"))
221+
.then(function () {
222+
return downloadAt(path.join(internalPath, "libs", "numeric"), "numeric_");
223+
});
215224
};
216225

217-
BoostDownloader.prototype._downloadSubmo = function (version, internalPath, name) {
226+
BoostDownloader.prototype._downloadSubmo = function (version, internalPath, name, prefix) {
218227
var self = this;
228+
prefix = prefix || "";
219229
internalPath = path.join(internalPath, name);
220230

221231
return fs.readdirAsync(internalPath)
222-
.then(function(entries) {
232+
.then(function (entries) {
223233
if (entries && entries.length) {
224234
return;
225235
}
226236

227-
var downloadUrl = "https://github.com/boostorg/" + name + "/archive/boost-" + version + ".tar.gz";
237+
var downloadUrl = "https://github.com/boostorg/" + prefix + name + "/archive/boost-" + version + ".tar.gz";
228238
self.log.http("BOOST", "Downloading: " + downloadUrl);
229239

230240
var gunzip = zlib.createGunzip();

tests/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ if(CMAKE_CL_64 EQUAL 0)
88
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO")
99
endif()
1010

11+
if(UNIX)
12+
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
13+
endif()
14+
1115
require_boost_libs(1.58.0 "coroutine;optional")
1216

1317
include_directories(${Boost_INCLUDE_DIRS})

0 commit comments

Comments
 (0)