check_include_file(unistd.h HAVE_UNISTD_H)
check_include_file_cxx(ext/stdio_filebuf.h HAVE_EXT_STDIO_FILEBUF_H)
-check_symbol_exists(clock_gettime "time.h" HAVE_CLOCK_GETTIME)
+# For Windows builds check if clock_gettime is available via -lpthread
+# (pthread_time.h).
+if(CVC4_WINDOWS_BUILD)
+ set(CMAKE_REQUIRED_FLAGS -pthread)
+ check_symbol_exists(clock_gettime "time.h" HAVE_CLOCK_GETTIME)
+ unset(CMAKE_REQUIRED_FLAGS)
+ if(HAVE_CLOCK_GETTIME)
+ add_c_cxx_flag(-pthread)
+ endif()
+else()
+ check_symbol_exists(clock_gettime "time.h" HAVE_CLOCK_GETTIME)
+endif()
check_symbol_exists(ffs "strings.h" HAVE_FFS)
check_symbol_exists(optreset "getopt.h" HAVE_DECL_OPTRESET)
check_symbol_exists(sigaltstack "signal.h" HAVE_SIGALTSTACK)
--- /dev/null
+# Toolchain file for building for Windows from Ubuntu.
+#
+# Use: cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-mingw64.cmake
+
+SET(CMAKE_SYSTEM_NAME Windows)
+
+set(TOOLCHAIN_PREFIX x86_64-w64-mingw32)
+
+SET(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
+SET(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
+SET(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)
+
+# Set target environment path
+SET(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
+
+# Adjust the default behaviour of the find_XXX() commands:
+# search headers and libraries in the target environment, search
+# programs in the host environment
+set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
+set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
+
+set(CVC4_WINDOWS_BUILD TRUE)
--name=STR use custom build directory name
--best turn on dependences known to give best performance
--gpl permit GPL dependences, if available
+ --win64 cross-compile for Windows 64 bit
Features:
--cryptominisat-dir=PATH path to top level of cryptominisat source tree
--cxxtest-dir=DIR path to CxxTest installation
--glpk-dir=PATH path to top level of glpk installation
+ --gmp-dir=PATH path to top level of GMP installation
--lfsc-dir=PATH path to top level of lfsc source tree
--symfpu-dir=PATH path to top level of symfpu source tree
debug_context_mm=default
dumping=default
gpl=default
+win64=default
glpk=default
lfsc=default
muzzle=default
cadical_dir=default
cryptominisat_dir=default
glpk_dir=default
+gmp_dir=default
lfsc_dir=default
symfpu_dir=default
--gpl) gpl=ON;;
--no-gpl) gpl=OFF;;
+ --win64) win64=ON;;
+ --no-win64) win64=OFF;;
+
--glpk) glpk=ON;;
--no-glpk) glpk=OFF;;
--glpk-dir) die "missing argument to $1 (try -h)" ;;
--glpk-dir=*) glpk_dir=${1##*=} ;;
+ --gmp-dir) die "missing argument to $1 (try -h)" ;;
+ --gmp-dir=*) gmp_dir=${1##*=} ;;
+
--lfsc-dir) die "missing argument to $1 (try -h)" ;;
--lfsc-dir=*) lfsc_dir=${1##*=} ;;
cmake_opts=""
-[ $buildtype != default ] && cmake_opts="$cmake_opts -DCMAKE_BUILD_TYPE=$buildtype"
+[ $buildtype != default ] \
+ && cmake_opts="$cmake_opts -DCMAKE_BUILD_TYPE=$buildtype"
[ $asan != default ] \
&& cmake_opts="$cmake_opts -DENABLE_ASAN=$asan" \
[ $gpl != default ] \
&& cmake_opts="$cmake_opts -DENABLE_GPL=$gpl" \
&& [ $gpl = ON ] && build_dir="$build_dir-gpl"
+[ $win64 != default ] \
+ && cmake_opts="$cmake_opts -DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-mingw64.cmake" \
+ && [ $win64 = ON ] && build_dir="$build_dir-win64"
[ $muzzle != default ] \
&& cmake_opts="$cmake_opts -DENABLE_MUZZLE=$muzzle" \
&& [ $muzzle = ON ] && build_dir="$build_dir-muzzle"
&& cmake_opts="$cmake_opts -DCRYPTOMINISAT_DIR=$cryptominisat_dir"
[ "$glpk_dir" != default ] \
&& cmake_opts="$cmake_opts -DGLPK_DIR=$glpk_dir"
+[ "$gmp_dir" != default ] \
+ && cmake_opts="$cmake_opts -DGMP_DIR=$gmp_dir"
[ "$lfsc_dir" != default ] \
&& cmake_opts="$cmake_opts -DLFSC_DIR=$lfsc_dir"
[ "$symfpu_dir" != default ] \
# If a build name is specified just create directory 'build_name' for the
# current build.
build_dir=$build_name
+
+ # The cmake toolchain can't be changed once it is configured in $build_dir.
+ # Thus, remove $build_dir and create an empty directory.
+ [ $win64 = ON ] && [ -e "$build_dir" ] && rm -r "$build_dir"
mkdir -p "$build_name"
else
# If no build name is specified create 'cmake-builds' directory and create
# the current build directory. Set symlink 'cmake-builds/build/' to current
# build.
build_dir="$build_prefix$build_dir"
+
+ # The cmake toolchain can't be changed once it is configured in $build_dir.
+ # Thus, remove $build_dir and create an empty directory.
+ [ $win64 = ON ] && [ -e "cmake-build/$build_dir" ] \
+ && rm -r "cmake-builds/$build_dir"
mkdir -p "cmake-builds/$build_dir"
cd cmake-builds || exit 1
[ -e build ] && rm build
target_link_libraries(cvc4parser cvc4 ${ANTLR_LIBRARIES})
target_include_directories(cvc4parser PRIVATE ${ANTLR_INCLUDE_DIR})
install(TARGETS cvc4parser DESTINATION lib)
+
+# The generated lexer/parser files define some functions as
+# __declspec(dllexport) via the ANTLR3_API macro, which leads to lots of
+# unresolved symbols when linking against libcvc4parser.
+# -Wl,--export-all-symbols makes sure that all symbols are exported when
+# building a DLL.
+if(CVC4_WINDOWS_BUILD)
+ set_target_properties(cvc4parser
+ PROPERTIES LINK_FLAGS "-Wl,--export-all-symbols")
+endif()