Skip to content

Commit 2c9ae96

Browse files
committed
headeronly support
1 parent c38566b commit 2c9ae96

File tree

3 files changed

+104
-102
lines changed

3 files changed

+104
-102
lines changed

cmake/BoostLibInstaller.cmake

Lines changed: 102 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -54,119 +54,121 @@ function(boost_lib_installer req_boost_version req_boost_libs)
5454
endif()
5555

5656
# Process libs
57-
if(MSVC)
58-
if(CMAKE_CL_64 EQUAL 1)
59-
set(stage_dir stage64)
57+
if(req_boost_libs)
58+
if(MSVC)
59+
if(CMAKE_CL_64 EQUAL 1)
60+
set(stage_dir stage64)
61+
else()
62+
set(stage_dir stage32)
63+
endif()
6064
else()
61-
set(stage_dir stage32)
65+
set(stage_dir stage)
6266
endif()
63-
else()
64-
set(stage_dir stage)
65-
endif()
66-
67-
get_boots_lib_b2_args()
68-
message(STATUS "b2 args: ${b2Args}")
6967

70-
# Resolve dependency tree
71-
foreach(i RANGE 4)
72-
foreach(lib ${req_boost_libs})
73-
list(APPEND req_boost_libs2 ${lib})
74-
list(APPEND req_boost_libs2 ${${lib}_dep})
68+
get_boots_lib_b2_args()
69+
message(STATUS "b2 args: ${b2Args}")
70+
71+
# Resolve dependency tree
72+
foreach(i RANGE 4)
73+
foreach(lib ${req_boost_libs})
74+
list(APPEND req_boost_libs2 ${lib})
75+
list(APPEND req_boost_libs2 ${${lib}_dep})
76+
endforeach()
77+
list(REMOVE_DUPLICATES req_boost_libs2)
78+
set(req_boost_libs "${req_boost_libs2}")
7579
endforeach()
76-
list(REMOVE_DUPLICATES req_boost_libs2)
77-
set(req_boost_libs "${req_boost_libs2}")
78-
endforeach()
79-
80-
foreach(lib ${req_boost_libs})
81-
message(STATUS "Resolving Boost library: ${lib}")
82-
83-
if (EXISTS "${install_dir}/libs/${lib}/build/")
84-
# Has source
85-
86-
# Setup variables
87-
set(jam_lib boost_${lib}_jam)
88-
set(boost_lib boost_${lib})
89-
if(lib STREQUAL "test")
90-
set(lib_name unit_test_framework)
91-
else()
92-
set(lib_name ${lib})
93-
endif()
94-
95-
if(MSVC)
96-
if(MSVC11)
97-
set(compiler_name vc110)
98-
elseif(MSVC12)
99-
set(compiler_name vc120)
100-
elseif(MSVC14)
101-
set(compiler_name vc140)
80+
81+
foreach(lib ${req_boost_libs})
82+
message(STATUS "Resolving Boost library: ${lib}")
83+
84+
if (EXISTS "${install_dir}/libs/${lib}/build/")
85+
# Has source
86+
87+
# Setup variables
88+
set(jam_lib boost_${lib}_jam)
89+
set(boost_lib boost_${lib})
90+
if(lib STREQUAL "test")
91+
set(lib_name unit_test_framework)
92+
else()
93+
set(lib_name ${lib})
10294
endif()
103-
104-
set(debug_lib_path "${install_dir}/${stage_dir}/lib/libboost_${lib_name}-${compiler_name}-mt-gd-${lib_postfix}.lib")
105-
set(lib_path "${install_dir}/${stage_dir}/lib/libboost_${lib_name}-${compiler_name}-mt-${lib_postfix}.lib")
106-
else()
107-
if((CMAKE_BUILD_TYPE STREQUAL "Debug") OR (CMAKE_BUILD_TYPE STREQUAL "") OR (NOT DEFINED CMAKE_BUILD_TYPE))
108-
set(lib_path "${install_dir}/${stage_dir}/lib/libboost_${lib_name}-mt-d.a")
95+
96+
if(MSVC)
97+
if(MSVC11)
98+
set(compiler_name vc110)
99+
elseif(MSVC12)
100+
set(compiler_name vc120)
101+
elseif(MSVC14)
102+
set(compiler_name vc140)
103+
endif()
104+
105+
set(debug_lib_path "${install_dir}/${stage_dir}/lib/libboost_${lib_name}-${compiler_name}-mt-gd-${lib_postfix}.lib")
106+
set(lib_path "${install_dir}/${stage_dir}/lib/libboost_${lib_name}-${compiler_name}-mt-${lib_postfix}.lib")
109107
else()
110-
set(lib_path "${install_dir}/${stage_dir}/lib/libboost_${lib_name}-mt.a")
108+
if((CMAKE_BUILD_TYPE STREQUAL "Debug") OR (CMAKE_BUILD_TYPE STREQUAL "") OR (NOT DEFINED CMAKE_BUILD_TYPE))
109+
set(lib_path "${install_dir}/${stage_dir}/lib/libboost_${lib_name}-mt-d.a")
110+
else()
111+
set(lib_path "${install_dir}/${stage_dir}/lib/libboost_${lib_name}-mt.a")
112+
endif()
111113
endif()
112-
endif()
113114

114-
# Create lib
115-
if(EXISTS ${lib_path})
116-
message(STATUS "Library ${lib} already built.")
117-
# Dummy project:
118-
ExternalProject_Add(
119-
"${jam_lib}"
120-
STAMP_DIR "${CMAKE_BINARY_DIR}/boost-${req_boost_version}"
121-
SOURCE_DIR "${install_dir}"
122-
BINARY_DIR "${install_dir}"
123-
CONFIGURE_COMMAND ""
124-
BUILD_COMMAND ""
125-
INSTALL_COMMAND ""
126-
BUILD_BYPRODUCTS "${lib_path}"
127-
LOG_BUILD OFF)
128-
else()
129-
message(STATUS "Setting up external project to build ${lib}.")
130-
ExternalProject_Add(
131-
"${jam_lib}"
132-
STAMP_DIR "${CMAKE_BINARY_DIR}/boost-${req_boost_version}"
133-
SOURCE_DIR "${install_dir}"
134-
BINARY_DIR "${install_dir}"
135-
CONFIGURE_COMMAND ""
136-
BUILD_COMMAND "${b2_command}" "${b2Args}" --with-${lib}
137-
INSTALL_COMMAND ""
138-
BUILD_BYPRODUCTS "${lib_path}"
139-
LOG_BUILD ON)
140-
endif()
141-
142-
add_library(${boost_lib} STATIC IMPORTED GLOBAL)
143-
144-
if(MSVC)
145-
set_target_properties(${boost_lib} PROPERTIES
146-
IMPORTED_LOCATION_DEBUG "${debug_lib_path}"
147-
IMPORTED_LOCATION "${lib_path}"
148-
LINKER_LANGUAGE CXX)
149-
else()
150-
set_target_properties(${boost_lib} PROPERTIES
151-
IMPORTED_LOCATION "${lib_path}"
152-
LINKER_LANGUAGE CXX)
153-
endif()
115+
# Create lib
116+
if(EXISTS ${lib_path})
117+
message(STATUS "Library ${lib} already built.")
118+
# Dummy project:
119+
ExternalProject_Add(
120+
"${jam_lib}"
121+
STAMP_DIR "${CMAKE_BINARY_DIR}/boost-${req_boost_version}"
122+
SOURCE_DIR "${install_dir}"
123+
BINARY_DIR "${install_dir}"
124+
CONFIGURE_COMMAND ""
125+
BUILD_COMMAND ""
126+
INSTALL_COMMAND ""
127+
BUILD_BYPRODUCTS "${lib_path}"
128+
LOG_BUILD OFF)
129+
else()
130+
message(STATUS "Setting up external project to build ${lib}.")
131+
ExternalProject_Add(
132+
"${jam_lib}"
133+
STAMP_DIR "${CMAKE_BINARY_DIR}/boost-${req_boost_version}"
134+
SOURCE_DIR "${install_dir}"
135+
BINARY_DIR "${install_dir}"
136+
CONFIGURE_COMMAND ""
137+
BUILD_COMMAND "${b2_command}" "${b2Args}" --with-${lib}
138+
INSTALL_COMMAND ""
139+
BUILD_BYPRODUCTS "${lib_path}"
140+
LOG_BUILD ON)
141+
endif()
154142

155-
# Exlude it from all
156-
set_target_properties(${jam_lib} ${boost_lib} PROPERTIES LABELS Boost EXCLUDE_FROM_ALL TRUE)
143+
add_library(${boost_lib} STATIC IMPORTED GLOBAL)
157144

158-
# Setup dependencies
159-
add_dependencies(${boost_lib} ${jam_lib})
160-
foreach(dep_lib ${${lib}_dep})
161-
message(STATUS "Setting ${boost_lib} dependent on boost_${dep_lib}")
162-
add_dependencies(${boost_lib} boost_${dep_lib})
163-
endforeach()
145+
if(MSVC)
146+
set_target_properties(${boost_lib} PROPERTIES
147+
IMPORTED_LOCATION_DEBUG "${debug_lib_path}"
148+
IMPORTED_LOCATION "${lib_path}"
149+
LINKER_LANGUAGE CXX)
150+
else()
151+
set_target_properties(${boost_lib} PROPERTIES
152+
IMPORTED_LOCATION "${lib_path}"
153+
LINKER_LANGUAGE CXX)
154+
endif()
164155

165-
list(APPEND boost_libs ${boost_lib})
156+
# Exlude it from all
157+
set_target_properties(${jam_lib} ${boost_lib} PROPERTIES LABELS Boost EXCLUDE_FROM_ALL TRUE)
166158

167-
endif()
159+
# Setup dependencies
160+
add_dependencies(${boost_lib} ${jam_lib})
161+
foreach(dep_lib ${${lib}_dep})
162+
message(STATUS "Setting ${boost_lib} dependent on boost_${dep_lib}")
163+
add_dependencies(${boost_lib} boost_${dep_lib})
164+
endforeach()
165+
166+
list(APPEND boost_libs ${boost_lib})
168167

169-
endforeach()
168+
endif()
169+
170+
endforeach()
171+
endif(req_boost_libs)
170172

171173
if(boost_libs)
172174
message(STATUS "Boost libs scheduled for build: ${boost_libs}")

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "boost-lib",
3-
"version": "0.9.0",
3+
"version": "0.9.1",
44
"description": "Boost dependency manager for CMake.js based native modules",
55
"license": "MIT",
66
"keywords": [

tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ if(UNIX)
1212
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
1313
endif()
1414

15-
require_boost_libs(1.58.0 "coroutine;optional")
15+
require_boost_libs(1.58.0 coroutine;optional)
1616

1717
include_directories(${Boost_INCLUDE_DIRS})
1818
file(GLOB src "main.cpp")

0 commit comments

Comments
 (0)