This makes a push to fix our windows nightly builds. It does a couple of things:
- remove `CVC5_WINDOWS_BUILD` and check `CMAKE_SYSTEM_NAME` instead
- use `CMAKE_SHARED_LIBRARY_SUFFIX` instead of `so`
- properly set `IMPORTED_IMPLIB` on imported shared libraries
- fix the GMP build, where the header is different for shared and static builds
- fix the find&sed patching for libpoly
- add `CVC5_EXPORT` to nested types in the API
- remove `CVC5_EXPORT` from enums
- add `-Dcvc5_obj_EXPORTS` to actually enable exports
- Fix how template function `safe_print` is exported.
# For Windows builds check if clock_gettime is available via -lpthread
# (pthread_time.h).
-if(CVC5_WINDOWS_BUILD)
+if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(CMAKE_REQUIRED_FLAGS -pthread)
check_symbol_exists(clock_gettime "time.h" HAVE_CLOCK_GETTIME)
unset(CMAKE_REQUIRED_FLAGS)
${64bit}
--host=${TOOLCHAIN_PREFIX}
BUILD_BYPRODUCTS <INSTALL_DIR>/${CMAKE_INSTALL_LIBDIR}/libantlr3c.a
- <INSTALL_DIR>/${CMAKE_INSTALL_LIBDIR}/libantlr3c.so
+ <INSTALL_DIR>/${CMAKE_INSTALL_LIBDIR}/libantlr3c${CMAKE_SHARED_LIBRARY_SUFFIX}
)
set(ANTLR3_JAR "${DEPS_BASE}/share/java/antlr-3.4-complete.jar")
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)
include(ExternalProject)
+ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
+ set(LIBFILENAME "libcryptominisat5win")
+ else()
+ set(LIBFILENAME "libcryptominisat5")
+ endif()
+
ExternalProject_Add(
CryptoMiniSat-EP
${COMMON_EP_CONFIG}
)
set(CryptoMiniSat_INCLUDE_DIR "${DEPS_BASE}/include/")
- set(CryptoMiniSat_LIBRARIES "${DEPS_BASE}/${CMAKE_INSTALL_LIBDIR}/libcryptominisat5.a")
+ set(CryptoMiniSat_LIBRARIES "${DEPS_BASE}/${CMAKE_INSTALL_LIBDIR}/${LIBFILENAME}.a")
add_library(CryptoMiniSat STATIC IMPORTED GLOBAL)
set_target_properties(
if(NOT GMP_STATIC_LIBRARIES)
set(GMP_FOUND_SYSTEM FALSE)
endif()
+ set(GMP_STATIC_INCLUDE_DIR "${GMP_INCLUDE_DIR}")
reset_force_static_library()
endif()
set(GMP_VERSION "6.2.1")
- ExternalProject_Add(
- GMP-EP
- ${COMMON_EP_CONFIG}
- URL https://gmplib.org/download/gmp/gmp-${GMP_VERSION}.tar.bz2
- URL_HASH SHA1=2dcf34d4a432dbe6cce1475a835d20fe44f75822
- CONFIGURE_COMMAND
- <SOURCE_DIR>/configure --prefix=<INSTALL_DIR> --enable-cxx --with-pic
- --enable-shared --enable-static --host=${TOOLCHAIN_PREFIX}
- BUILD_BYPRODUCTS <INSTALL_DIR>/lib/libgmp.a
- <INSTALL_DIR>/lib/libgmp${CMAKE_SHARED_LIBRARY_SUFFIX}
- )
+ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
+ # on windows, the gmp.h is different for shared and static builds.
+ # we thus need two separate builds. as the configure script taints the
+ # source folder, we even need two source folders.
+ ExternalProject_Add(
+ GMP-EP-shared
+ ${COMMON_EP_CONFIG}
+ URL https://gmplib.org/download/gmp/gmp-${GMP_VERSION}.tar.bz2
+ URL_HASH SHA1=2dcf34d4a432dbe6cce1475a835d20fe44f75822
+ DOWNLOAD_NAME gmp-${GMP_VERSION}-shared.tar.bz2
+ CONFIGURE_COMMAND
+ <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}
+ )
+ ExternalProject_Add(
+ GMP-EP-static
+ ${COMMON_EP_CONFIG}
+ URL https://gmplib.org/download/gmp/gmp-${GMP_VERSION}.tar.bz2
+ URL_HASH SHA1=2dcf34d4a432dbe6cce1475a835d20fe44f75822
+ DOWNLOAD_NAME gmp-${GMP_VERSION}-static.tar.bz2
+ CONFIGURE_COMMAND
+ <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
+ )
- set(GMP_INCLUDE_DIR "${DEPS_BASE}/include/")
- set(GMP_LIBRARIES "${DEPS_BASE}/lib/libgmp${CMAKE_SHARED_LIBRARY_SUFFIX}")
- set(GMP_STATIC_LIBRARIES "${DEPS_BASE}/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_STATIC_LIBRARIES "${DEPS_BASE}/gmp-static/lib/libgmp.a")
+
+ file(MAKE_DIRECTORY "${GMP_INCLUDE_DIR}")
+ file(MAKE_DIRECTORY "${GMP_STATIC_INCLUDE_DIR}")
+ else()
+ ExternalProject_Add(
+ GMP-EP
+ ${COMMON_EP_CONFIG}
+ URL https://gmplib.org/download/gmp/gmp-${GMP_VERSION}.tar.bz2
+ URL_HASH SHA1=2dcf34d4a432dbe6cce1475a835d20fe44f75822
+ CONFIGURE_COMMAND
+ <SOURCE_DIR>/configure --enable-shared --enable-static
+ --prefix=<INSTALL_DIR>
+ --enable-cxx --with-pic --host=${TOOLCHAIN_PREFIX}
+ BUILD_BYPRODUCTS <INSTALL_DIR>/lib/libgmp.a
+ <INSTALL_DIR>/lib/libgmp${CMAKE_SHARED_LIBRARY_SUFFIX}
+ )
+
+ set(GMP_INCLUDE_DIR "${DEPS_BASE}/include/")
+ set(GMP_STATIC_INCLUDE_DIR "${DEPS_BASE}/include/")
+ set(GMP_LIBRARIES "${DEPS_BASE}/lib/libgmp${CMAKE_SHARED_LIBRARY_SUFFIX}")
+ set(GMP_STATIC_LIBRARIES "${DEPS_BASE}/lib/libgmp.a")
+ endif()
endif()
set(GMP_FOUND TRUE)
IMPORTED_LOCATION "${GMP_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${GMP_INCLUDE_DIR}"
)
+if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
+ set_target_properties(GMP_SHARED PROPERTIES IMPORTED_IMPLIB "${GMP_LIBRARIES}")
+endif()
if(ENABLE_STATIC_LIBRARY)
add_library(GMP_STATIC STATIC IMPORTED GLOBAL)
set_target_properties(GMP_STATIC PROPERTIES
IMPORTED_LOCATION "${GMP_STATIC_LIBRARIES}"
- INTERFACE_INCLUDE_DIRECTORIES "${GMP_INCLUDE_DIR}"
+ INTERFACE_INCLUDE_DIRECTORIES "${GMP_STATIC_INCLUDE_DIR}"
)
endif()
# Roughly following https://stackoverflow.com/a/44383330/2375725
set(patchcmd
# Avoid %z and %llu format specifiers
- COMMAND find <SOURCE_DIR>/ -type f -exec
- sed -i.orig "s/%z[diu]/%\" PRIu64 \"/g" {} +
- COMMAND find <SOURCE_DIR>/ -type f -exec
- sed -i.orig "s/%ll[du]/%\" PRIu64 \"/g" {} +
+ COMMAND find <SOURCE_DIR>/ -type f ! -name "*.orig" -exec
+ sed -i.orig "s/%z[diu]/%\\\" PRIu64 \\\"/g" {} +
+ COMMAND find <SOURCE_DIR>/ -type f ! -name "*.orig" -exec
+ sed -i.orig "s/%ll[du]/%\\\" PRIu64 \\\"/g" {} +
# Make sure the new macros are available
- COMMAND find <SOURCE_DIR>/ -type f -exec
- sed -i.orig "s/#include <stdio.h>/#include <stdio.h>\\n#include <inttypes.h>/" {} +
- COMMAND find <SOURCE_DIR>/ -type f -exec
- sed -i.orig "s/#include <cstdio>/#include <cstdio>\\n#include <inttypes.h>/" {} +
+ COMMAND find <SOURCE_DIR>/ -type f ! -name "*.orig" -exec
+ 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)
get_target_property(GMP_LIBRARY GMP_SHARED IMPORTED_LOCATION)
get_filename_component(GMP_LIB_PATH "${GMP_LIBRARY}" DIRECTORY)
+ set(POLY_BYPRODUCTS
+ <INSTALL_DIR>/lib/libpicpoly.a
+ <INSTALL_DIR>/lib/libpicpolyxx.a
+ <INSTALL_DIR>/lib/libpoly${CMAKE_SHARED_LIBRARY_SUFFIX}
+ <INSTALL_DIR>/lib/libpolyxx${CMAKE_SHARED_LIBRARY_SUFFIX}
+ )
+ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+ list(APPEND POLY_BYPRODUCTS
+ <INSTALL_DIR>/lib/libpoly.0${CMAKE_SHARED_LIBRARY_SUFFIX}
+ <INSTALL_DIR>/lib/libpoly.0.1.9${CMAKE_SHARED_LIBRARY_SUFFIX}
+ <INSTALL_DIR>/lib/libpolyxx.0${CMAKE_SHARED_LIBRARY_SUFFIX}
+ <INSTALL_DIR>/lib/libpolyxx.0.1.9${CMAKE_SHARED_LIBRARY_SUFFIX}
+ )
+ elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ list(APPEND POLY_BYPRODUCTS
+ <INSTALL_DIR>/lib/libpoly${CMAKE_SHARED_LIBRARY_SUFFIX}.0
+ <INSTALL_DIR>/lib/libpoly${CMAKE_SHARED_LIBRARY_SUFFIX}.0.1.9
+ <INSTALL_DIR>/lib/libpolyxx${CMAKE_SHARED_LIBRARY_SUFFIX}.0
+ <INSTALL_DIR>/lib/libpolyxx${CMAKE_SHARED_LIBRARY_SUFFIX}.0.1.9
+ )
+ endif()
+
ExternalProject_Add(
Poly-EP
${COMMON_EP_CONFIG}
<INSTALL_DIR>/lib/libpicpoly.a
COMMAND ${CMAKE_COMMAND} -E copy src/libpicpolyxx.a
<INSTALL_DIR>/lib/libpicpolyxx.a
- BUILD_BYPRODUCTS <INSTALL_DIR>/lib/libpicpoly.a
- <INSTALL_DIR>/lib/libpicpolyxx.a
- <INSTALL_DIR>/lib/libpoly${CMAKE_SHARED_LIBRARY_SUFFIX}
- <INSTALL_DIR>/lib/libpolyxx${CMAKE_SHARED_LIBRARY_SUFFIX}
+ BUILD_BYPRODUCTS ${POLY_BYPRODUCTS}
)
ExternalProject_Add_Step(
Poly-EP cleanup
set(PolyXX_LIBRARIES "${DEPS_BASE}/lib/libpolyxx${CMAKE_SHARED_LIBRARY_SUFFIX}")
set(Poly_STATIC_LIBRARIES "${DEPS_BASE}/lib/libpicpoly.a")
set(PolyXX_STATIC_LIBRARIES "${DEPS_BASE}/lib/libpicpolyxx.a")
+
+ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
+ set(Poly_LIBRARIES "${DEPS_BASE}/bin/libpoly${CMAKE_SHARED_LIBRARY_SUFFIX}")
+ set(PolyXX_LIBRARIES "${DEPS_BASE}/bin/libpolyxx${CMAKE_SHARED_LIBRARY_SUFFIX}")
+ endif()
endif()
set(Poly_FOUND TRUE)
IMPORTED_LOCATION "${Poly_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${Poly_INCLUDE_DIR}"
)
+if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
+ set_target_properties(Poly_SHARED PROPERTIES IMPORTED_IMPLIB "${Poly_LIBRARIES}")
+endif()
target_link_libraries(Poly_SHARED INTERFACE GMP_SHARED)
add_library(Polyxx_SHARED SHARED IMPORTED GLOBAL)
INTERFACE_INCLUDE_DIRECTORIES "${Poly_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES Poly_SHARED
)
+if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
+ set_target_properties(Polyxx_SHARED PROPERTIES IMPORTED_IMPLIB "${PolyXX_LIBRARIES}")
+endif()
if(ENABLE_STATIC_LIBRARY)
add_library(Poly_STATIC STATIC IMPORTED GLOBAL)
add_dependencies(Poly_SHARED Poly-EP)
add_dependencies(Polyxx_SHARED Poly-EP)
+ ExternalProject_Get_Property(Poly-EP BUILD_BYPRODUCTS INSTALL_DIR)
+ string(REPLACE "<INSTALL_DIR>" "${INSTALL_DIR}" BUILD_BYPRODUCTS "${BUILD_BYPRODUCTS}")
install(FILES
- $<TARGET_SONAME_FILE:Poly_SHARED> $<TARGET_SONAME_FILE:Polyxx_SHARED>
+ ${BUILD_BYPRODUCTS}
DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
-set(CVC5_WINDOWS_BUILD TRUE)
# First build the object library
add_library(cvc5-obj OBJECT ${LIBCVC5_SRCS} ${LIBCVC5_GEN_SRCS})
-target_compile_definitions(cvc5-obj PRIVATE -D__BUILDING_CVC5LIB)
+target_compile_definitions(cvc5-obj PRIVATE -D__BUILDING_CVC5LIB -Dcvc5_obj_EXPORTS)
set_target_properties(cvc5-obj PROPERTIES POSITION_INDEPENDENT_CODE ON)
# add_dependencies() is necessary for cmake versions before 3.21
add_dependencies(cvc5-obj cvc5base cvc5context)
* for example, the term f(x, y) will have Kind APPLY_UF and three
* children: f, x, and y
*/
- class const_iterator
+ class CVC5_EXPORT const_iterator
{
friend class Term;
* Standard 754.
* \endverbatim
*/
-enum CVC5_EXPORT RoundingMode
+enum RoundingMode
{
/**
* Round to the nearest even number.
using BaseType = std::map<std::string, Stat>;
/** Custom iterator to hide certain statistics from regular iteration */
- class iterator
+ class CVC5_EXPORT iterator
{
public:
friend class Statistics;
* depends on the size of `cvc5::Kind` (`NodeValue::NBITS_KIND`, currently 10
* bits, see expr/node_value.h).
*/
-enum CVC5_EXPORT Kind : int32_t
+enum Kind : int32_t
{
/**
* Internal kind.
NL = '\n'
# Expected C++ Enum Declarations
-ENUM_START = 'enum CVC5_EXPORT Kind'
+ENUM_START = 'enum Kind'
ENUM_END = CCB + SC
# Comments and Macro Tokens
add_library(cvc5base OBJECT ${LIBBASE_SOURCES})
set_target_properties(cvc5base PROPERTIES POSITION_INDEPENDENT_CODE ON)
-target_compile_definitions(cvc5base PRIVATE -D__BUILDING_CVC5LIB)
+target_compile_definitions(cvc5base PRIVATE -D__BUILDING_CVC5LIB -Dcvc5_obj_EXPORTS)
add_dependencies(cvc5base gen-versioninfo gen-tags)
add_library(cvc5context OBJECT ${LIBCONTEXT_SOURCES})
set_target_properties(cvc5context PROPERTIES POSITION_INDEPENDENT_CODE ON)
-target_compile_definitions(cvc5context PRIVATE -D__BUILDING_CVC5LIB)
+target_compile_definitions(cvc5context PRIVATE -D__BUILDING_CVC5LIB -Dcvc5_obj_EXPORTS)
namespace cvc5 {
-enum class CVC5_EXPORT Language
+enum class Language
{
// SPECIAL "NON-LANGUAGE" LANGUAGES HAVE ENUM VALUE < 0
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)
+target_compile_definitions(cvc5parser-objs PUBLIC -D__BUILDING_CVC5PARSERLIB -Dcvc5_obj_EXPORTS)
add_dependencies(cvc5parser-objs ANTLR3_SHARED)
target_include_directories(cvc5parser-objs PRIVATE ${ANTLR3_INCLUDE_DIR})
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)
-target_link_libraries(cvc5parser-shared PRIVATE ANTLR3_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()
install(TARGETS cvc5parser-shared
EXPORT cvc5-targets
# unresolved symbols when linking against libcvc5parser.
# -Wl,--export-all-symbols makes sure that all symbols are exported when
# building a DLL.
-if(CVC5_WINDOWS_BUILD)
- set_target_properties(cvc5parser
+if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
+ set_target_properties(cvc5parser-objs
PROPERTIES LINK_FLAGS "-Wl,--export-all-symbols")
endif()
namespace cvc5 {
+template <size_t N>
+void CVC5_EXPORT safe_print(int fd, const char (&msg)[N]);
+template <typename T>
+void CVC5_EXPORT safe_print(int fd, const T& obj);
+
/**
* Prints arrays of chars (e.g. string literals) of length N. Safe to use in a
* signal handler.
*/
template <size_t N>
-void CVC5_EXPORT safe_print(int fd, const char (&msg)[N])
+void safe_print(int fd, const char (&msg)[N])
{
ssize_t nb = N - 1;
if (write(fd, msg, nb) != nb) {
* @param obj The object to print
*/
template <typename T>
-void CVC5_EXPORT safe_print(int fd, const T& obj)
+void safe_print(int fd, const T& obj)
{
const char* s =
toStringImpl(obj, /* prefer the method that uses `toString()` */ 0);