Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify default argument in the declaration not the friend declaration #27

Open
wants to merge 44 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
c554273
Fixing problems with compilation with C++11 compilers
msoos Apr 1, 2015
4d9462e
Remove illegal (and not neccesary) friend definition to fix compilati…
jbransen Jun 19, 2014
3db5894
Fix declaration of Minisat::memUsedPeak for non-Linux systems
rgov Jun 22, 2015
26b58cf
Specify default argument in the declaration not the friend declaration
msoos Mar 19, 2016
25ac527
Fixing Visual Studio build issues
msoos Apr 23, 2017
7d4cb54
Adding appveyor for minisat
msoos Apr 23, 2017
5566d44
Fixing appveyor build
msoos Apr 23, 2017
a98e44f
fixed GCC 6.3 warning: invalid suffix on literal; C++11 requires a sp…
Robbepop Apr 27, 2017
0662095
Merge pull request #1 from Robbepop/master
msoos Apr 27, 2017
99e19fc
Resolve merge conflicts
rgov Mar 7, 2018
29bb7bc
Merge branch 'msoos-master'
rgov Mar 7, 2018
1aa1e87
Fix linking of minisat as dependency library on MacOSX
MartinNowack Jun 29, 2018
a259927
Merge pull request #2 from MartinNowack/patch-1
rgov Jul 2, 2018
ef004b4
Fixing static vs. dynamic compile
msoos Feb 28, 2019
dbef978
Quell some clang warnings
bpfoley Feb 12, 2020
47baffb
Merge pull request #4 from bpfoley/clang-warnings
msoos Feb 12, 2020
b69cb5f
Export minisat project for other cmake builds
msoos Aug 31, 2020
f7d16b9
Updating to fix build
msoos Aug 31, 2020
93da0f0
Fixing static vs. dynamic compile
msoos Feb 28, 2019
a2c6fe6
Export minisat project for other cmake builds
msoos Aug 31, 2020
dd31450
Updating to fix build
msoos Aug 31, 2020
16d13d0
Merge pull request #5 from stp/stp-master
msoos Sep 1, 2020
1193f18
CMakeLists: support different lib dirs
Nov 4, 2019
5f9111f
Removing second STATICCOMPILE
msoos Sep 2, 2020
5b16571
Revert "CMakeLists: support different lib dirs"
msoos Sep 2, 2020
5a38d36
Adding uninstall capability
msoos Sep 2, 2020
37158a3
Fixing exported definitions
msoos Sep 2, 2020
8ac9a99
Merge branch 'stp-master'
msoos Sep 19, 2020
55d7e76
Print more about elimination performance
msoos Dec 15, 2020
43079d2
Fixing static/dynamic Windows builds
msoos Aug 23, 2021
6e8ae45
Making it work as a fuzzer
msoos Jan 31, 2024
c1a7bc1
Fixing minisat for MacOSX
msoos Jan 31, 2024
c250516
Removing zlib dependency from minisat
msoos Jan 31, 2024
d470226
Fixing solution printing for minisat
msoos Dec 7, 2017
0d3b95e
Fixing minisat output
msoos Mar 23, 2018
5b489d2
Less warnings
msoos May 13, 2018
8ab934f
Removing some warnings
msoos May 13, 2018
c0dbd0d
Fixing cmake warning
msoos May 14, 2018
0dd9ca0
Error introduced in minisat, oops
msoos May 17, 2018
ab1a1f3
Removing warning
msoos May 22, 2019
c479dce
Bumping cmake version
msoos Jan 31, 2024
d9b3463
Fixing up post-merge
msoos Jan 31, 2024
f993cfb
Updating to build without warnings
msoos Jan 31, 2024
4223231
Compile with fPIC
msoos Apr 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
173 changes: 139 additions & 34 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
cmake_minimum_required(VERSION 3.11 FATAL_ERROR)

project(minisat)

if(POLICY CMP0048)
#policy for VERSION in cmake 3.0
cmake_policy(SET CMP0048 NEW)
endif()

#--------------------------------------------------------------------------------------------------
# Configurable options:

Expand All @@ -23,17 +28,139 @@ else()
endif()
set(MINISAT_SOVERSION ${MINISAT_SOMAJOR})

#--------------------------------------------------------------------------------------------------
# Dependencies:

find_package(ZLIB)
include_directories(${ZLIB_INCLUDE_DIR})
include_directories(${minisat_SOURCE_DIR})
include_directories(${PROJECT_SOURCE_DIR})

#--------------------------------------------------------------------------------------------------
# Compile flags:

add_definitions(-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS)
add_cxx_flag_if_supported("-Wno-format-nonliteral")
add_cxx_flag_if_supported("-Wno-class-memaccess")



#--------------------------------------------------------------------------------------------------
option(STATICCOMPILE "Compile static library and executable" OFF)

option(BUILD_SHARED_LIBS "Build the shared library" ON)
if (STATICCOMPILE)
set(BUILD_SHARED_LIBS OFF)
endif()

if (NOT BUILD_SHARED_LIBS)
if (NOT MSVC)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static -Wl,--whole-archive -lpthread -Wl,--no-whole-archive -static ")
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")

# removing -rdynamic that's automatically added
foreach (language CXX C)
set(VAR_TO_MODIFY "CMAKE_SHARED_LIBRARY_LINK_${language}_FLAGS")
string(REGEX REPLACE "(^| )-rdynamic($| )"
" "
replacement
"${${VAR_TO_MODIFY}}")
#message("Original (${VAR_TO_MODIFY}) is ${${VAR_TO_MODIFY}} replacement is ${replacement}")
set(${VAR_TO_MODIFY} "${replacement}" CACHE STRING "Default flags for ${build_config} configuration" FORCE)
endforeach()
endif()
else ()
# use, i.e. don't skip the full RPATH for the build tree
SET(CMAKE_SKIP_BUILD_RPATH FALSE)

# when building, don't use the install RPATH already
# (but later on when installing)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)

SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_LIBDIR}")

# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

# the RPATH to be used when installing, but only if it's not a system directory
LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_LIBDIR}" isSystemDir)
IF("${isSystemDir}" STREQUAL "-1")
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_LIBDIR}")
ENDIF("${isSystemDir}" STREQUAL "-1")

if (APPLE)
set(CMAKE_MACOSX_RPATH ON)
set(CMAKE_INSTALL_RPATH "@loader_path/../lib")
message(STATUS "Using RPATH for dynamic linking")
endif()
endif()

if (NOT MSVC)
add_compile_options( -g)
add_compile_options( -pthread )
add_compile_options( -fPIC )
add_compile_options("$<$<CONFIG:RELWITHDEBINFO>:-O2>")

add_compile_options("$<$<CONFIG:RELEASE>:-O2>")
add_compile_options("$<$<CONFIG:RELEASE>:-g0>")

add_compile_options("$<$<CONFIG:DEBUG>:-O0>")

if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -O2")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -O2")
endif()
else()
# see https://msdn.microsoft.com/en-us/library/fwkeyyhe.aspx for details
# /ZI = include debug info
# /Wall = all warnings

add_compile_options("$<$<CONFIG:RELWITHDEBINFO>:/O2>")
add_compile_options("$<$<CONFIG:RELWITHDEBINFO>:/ZI>")

add_compile_options("$<$<CONFIG:RELEASE>:/O2>")
add_compile_options("$<$<CONFIG:RELEASE>:/D>")
add_compile_options("$<$<CONFIG:RELEASE>:/NDEBUG>")

add_compile_options("$<$<CONFIG:DEBUG>:/Od>")

# buffers security check
add_compile_options(/GS)

# Proper warning level
add_compile_options(/W1)

# Disable STL used in DLL-boundary warning
add_compile_options(/wd4251)
add_compile_options(/D_CRT_SECURE_NO_WARNINGS)

# Wall is MSVC's Weverything, so annoying unless used from the start
# and with judiciously used warning disables
# add_compile_options(/Wall)

# /Za = only ansi C98 & C++11
# /Za is not recommended for use, not tested, etc.
# see: http://stackoverflow.com/questions/5489326/za-compiler-directive-does-not-compile-system-headers-in-vs2010
# add_compile_options(/Za)

add_compile_options(/fp:precise)

# exception handling. s = The exception-handling model that catches C++ exceptions only and tells the compiler to assume that functions declared as extern "C" may throw an exception.
# exception handling. c = If used with s (/EHsc), catches C++ exceptions only and tells the compiler to assume that functions declared as extern "C" never throw a C++ exception.
add_compile_options(/EHsc)

#what does this do?
set(DEF_INSTALL_CMAKE_DIR CMake)
endif()
set(MINISAT_EXPORT_NAME "minisatTargets")

# -----------------------------------------------------------------------------
# Add uninstall target for makefiles
# -----------------------------------------------------------------------------
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY
)

add_custom_target(uninstall-minisat
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
)

#--------------------------------------------------------------------------------------------------
# Build Targets:
Expand All @@ -44,40 +171,18 @@ set(MINISAT_LIB_SOURCES
minisat/core/Solver.cc
minisat/simp/SimpSolver.cc)

add_library(minisat-lib-static STATIC ${MINISAT_LIB_SOURCES})
add_library(minisat-lib-shared SHARED ${MINISAT_LIB_SOURCES})

target_link_libraries(minisat-lib-shared ${ZLIB_LIBRARY})
target_link_libraries(minisat-lib-static ${ZLIB_LIBRARY})
add_library(minisat ${MINISAT_LIB_SOURCES})

add_executable(minisat_core minisat/core/Main.cc)
add_executable(minisat_simp minisat/simp/Main.cc)

if(STATIC_BINARIES)
target_link_libraries(minisat_core minisat-lib-static)
target_link_libraries(minisat_simp minisat-lib-static)
else()
target_link_libraries(minisat_core minisat-lib-shared)
target_link_libraries(minisat_simp minisat-lib-shared)
endif()
target_link_libraries(minisat_core minisat)
target_link_libraries(minisat_simp minisat)

set_target_properties(minisat-lib-static PROPERTIES OUTPUT_NAME "minisat")
set_target_properties(minisat-lib-shared
set_target_properties(minisat
PROPERTIES
OUTPUT_NAME "minisat"
OUTPUT_NAME "minisat"
VERSION ${MINISAT_VERSION}
SOVERSION ${MINISAT_SOVERSION})

set_target_properties(minisat_simp PROPERTIES OUTPUT_NAME "minisat")

#--------------------------------------------------------------------------------------------------
# Installation targets:

install(TARGETS minisat-lib-static minisat-lib-shared minisat_core minisat_simp
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)

install(DIRECTORY minisat/mtl minisat/utils minisat/core minisat/simp
DESTINATION include/minisat
FILES_MATCHING PATTERN "*.h")
92 changes: 92 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# branches to build
branches:
# whitelist
only:
- master
- appveyor_debug

# Operating system (build VM template)
os: Visual Studio 2015

# scripts that are called at very beginning, before repo cloning
init:
- git config --global core.autocrlf input


# clone directory
clone_folder: c:\projects\minisat

platform:
- x64
# - x86

environment:
global:
BOOST_ROOT: C:\projects\minisat\boost_1_59_0_install
ZLIB_ROOT: C:\projects\minisat\zlib\myinstall
BUILD_TYPE: Release
MSBUILD_FLAGS: /maxcpucount /nologo

configuration:
- Release

build_script:
#- IF "%PLATFORM%" == "x86" ( SET BOOST_LIBRARYDIR=C:/Libraries/boost_1_59_0/lib32-msvc-14.0)
- IF "%PLATFORM%" == "x86" ( SET CMAKE_GENERATOR="Visual Studio 14 2015")

#- IF "%PLATFORM%" == "x64" ( SET BOOST_LIBRARYDIR=C:/Libraries/boost_1_59_0/lib64-msvc-14.0)
- IF "%PLATFORM%" == "x64" ( SET CMAKE_GENERATOR="Visual Studio 14 2015 Win64")

- echo %PLATFORM%
- echo %BOOST_LIBRARYDIR%
- echo %CMAKE_GENERATOR%
- echo %configuration%
- echo %APPVEYOR_BUILD_FOLDER%
- echo %cd%

# zlib
# TODO check out http://stackoverflow.com/questions/10507893/libzip-with-visual-studio-2010
- cd C:\projects\minisat
- git clone https://github.com/madler/zlib
- cd zlib
- git checkout v1.2.8
- echo %cd%
- mkdir build
- mkdir myinstall
- cd build
- cmake -G %CMAKE_GENERATOR% -DCMAKE_INSTALL_PREFIX=%ZLIB_ROOT% ..
- if %PLATFORM%==x86 call msbuild %MSBUILD_FLAGS% /t:Build /p:Configuration=%CONFIGURATION% /p:Platform="x86" zlib.sln
- if %PLATFORM%==x64 call msbuild %MSBUILD_FLAGS% /t:Build /p:Configuration=%CONFIGURATION% /p:Platform="x64" zlib.sln
- msbuild %MSBUILD_FLAGS% INSTALL.vcxproj
- dir ..\myinstall\

# minisat
- cd C:\projects\minisat
- mkdir build
- mkdir myinstall
- cd build
- cmake -G %CMAKE_GENERATOR% -DCMAKE_INSTALL_PREFIX=%MINISAT_ROOT% -DZLIB_ROOT=%ZLIB_ROOT% ..
- cmake --build . --config %CONFIGURATION%
- dir ..\myinstall\


build:
# project: INSTALL.vcxproj # path to Visual Studio solution or project
parallel: true
verbosity: minimal


# scripts to run after build
after_build:
- 7z a c:\projects\minisat\minisat.zip %APPVEYOR_BUILD_FOLDER%\build -tzip
- cd c:\projects\minisat

artifacts:
- path: minisat.zip
name: minisat.zip

deploy_script:
#- cd c:\projects\minisat
#- curl -T minisat.zip --user %ACCOUNT% https://someplace/

test: off
24 changes: 24 additions & 0 deletions cmake_uninstall.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
cmake_policy(SET CMP0007 NEW) # Suppress warnings see `cmake --help-policy CMP0007`

if (NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
message(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")

file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
string(REGEX REPLACE "\n" ";" files "${files}")
list(REVERSE files)
foreach (file ${files})
message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
if (EXISTS "$ENV{DESTDIR}${file}")
execute_process(
COMMAND @CMAKE_COMMAND@ -E remove "$ENV{DESTDIR}${file}"
OUTPUT_VARIABLE rm_out
RESULT_VARIABLE rm_retval
)
if(NOT ${rm_retval} EQUAL 0)
message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
endif (NOT ${rm_retval} EQUAL 0)
else (EXISTS "$ENV{DESTDIR}${file}")
message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
endif (EXISTS "$ENV{DESTDIR}${file}")
endforeach(file)
6 changes: 3 additions & 3 deletions minisat/core/Dimacs.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ static void readClause(B& in, Solver& S, vec<Lit>& lits) {
template<class B, class Solver>
static void parse_DIMACS_main(B& in, Solver& S, bool strictp = false) {
vec<Lit> lits;
int vars = 0;
//int vars = 0;
int clauses = 0;
int cnt = 0;
for (;;){
skipWhitespace(in);
if (*in == EOF) break;
else if (*in == 'p'){
if (eagerMatch(in, "p cnf")){
vars = parseInt(in);
parseInt(in);
clauses = parseInt(in);
// SATRACE'06 hack
// if (clauses > 4000000)
Expand All @@ -77,7 +77,7 @@ static void parse_DIMACS_main(B& in, Solver& S, bool strictp = false) {
// Inserts problem into solver.
//
template<class Solver>
static void parse_DIMACS(gzFile input_stream, Solver& S, bool strictp = false) {
static void parse_DIMACS(FILE* input_stream, Solver& S, bool strictp = false) {
StreamBuffer in(input_stream);
parse_DIMACS_main(in, S, strictp); }

Expand Down
5 changes: 2 additions & 3 deletions minisat/core/Main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWA
**************************************************************************************************/

#include <errno.h>
#include <zlib.h>

#include "minisat/utils/System.h"
#include "minisat/utils/ParseUtils.h"
Expand Down Expand Up @@ -84,7 +83,7 @@ int main(int argc, char** argv)
if (argc == 1)
printf("Reading from standard input... Use '--help' for help.\n");

gzFile in = (argc == 1) ? gzdopen(0, "rb") : gzopen(argv[1], "rb");
FILE* in = (argc == 1) ? fdopen(0, "rb") : fopen(argv[1], "rb");
if (in == NULL)
printf("ERROR! Could not open file: %s\n", argc == 1 ? "<stdin>" : argv[1]), exit(1);

Expand All @@ -93,7 +92,7 @@ int main(int argc, char** argv)
printf("| |\n"); }

parse_DIMACS(in, S, (bool)strictp);
gzclose(in);
fclose(in);
FILE* res = (argc >= 3) ? fopen(argv[2], "wb") : NULL;

if (S.verbosity > 0){
Expand Down
10 changes: 5 additions & 5 deletions minisat/core/Solver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -992,11 +992,11 @@ void Solver::printStats() const
{
double cpu_time = cpuTime();
double mem_used = memUsedPeak();
printf("restarts : %"PRIu64"\n", starts);
printf("conflicts : %-12"PRIu64" (%.0f /sec)\n", conflicts , conflicts /cpu_time);
printf("decisions : %-12"PRIu64" (%4.2f %% random) (%.0f /sec)\n", decisions, (float)rnd_decisions*100 / (float)decisions, decisions /cpu_time);
printf("propagations : %-12"PRIu64" (%.0f /sec)\n", propagations, propagations/cpu_time);
printf("conflict literals : %-12"PRIu64" (%4.2f %% deleted)\n", tot_literals, (max_literals - tot_literals)*100 / (double)max_literals);
printf("restarts : %" PRIu64 "\n", starts);
printf("conflicts : %-12" PRIu64 " (%.0f /sec)\n", conflicts , conflicts /cpu_time);
printf("decisions : %-12" PRIu64 " (%4.2f %% random) (%.0f /sec)\n", decisions, (float)rnd_decisions*100 / (float)decisions, decisions /cpu_time);
printf("propagations : %-12" PRIu64 " (%.0f /sec)\n", propagations, propagations/cpu_time);
printf("conflict literals : %-12" PRIu64 " (%4.2f %% deleted)\n", tot_literals, (max_literals - tot_literals)*100 / (double)max_literals);
if (mem_used != 0) printf("Memory used : %.2f MB\n", mem_used);
printf("CPU time : %g s\n", cpu_time);
}
Expand Down
Loading