Skip to content

Commit 4f504c9

Browse files
fuhlig1dennisklein
authored andcommitted
[legacy] boost: find needed libs on macosx
When brew installs software to a directory other than /usr/local boost can't find the packages since they are not in the default search paths. This is the case on Apple silicon. Let CMake find the packages and pass the proper information to the boost build process. Add CMake module to find the ZSTD installation.
1 parent f26c4e7 commit 4f504c9

File tree

4 files changed

+117
-1
lines changed

4 files changed

+117
-1
lines changed

FairSoftConfig.cmake

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,16 @@ if(APPLE)
7979
string(STRIP "${macos_sdk_path}" macos_sdk_path)
8080
set(CMAKE_OSX_SYSROOT "${macos_sdk_path}" CACHE FILEPATH "macOS SDK" FORCE)
8181
endif()
82+
83+
#
84+
# LZMA and ZSTD
85+
#
86+
# On macOS both packages aren't installed in some standard system path
87+
# so we need to give CMake some hints where to find them.
88+
# On Linux the packages are in the default system paths and are found
89+
# automatically.
90+
if(APPLE)
91+
execute_process(COMMAND brew --prefix OUTPUT_VARIABLE brew_prefix)
92+
set(LibLZMA_ROOT ${brew_prefix})
93+
set(ZSTD_ROOT ${brew_prefix})
94+
endif()

cmake/FindZSTD.cmake

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
################################################################################
2+
# Copyright (C) 2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
3+
# #
4+
# This software is distributed under the terms of the #
5+
# GNU Lesser General Public Licence (LGPL) version 3, #
6+
# copied verbatim in the file "LICENSE" #
7+
################################################################################
8+
#[=======================================================================[
9+
FindZSTD
10+
-----------
11+
12+
Find ZSTD compression algorithm headers and library.
13+
14+
Result variables
15+
^^^^^^^^^^^^^^^^
16+
17+
This module will set the following variables in your project:
18+
19+
``ZSTD_FOUND``
20+
True if libzstd headers and library were found.
21+
``ZSTD_INCLUDE_DIR``
22+
Directory where libzstd headers are located.
23+
``ZSTD_LIBRARY``
24+
Zstd library to link against.
25+
``ZSTD_BINARY``
26+
Zstd binary
27+
``ZSTD_VERSION``
28+
the version of ZSTD found.
29+
#]=======================================================================]
30+
31+
find_path(ZSTD_INCLUDE_DIR zstd.h)
32+
33+
if(NOT ZSTD_LIBRARY)
34+
find_library(ZSTD_LIBRARY NAMES zstd lzstd libzstd NAMES_PER_DIR PATH_SUFFIXES lib)
35+
endif()
36+
37+
if(NOT ZSTD_BINARY)
38+
find_program(ZSTD_BINARY NAMES zstd NAMES_PER_DIR PATH_SUFFIXES bin)
39+
endif()
40+
41+
if(ZSTD_BINARY)
42+
execute_process(COMMAND ${ZSTD_BINARY} --version
43+
OUTPUT_VARIABLE zstd_version
44+
)
45+
string(REGEX REPLACE "^.*([0-9]\\.[0-9]\\.[0-9])+.*" "\\1" zstd_version1 "${zstd_version}")
46+
set(ZSTD_VERSION "${zstd_version1}" CACHE STRING "ZSTD version info for Boost" FORCE)
47+
elseif(ZSTD_INCLUDE_DIR)
48+
file(READ ${ZSTD_INCLUDE_DIR}/zstd.h ZSTD_VERSION_INFO)
49+
string(REGEX REPLACE ".*#define[ ]+ZSTD_VERSION_MAJOR[ ]+([0-9]+).*" "\\1" ZSTD_VERSION_MAJOR "${ZSTD_VERSION_INFO}")
50+
string(REGEX REPLACE ".*#define[ ]+ZSTD_VERSION_MINOR[ ]+([0-9]+).*" "\\1" ZSTD_VERSION_MINOR "${ZSTD_VERSION_INFO}")
51+
string(REGEX REPLACE ".*#define[ ]+ZSTD_VERSION_RELEASE[ ]+([0-9]+).*" "\\1" ZSTD_VERSION_RELEASE "${ZSTD_VERSION_INFO}")
52+
set(ZSTD_VERSION "${ZSTD_VERSION_MAJOR}.${ZSTD_VERSION_MINOR}.${ZSTD_VERSION_RELEASE}" CACHE STRING "ZSTD version info for Boost" FORCE)
53+
endif()
54+
55+
include(FindPackageHandleStandardArgs)
56+
find_package_handle_standard_args(ZSTD REQUIRED_VARS ZSTD_LIBRARY
57+
ZSTD_INCLUDE_DIR
58+
VERSION_VAR ZSTD_VERSION
59+
)
60+
mark_as_advanced( ZSTD_INCLUDE_DIR ZSTD_LIBRARY )

cmake/legacy.cmake

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,48 @@
11
################################################################################
2-
# Copyright (C) 2020-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
2+
# Copyright (C) 2020-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
33
# #
44
# This software is distributed under the terms of the #
55
# GNU Lesser General Public Licence (LGPL) version 3, #
66
# copied verbatim in the file "LICENSE" #
77
################################################################################
88
cmake_minimum_required(VERSION 3.19...3.28 FATAL_ERROR)
9+
cmake_policy(VERSION 3.19...3.28)
10+
11+
find_package(LibLZMA)
12+
if(LibLZMA_FOUND)
13+
message(STATUS "LZMA installation found. Boost iostream will be build with lzma compression")
14+
else()
15+
message(WARNING "LZMA installation not found. Boost iostream will be build without lzma compression")
16+
endif()
17+
18+
find_package(ZSTD)
19+
if(ZSTD_FOUND)
20+
message(STATUS "ZSTD installation found. Boost iostream will be build with zstd compression")
21+
else()
22+
message(WARNING "ZSTD installation not found. Boost iostream will be build without zstd compression")
23+
endif()
24+
25+
if(APPLE AND LibLZMA_FOUND)
26+
set(LZMA_EXTERNAL "using lzma :" CACHE STRING "LZMA exetrnal usage for Boost" FORCE)
27+
set(LZMA_VERSION "${LIBLZMA_VERSION}" CACHE STRING "LZMA version info for Boost" FORCE)
28+
set(LZMA_STRING ": <include>${LIBLZMA_INCLUDE_DIR} <search>${LIBLZMA_LIBRARY} ;" CACHE STRING "LZMA install info for Boost" FORCE)
29+
else()
30+
set(LZMA_EXTERNAL "" CACHE STRING "LZMA exetrnal usage for Boost" FORCE)
31+
set(LZMA_VERSION "" CACHE STRING "LZMA version info for Boost" FORCE)
32+
set(LZMA_STRING "" CACHE STRING "LZMA install info for Boost" FORCE)
33+
endif()
34+
35+
if(APPLE AND ZSTD_FOUND)
36+
get_filename_component(ZSTD_LIBRARY_DIR ${ZSTD_LIBRARY} DIRECTORY)
37+
set(ZSTD_EXTERNAL "using zstd :" CACHE STRING "ZSTD exetrnal usage for Boost" FORCE)
38+
set(ZSTD_VERSION "${ZSTD_VERSION}" CACHE STRING "ZSTD version info for Boost" FORCE)
39+
set(ZSTD_STRING ": <include>${ZSTD_INCLUDE_DIR} <search>${ZSTD_LIBRARY_DIR} ;" CACHE STRING "ZSTD install info for Boost" FORCE)
40+
else()
41+
set(ZSTD_EXTERNAL "" CACHE STRING "ZSTD exetrnal usage for Boost" FORCE)
42+
set(ZSTD_VERSION "" CACHE STRING "ZSTD version info for Boost" FORCE)
43+
set(ZSTD_STRING "" CACHE STRING "ZSTD install info for Boost" FORCE)
44+
endif()
45+
946

1047
find_package(Git REQUIRED)
1148
find_package(Patch REQUIRED)

legacy/boost/site-config.jam.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,9 @@ using python : @Python_VERSION_MAJOR@.@Python_VERSION_MINOR@
22
: @Python_EXECUTABLE_NAME@
33
: @Python_INCLUDE_DIRS@
44
: @Python_LIBRARY_DIRS@ ;
5+
6+
@ZSTD_EXTERNAL@ @ZSTD_VERSION@
7+
@ZSTD_STRING@
8+
9+
@LZMA_EXTERNAL@ @LZMA_VERSION@
10+
@LZMA_STRING@

0 commit comments

Comments
 (0)