Fix libpoly build on windows (#7502)
authorGereon Kremer <nafur42@gmail.com>
Wed, 27 Oct 2021 00:18:23 +0000 (17:18 -0700)
committerGitHub <noreply@github.com>
Wed, 27 Oct 2021 00:18:23 +0000 (00:18 +0000)
This PR should finally resolve the current issues with libpoly and windows cross compilation.

cmake/FindANTLR3.cmake
cmake/FindGMP.cmake
cmake/FindPoly.cmake
src/parser/CMakeLists.txt

index 772f5f43e75c2bd1b2e3232b4c1c31603101f6dc..e389e15f0107626addae39604997e3755e93ba18 100644 (file)
@@ -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()
index 6dad1595448892be0c5d12dfa140237c8ff1e93d..5a849153ba637cc7ab6839b491487410bd9312da 100644 (file)
@@ -76,7 +76,7 @@ if(NOT GMP_FOUND_SYSTEM)
         <SOURCE_DIR>/configure --enable-shared --disable-static
         --prefix=<INSTALL_DIR>/gmp-shared
         --enable-cxx --with-pic --host=${TOOLCHAIN_PREFIX}
-      BUILD_BYPRODUCTS <INSTALL_DIR>/lib/libgmp${CMAKE_SHARED_LIBRARY_SUFFIX}
+      BUILD_BYPRODUCTS <INSTALL_DIR>/gmp-shared/lib/libgmp.dll.a
     )
     ExternalProject_Add(
       GMP-EP-static
@@ -88,14 +88,14 @@ if(NOT GMP_FOUND_SYSTEM)
         <SOURCE_DIR>/configure --disable-shared --enable-static
         --prefix=<INSTALL_DIR>/gmp-static
         --enable-cxx --with-pic --host=${TOOLCHAIN_PREFIX}
-      BUILD_BYPRODUCTS <INSTALL_DIR>/lib/libgmp.a
+      BUILD_BYPRODUCTS <INSTALL_DIR>/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}")
index edba3663ea341e15be674198ae1075ccc5ff89b4..b55eca939a7f0ee8d5b47b7126b5491dee0bb735 100644 (file)
@@ -71,9 +71,6 @@ if(NOT Poly_FOUND_SYSTEM)
                 sed -i.orig "s/#include <stdio.h>/#include <stdio.h>\\\\n#include <inttypes.h>/" {} +
         COMMAND find <SOURCE_DIR>/ -type f ! -name "*.orig" -exec
                 sed -i.orig "s/#include <cstdio>/#include <cstdio>\\\\n#include <inttypes.h>/" {} +
-        # Help with finding GMP
-        COMMAND sed -i.orig "s/find_library(GMP_LIBRARY gmp)/find_library(GMP_LIBRARY gmp gmp-10)/"
-                <SOURCE_DIR>/CMakeLists.txt
     )
   else()
     unset(patchcmd)
index eeae442a4a0a182dd83aaf38337dcddf4973834d..e2cf3d64e32f7740d0c5b69658e8f51d60919ffc 100644 (file)
@@ -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 $<TARGET_OBJECTS:cvc5parser-objs>)
 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 $<TARGET_OBJECTS:cvc5parser-objs>)
   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