Skip to content

Commit bef1b80

Browse files
committed
libigl boost fix
1 parent 1830b1d commit bef1b80

File tree

3 files changed

+104
-0
lines changed

3 files changed

+104
-0
lines changed

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ endif()
3535

3636
list(PREPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
3737

38+
include(boost)
39+
include(eigen)
40+
3841
# Optionally get multiprecision libraries
3942
if(USE_MULTIPRECISION)
4043
# Turning this on activates mpfr in the conformal code

cmake/CPM.cmake

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
set(CPM_DOWNLOAD_VERSION 0.38.1)
2+
3+
if(CPM_SOURCE_CACHE)
4+
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
5+
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
6+
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
7+
else()
8+
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
9+
endif()
10+
11+
# Expand relative path. This is important if the provided path contains a tilde (~)
12+
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)
13+
14+
function(download_cpm)
15+
message(STATUS "Downloading CPM.cmake to ${CPM_DOWNLOAD_LOCATION}")
16+
file(DOWNLOAD
17+
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
18+
${CPM_DOWNLOAD_LOCATION}
19+
)
20+
endfunction()
21+
22+
if(NOT (EXISTS ${CPM_DOWNLOAD_LOCATION}))
23+
download_cpm()
24+
else()
25+
# resume download if it previously failed
26+
file(READ ${CPM_DOWNLOAD_LOCATION} check)
27+
if("${check}" STREQUAL "")
28+
download_cpm()
29+
endif()
30+
unset(check)
31+
endif()
32+
33+
include(${CPM_DOWNLOAD_LOCATION})

cmake/boost.cmake

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#
2+
# Copyright 2021 Adobe. All rights reserved.
3+
# This file is licensed to you under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License. You may obtain a copy
5+
# of the License at http://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software distributed under
8+
# the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9+
# OF ANY KIND, either express or implied. See the License for the specific language
10+
# governing permissions and limitations under the License.
11+
#
12+
if(TARGET Boost::boost)
13+
return()
14+
endif()
15+
16+
message(STATUS "Third-party: creating targets 'Boost::boost'...")
17+
18+
set(PREVIOUS_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
19+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
20+
set(OLD_CMAKE_POSITION_INDEPENDENT_CODE ${CMAKE_POSITION_INDEPENDENT_CODE})
21+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
22+
23+
set(BOOST_URL
24+
"https://archives.boost.io/release/1.83.0/source/boost_1_83_0.tar.bz2"
25+
CACHE STRING "Boost download URL")
26+
set(BOOST_URL_SHA256 "6478edfe2f3305127cffe8caf73ea0176c53769f4bf1585be237eb30798c3b8e" CACHE STRING "Boost download URL SHA256 checksum")
27+
28+
include(CPM)
29+
CPMAddPackage(
30+
NAME boost
31+
URL ${BOOST_URL}
32+
URL_HASH SHA256=${BOOST_URL_SHA256}
33+
DOWNLOAD_ONLY ON
34+
)
35+
set(BOOST_SOURCE ${boost_SOURCE_DIR})
36+
set(Boost_POPULATED ON)
37+
38+
# Only build the following Boost libs
39+
set(BOOST_LIBS_OPTIONAL "" CACHE STRING "Boost libs to be compiled" FORCE)
40+
41+
# File lcid.cpp from Boost_locale.cpp doesn't compile on MSVC, so we exclude them from the default
42+
# targets being built by the project (only targets explicitly used by other targets will be built).
43+
CPMAddPackage(
44+
NAME boost-cmake
45+
GITHUB_REPOSITORY Orphis/boost-cmake
46+
GIT_TAG 7f97a08b64bd5d2e53e932ddf80c40544cf45edf
47+
EXCLUDE_FROM_ALL
48+
)
49+
50+
set(CMAKE_POSITION_INDEPENDENT_CODE ${OLD_CMAKE_POSITION_INDEPENDENT_CODE})
51+
set(CMAKE_CXX_FLAGS "${PREVIOUS_CMAKE_CXX_FLAGS}")
52+
53+
foreach(name IN ITEMS
54+
atomic
55+
chrono
56+
container
57+
date_time
58+
filesystem
59+
iostreams
60+
log
61+
system
62+
thread
63+
timer
64+
)
65+
if(TARGET Boost_${name})
66+
set_target_properties(Boost_${name} PROPERTIES FOLDER third_party/boost)
67+
endif()
68+
endforeach()

0 commit comments

Comments
 (0)