From: Gereon Kremer Date: Wed, 27 Oct 2021 00:18:23 +0000 (-0700) Subject: Fix libpoly build on windows (#7502) X-Git-Tag: cvc5-1.0.0~961 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c405f169925f5c9b5bf17d668872f37ce878eb68;p=cvc5.git Fix libpoly build on windows (#7502) This PR should finally resolve the current issues with libpoly and windows cross compilation. --- diff --git a/cmake/FindANTLR3.cmake b/cmake/FindANTLR3.cmake index 772f5f43e..e389e15f0 100644 --- a/cmake/FindANTLR3.cmake +++ b/cmake/FindANTLR3.cmake @@ -133,8 +133,7 @@ if(NOT ANTLR3_FOUND_SYSTEM) set(ANTLR3_JAR "${DEPS_BASE}/share/java/antlr-3.4-complete.jar") set(ANTLR3_INCLUDE_DIR "${DEPS_BASE}/include/") - set(ANTLR3_LIBRARIES "${DEPS_BASE}/${CMAKE_INSTALL_LIBDIR}/libantlr3c${CMAKE_SHARED_LIBRARY_SUFFIX}") - set(ANTLR3_STATIC_LIBRARIES "${DEPS_BASE}/${CMAKE_INSTALL_LIBDIR}/libantlr3c.a") + set(ANTLR3_LIBRARIES "${DEPS_BASE}/${CMAKE_INSTALL_LIBDIR}/libantlr3c.a") endif() find_package(Java COMPONENTS Runtime REQUIRED) @@ -146,21 +145,13 @@ set(ANTLR3_FOUND TRUE) set(ANTLR3_COMMAND ${Java_JAVA_EXECUTABLE} -cp "${ANTLR3_JAR}" org.antlr.Tool CACHE STRING "run ANTLR3" FORCE) -add_library(ANTLR3_SHARED SHARED IMPORTED GLOBAL) -set_target_properties(ANTLR3_SHARED PROPERTIES +add_library(ANTLR3 STATIC IMPORTED GLOBAL) +set_target_properties(ANTLR3 PROPERTIES IMPORTED_LOCATION "${ANTLR3_LIBRARIES}" INTERFACE_INCLUDE_DIRECTORIES "${ANTLR3_INCLUDE_DIR}" ) if(CMAKE_SYSTEM_NAME STREQUAL "Windows") - set_target_properties(ANTLR3_SHARED PROPERTIES IMPORTED_IMPLIB "${ANTLR3_LIBRARIES}") -endif() - -if(ENABLE_STATIC_LIBRARY) - add_library(ANTLR3_STATIC STATIC IMPORTED GLOBAL) - set_target_properties(ANTLR3_STATIC PROPERTIES - IMPORTED_LOCATION "${ANTLR3_STATIC_LIBRARIES}" - INTERFACE_INCLUDE_DIRECTORIES "${ANTLR3_INCLUDE_DIR}" - ) + set_target_properties(ANTLR3 PROPERTIES IMPORTED_IMPLIB "${ANTLR3_LIBRARIES}") endif() mark_as_advanced(ANTLR3_BINARY) @@ -170,7 +161,6 @@ mark_as_advanced(ANTLR3_FOUND_SYSTEM) mark_as_advanced(ANTLR3_INCLUDE_DIR) mark_as_advanced(ANTLR3_JAR) mark_as_advanced(ANTLR3_LIBRARIES) -mark_as_advanced(ANTLR3_STATIC_LIBRARIES) if(ANTLR3_FOUND_SYSTEM) message(STATUS "Found ANTLR3 runtime: ${ANTLR3_LIBRARIES}") @@ -178,8 +168,5 @@ if(ANTLR3_FOUND_SYSTEM) else() message(STATUS "Building ANTLR3 runtime: ${ANTLR3_LIBRARIES}") message(STATUS "Downloading ANTLR3 JAR: ${ANTLR3_JAR}") - add_dependencies(ANTLR3_SHARED ANTLR3-EP-runtime ANTLR3-EP-jar) - if(ENABLE_STATIC_LIBRARY) - add_dependencies(ANTLR3_STATIC ANTLR3-EP-runtime ANTLR3-EP-jar) - endif() + add_dependencies(ANTLR3 ANTLR3-EP-runtime ANTLR3-EP-jar) endif() diff --git a/cmake/FindGMP.cmake b/cmake/FindGMP.cmake index 6dad15954..5a849153b 100644 --- a/cmake/FindGMP.cmake +++ b/cmake/FindGMP.cmake @@ -76,7 +76,7 @@ if(NOT GMP_FOUND_SYSTEM) /configure --enable-shared --disable-static --prefix=/gmp-shared --enable-cxx --with-pic --host=${TOOLCHAIN_PREFIX} - BUILD_BYPRODUCTS /lib/libgmp${CMAKE_SHARED_LIBRARY_SUFFIX} + BUILD_BYPRODUCTS /gmp-shared/lib/libgmp.dll.a ) ExternalProject_Add( GMP-EP-static @@ -88,14 +88,14 @@ if(NOT GMP_FOUND_SYSTEM) /configure --disable-shared --enable-static --prefix=/gmp-static --enable-cxx --with-pic --host=${TOOLCHAIN_PREFIX} - BUILD_BYPRODUCTS /lib/libgmp.a + BUILD_BYPRODUCTS /gmp-static/lib/libgmp.a ) add_custom_target(GMP-EP DEPENDS GMP-EP-shared GMP-EP-static) set(GMP_INCLUDE_DIR "${DEPS_BASE}/gmp-shared/include/") set(GMP_STATIC_INCLUDE_DIR "${DEPS_BASE}/gmp-static/include/") - set(GMP_LIBRARIES "${DEPS_BASE}/gmp-shared/bin/libgmp-10${CMAKE_SHARED_LIBRARY_SUFFIX}") + set(GMP_LIBRARIES "${DEPS_BASE}/gmp-shared/lib/libgmp.dll.a") set(GMP_STATIC_LIBRARIES "${DEPS_BASE}/gmp-static/lib/libgmp.a") file(MAKE_DIRECTORY "${GMP_INCLUDE_DIR}") diff --git a/cmake/FindPoly.cmake b/cmake/FindPoly.cmake index edba3663e..b55eca939 100644 --- a/cmake/FindPoly.cmake +++ b/cmake/FindPoly.cmake @@ -71,9 +71,6 @@ if(NOT Poly_FOUND_SYSTEM) sed -i.orig "s/#include /#include \\\\n#include /" {} + COMMAND find / -type f ! -name "*.orig" -exec sed -i.orig "s/#include /#include \\\\n#include /" {} + - # Help with finding GMP - COMMAND sed -i.orig "s/find_library(GMP_LIBRARY gmp)/find_library(GMP_LIBRARY gmp gmp-10)/" - /CMakeLists.txt ) else() unset(patchcmd) diff --git a/src/parser/CMakeLists.txt b/src/parser/CMakeLists.txt index eeae442a4..e2cf3d64e 100644 --- a/src/parser/CMakeLists.txt +++ b/src/parser/CMakeLists.txt @@ -102,18 +102,14 @@ add_library(cvc5parser-objs OBJECT ${libcvc5parser_src_files}) set_target_properties(cvc5parser-objs PROPERTIES POSITION_INDEPENDENT_CODE ON) target_compile_definitions(cvc5parser-objs PUBLIC -D__BUILDING_CVC5PARSERLIB -Dcvc5_obj_EXPORTS) -add_dependencies(cvc5parser-objs ANTLR3_SHARED) +add_dependencies(cvc5parser-objs ANTLR3) target_include_directories(cvc5parser-objs PRIVATE ${ANTLR3_INCLUDE_DIR}) add_library(cvc5parser-shared SHARED $) set_target_properties(cvc5parser-shared PROPERTIES SOVERSION ${CVC5_SOVERSION}) set_target_properties(cvc5parser-shared PROPERTIES OUTPUT_NAME cvc5parser) target_link_libraries(cvc5parser-shared PRIVATE cvc5-shared) -if(CMAKE_SYSTEM_NAME STREQUAL "Windows") - target_link_libraries(cvc5parser-shared PRIVATE ANTLR3_STATIC) -else() - target_link_libraries(cvc5parser-shared PRIVATE ANTLR3_SHARED) -endif() +target_link_libraries(cvc5parser-shared PRIVATE ANTLR3) install(TARGETS cvc5parser-shared EXPORT cvc5-targets @@ -123,7 +119,7 @@ if(ENABLE_STATIC_LIBRARY) add_library(cvc5parser-static STATIC $) set_target_properties(cvc5parser-static PROPERTIES OUTPUT_NAME cvc5parser) target_link_libraries(cvc5parser-static PRIVATE cvc5-static) - target_link_libraries(cvc5parser-static PRIVATE ANTLR3_STATIC) + target_link_libraries(cvc5parser-static PRIVATE ANTLR3) install(TARGETS cvc5parser-objs cvc5parser-static EXPORT cvc5-targets