From: Andrew V. Jones Date: Sat, 1 Aug 2020 07:34:37 +0000 (+0100) Subject: Ensure that we only find '.a's when building statically (#4785) X-Git-Tag: cvc5-1.0.0~3060 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=230d27bad9b4cd49bad1164145cf83c9f04e9aca;p=cvc5.git Ensure that we only find '.a's when building statically (#4785) ## Issue When trying to building statically, and if your machine *does not* have static libraries (e.g., there is [no static GMP on CentOS 8](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html-single/considerations_in_adopting_rhel_8/index#removed-packages_changes-to-packages)), then CVC4's CMake does not detect this: ``` FAILED: bin/cvc4 : && /usr/bin/c++ -O3 -Wall -Wno-deprecated -Wsuggest-override -Wnon-virtual-dtor -Wimplicit-fallthrough -Wshadow -Wno-class-memaccess -fuse-ld=gold -static src/main/CMakeFiles/main.dir/command_executor.cpp.o src/main/CMakeFiles/main.dir/interactive_shell.cpp.o src/main/CMakeFiles/main.dir/signal_handlers.cpp.o src/main/CMakeFiles/main.dir/time_limit.cpp.o src/main/CMakeFiles/cvc4-bin.dir/driver_unified.cpp.o src/main/CMakeFiles/cvc4-bin.dir/main.cpp.o -o bin/cvc4 src/libcvc4.a src/parser/libcvc4parser.a src/libcvc4.a -Wl,-Bdynamic /usr/lib64/libgmp.so -Wl,-Bstatic ../deps/install/lib/libantlr3c.a && : /usr/bin/ld.gold: error: cannot mix -static with dynamic object /usr/lib64/libgmp.so ``` ## Resolution This PR changes CVC4's CMakeLists such that, if you're building statically, it *only* allows for linking against `.a`s (or `.a`s + `.lib`s on Windows). Signed-off-by: Andrew V. Jones --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 7fc0af52c..93ea5cbeb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -314,7 +314,12 @@ if(ENABLE_SHARED) # https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/RPATH-handling set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${LIBRARY_INSTALL_DIR};${PROJECT_SOURCE_DIR}/deps/install/lib") else() - set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) + # When building statically, we *only* want static archives/libraries + if (WIN32) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a) + else() + set(CMAKE_FIND_LIBRARY_SUFFIXES .a) + endif() set(BUILD_SHARED_LIBS OFF) cvc4_set_option(ENABLE_STATIC_BINARY ON)