diff --git a/make-srpm.sh b/make-srpm.sh index a2fbf3b..6213cea 100755 --- a/make-srpm.sh +++ b/make-srpm.sh @@ -89,8 +89,8 @@ cat > "$SPEC" << EOF %bcond_without python2 %endif -# build csdiff-static on 64bit RHEL-10+ and Fedora -%if 0%{?__isa_bits} == 64 && (0%{?rhel} > 9 || 0%{?fedora}) +# build csdiff-static on 64bit RHEL-8+ and Fedora +%if 0%{?__isa_bits} == 64 && (0%{?rhel} > 7 || 0%{?fedora}) %bcond_without static %else %bcond_with static @@ -150,7 +150,11 @@ defect lists using various filtering predicates. %if %{with static} %package static Summary: Statically linked csgrep-static executable +%if 0%{?rhel} == 8 || 0%{?rhel} == 9 +BuildRequires: boost1.78-static +%else BuildRequires: boost-static +%endif BuildRequires: glibc-static BuildRequires: libstdc++-static @@ -195,6 +199,11 @@ code scan defect lists to find out added or fixed defects. export BOOST_INCLUDEDIR=/usr/include/boost169 export BOOST_LIBRARYDIR=/usr/lib64/boost169 %endif +%if 0%{?rhel} == 8 || 0%{?rhel} == 9 +# Set paths for CMake's FindBoost +export BOOST_INCLUDEDIR=/usr/include/boost1.78 +export BOOST_LIBRARYDIR=/usr/lib64/boost1.78 +%endif make version.cc %if 0%{?rhel} == 7 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7234ecc..ce30eb4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -102,11 +102,17 @@ if(CSGREP_STATIC) add_executable(csgrep-static csgrep.cc) target_link_options(csgrep-static PRIVATE "-static") - # FIXME: do not hardcode paths to boost static libs + # Use BOOST_LIBRARYDIR if set, otherwise fallback to /usr/lib64 + if(DEFINED ENV{BOOST_LIBRARYDIR}) + set(Boost_STATIC_DIR "$ENV{BOOST_LIBRARYDIR}") + else() + set(Boost_STATIC_DIR "/usr/lib64") + endif() + target_link_libraries(csgrep-static cs - /usr/lib64/libboost_filesystem.a - /usr/lib64/libboost_program_options.a - /usr/lib64/libboost_regex.a) + ${Boost_STATIC_DIR}/libboost_filesystem.a + ${Boost_STATIC_DIR}/libboost_program_options.a + ${Boost_STATIC_DIR}/libboost_regex.a) install(TARGETS csgrep-static DESTINATION ${CMAKE_INSTALL_LIBEXECDIR})