### Build QuadriFlow with CMake Source: https://github.com/hjwdzh/quadriflow/blob/master/README.md Clone the repository and build with CMake in release mode. Run `sh demo.sh` to build and try the example that converts `examples/Gargoyle_input.obj` to `examples/Gargoyle_quadriflow.obj`. ```bash git clone git://github.com/hjwdzh/quadriflow cd quadriflow mkdir build cd build cmake .. -DCMAKE_BUILD_TYPE=release make -j ``` -------------------------------- ### Verify minisat and timeout Installation Source: https://github.com/hjwdzh/quadriflow/blob/master/README.md Check that the minisat and timeout binaries are properly installed and accessible in PATH before enabling SAT flip removal. ```bash which minisat which timeout ``` -------------------------------- ### Install lemon library and headers Source: https://github.com/hjwdzh/quadriflow/blob/master/3rd/lemon-1.3.1/lemon/CMakeLists.txt Installs the lemon library to lib, headers to include/lemon, and the generated config.h and lemon.pc to their respective destinations. Headers are installed with component 'headers' and library with component 'library'. ```CMake INSTALL( TARGETS lemon ARCHIVE DESTINATION lib LIBRARY DESTINATION lib COMPONENT library ) INSTALL( DIRECTORY . bits concepts DESTINATION include/lemon COMPONENT headers FILES_MATCHING PATTERN "*.h" ) INSTALL( FILES ${CMAKE_CURRENT_BINARY_DIR}/config.h DESTINATION include/lemon COMPONENT headers ) INSTALL( FILES ${CMAKE_CURRENT_BINARY_DIR}/lemon.pc DESTINATION lib/pkgconfig ) ``` -------------------------------- ### Build QuadriFlow with Gurobi Support Source: https://github.com/hjwdzh/quadriflow/blob/master/README.md Build QuadriFlow with Gurobi integer programming support for benchmarking. This overrides other solvers and should only be used for benchmark purposes. ```bash cmake .. -DCMAKE_BUILD_TYPE=release -DBUILD_GUROBI=ON -DBUILD_LOG=ON ``` -------------------------------- ### Build QuadriFlow with Logging Enabled Source: https://github.com/hjwdzh/quadriflow/blob/master/README.md Build QuadriFlow with verbose logging enabled, recommended when using SAT flip removal to understand what is going on. ```bash cmake .. -DCMAKE_BUILD_TYPE=release -DBUILD_LOG=ON ``` -------------------------------- ### LEMON library setup in CMake Source: https://github.com/hjwdzh/quadriflow/blob/master/CMakeLists.txt Locates LEMON source in the 3rd/lemon-1.3.1 directory. If present, adds it as a subproject and sets include and library variables; otherwise falls back to find_package(LEMON). ```CMake set(LEMON_3RD_PATH 3rd/lemon-1.3.1) find_path( LEMON_SOURCE_ROOT_DIR CMakeLists.txt PATHS ${CMAKE_SOURCE_DIR}/${LEMON_3RD_PATH} NO_DEFAULT_PATH DOC "Location of LEMON source as a CMAKE subproject" ) if (EXISTS ${LEMON_SOURCE_ROOT_DIR}) add_subdirectory(${LEMON_SOURCE_ROOT_DIR}) set(LEMON_INCLUDE_DIRS ${LEMON_SOURCE_ROOT_DIR} ${PROJECT_BINARY_DIR}/${LEMON_3RD_PATH}) set(LEMON_LIBRARIES lemon) unset(LEMON_ROOT_DIR CACHE) unset(LEMON_DIR CACHE) unset(LEMON_INCLUDE_DIR CACHE) unset(LEMON_LIBRARY CACHE) else() find_package(LEMON QUIET NO_MODULE) find_package(LEMON REQUIRED) endif() ``` -------------------------------- ### Install coreutils via Homebrew for SAT Flip Removal Source: https://github.com/hjwdzh/quadriflow/blob/master/README.md Install coreutils on macOS to provide the timeout command required for SAT flip removal. The export adds the GNU coreutils binaries to PATH. ```bash brew install coreutils export PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH" ``` -------------------------------- ### Citation entry for QuadriFlow paper Source: https://github.com/hjwdzh/quadriflow/blob/master/README.md BibTeX entry to cite when using QuadriFlow in a publication. ```bibtex @article {10.1111:cgf.13498, journal = {Computer Graphics Forum}, title = {{QuadriFlow: A Scalable and Robust Method for Quadrangulation}}, author = {Huang, Jingwei and Zhou, Yichao and Niessner, Matthias and Shewchuk, Jonathan Richard and Guibas, Leonidas J.}, year = {2018}, publisher = {The Eurographics Association and John Wiley & Sons Ltd.}, ISSN = {1467-8659}, DOI = {10.1111/cgf.13498} } ``` -------------------------------- ### Commented example for adding an executable linked to lemon Source: https://github.com/hjwdzh/quadriflow/blob/master/3rd/lemon-1.3.1/contrib/CMakeLists.txt Shows how to define an executable and link it against the lemon library. The lines are commented out; uncomment and adjust 'myprog' and 'myprog-main.cc' to build your own program. On Windows, '.exe' is appended automatically. ```CMake # ADD_EXECUTABLE(myprog myprog-main.cc) # TARGET_LINK_LIBRARIES(myprog lemon) ``` -------------------------------- ### CMakeLists.txt for LEMON tools Source: https://github.com/hjwdzh/quadriflow/blob/master/3rd/lemon-1.3.1/tools/CMakeLists.txt Defines build configuration for lgf-gen, dimacs-to-lgf, and dimacs-solver executables, linking against the lemon library. Installs binaries to bin and conditionally installs lemon-0.x-to-1.x.sh on non-Windows platforms. ```CMake INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} ) LINK_DIRECTORIES( ${PROJECT_BINARY_DIR}/lemon ) ADD_EXECUTABLE(lgf-gen lgf-gen.cc) TARGET_LINK_LIBRARIES(lgf-gen lemon) ADD_EXECUTABLE(dimacs-to-lgf dimacs-to-lgf.cc) TARGET_LINK_LIBRARIES(dimacs-to-lgf lemon) ADD_EXECUTABLE(dimacs-solver dimacs-solver.cc) TARGET_LINK_LIBRARIES(dimacs-solver lemon) INSTALL( TARGETS lgf-gen dimacs-to-lgf dimacs-solver RUNTIME DESTINATION bin COMPONENT bin ) IF(NOT WIN32) INSTALL( PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/lemon-0.x-to-1.x.sh DESTINATION bin COMPONENT bin ) ENDIF() ``` -------------------------------- ### Run QuadriFlow CLI Source: https://github.com/hjwdzh/quadriflow/blob/master/README.md Command-line usage: takes a manifold triangle mesh `input.obj` and generates a manifold quad mesh `output.obj`. The `-f` flag sets the desired number of faces in the quad mesh; the face number increases linearly with resolution. ```bash ./quadriflow -i input.obj -o output.obj -f [resolution] ``` -------------------------------- ### CPack configuration for NSIS installer Source: https://github.com/hjwdzh/quadriflow/blob/master/3rd/lemon-1.3.1/CMakeLists.txt Configures CPack for NSIS packaging when building from the source directory. Sets package metadata, component groups, install types, and NSIS-specific settings like icons and shortcuts. ```CMake # CPACK config (Basically for NSIS) IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR}) SET(CPACK_PACKAGE_NAME ${PROJECT_NAME}) SET(CPACK_PACKAGE_VENDOR "EGRES") SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "LEMON - Library for Efficient Modeling and Optimization in Networks") SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE") SET(CPACK_PACKAGE_VERSION ${PROJECT_VERSION}) SET(CPACK_PACKAGE_INSTALL_DIRECTORY "${PROJECT_NAME} ${PROJECT_VERSION}") SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${PROJECT_NAME} ${PROJECT_VERSION}") SET(CPACK_COMPONENTS_ALL headers library html_documentation bin) SET(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ headers") SET(CPACK_COMPONENT_LIBRARY_DISPLAY_NAME "Dynamic-link library") SET(CPACK_COMPONENT_BIN_DISPLAY_NAME "Command line utilities") SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DISPLAY_NAME "HTML documentation") SET(CPACK_COMPONENT_HEADERS_DESCRIPTION "C++ header files") SET(CPACK_COMPONENT_LIBRARY_DESCRIPTION "DLL and import library") SET(CPACK_COMPONENT_BIN_DESCRIPTION "Command line utilities") SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DESCRIPTION "Doxygen generated documentation") SET(CPACK_COMPONENT_HEADERS_DEPENDS library) SET(CPACK_COMPONENT_HEADERS_GROUP "Development") SET(CPACK_COMPONENT_LIBRARY_GROUP "Development") SET(CPACK_COMPONENT_HTML_DOCUMENTATION_GROUP "Documentation") SET(CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION "Components needed to develop software using LEMON") SET(CPACK_COMPONENT_GROUP_DOCUMENTATION_DESCRIPTION "Documentation of LEMON") SET(CPACK_ALL_INSTALL_TYPES Full Developer) SET(CPACK_COMPONENT_HEADERS_INSTALL_TYPES Developer Full) SET(CPACK_COMPONENT_LIBRARY_INSTALL_TYPES Developer Full) SET(CPACK_COMPONENT_HTML_DOCUMENTATION_INSTALL_TYPES Full) SET(CPACK_GENERATOR "NSIS") SET(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis/lemon.ico") SET(CPACK_NSIS_MUI_UNIICON "${PROJECT_SOURCE_DIR}/cmake/nsis/uninstall.ico") #SET(CPACK_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis\\installer.bmp") SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\lemon.ico") SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} ${PROJECT_NAME}") SET(CPACK_NSIS_HELP_LINK "http:\\\\lemon.cs.elte.hu") SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\lemon.cs.elte.hu") SET(CPACK_NSIS_CONTACT "lemon-user@lemon.cs.elte.hu") SET(CPACK_NSIS_CREATE_ICONS_EXTRA " CreateShortCut \"$SMPROGRAMS\\$STARTMENU_FOLDER\\Documentation.lnk\" \"$INSTDIR\\share\\doc\\index.html\" ") SET(CPACK_NSIS_DELETE_ICONS_EXTRA " !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP Delete \"$SMPROGRAMS\\$MUI_TEMP\\Documentation.lnk\" ") INCLUDE(CPack) ENDIF() ``` -------------------------------- ### Enable SAT Flip Removal with -sat Source: https://github.com/hjwdzh/quadriflow/blob/master/README.md Remove flips in the integer offsets map and guarantee a watertight result mesh using the SAT solver. Requires minisat and timeout to be installed. ```bash ./quadriflow -sat -i input.obj -o output.obj -f [resolution] ``` -------------------------------- ### CMake test setup for LEMON library Source: https://github.com/hjwdzh/quadriflow/blob/master/3rd/lemon-1.3.1/test/CMakeLists.txt Configures include and link directories, defines test list, and sets up test executables for the LEMON library. Includes conditional handling for LP and MIP tests with optional solver libraries and Windows DLL copying. ```CMake INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} ) LINK_DIRECTORIES( ${PROJECT_BINARY_DIR}/lemon ) SET(TEST_WITH_VALGRIND "NO" CACHE STRING "Run the test with valgrind (YES/NO).") SET(VALGRIND_FLAGS "" CACHE STRING "Valgrind flags used by the tests.") SET(TESTS adaptors_test arc_look_up_test bellman_ford_test bfs_test bpgraph_test circulation_test connectivity_test counter_test dfs_test digraph_test dijkstra_test dim_test edge_set_test error_test euler_test fractional_matching_test gomory_hu_test graph_copy_test graph_test graph_utils_test hao_orlin_test heap_test kruskal_test lgf_reader_writer_test lgf_test maps_test matching_test max_cardinality_search_test max_clique_test max_flow_test min_cost_arborescence_test min_cost_flow_test min_mean_cycle_test nagamochi_ibaraki_test path_test planarity_test radix_sort_test random_test suurballe_test time_measure_test tsp_test unionfind_test ) IF(LEMON_HAVE_LP) IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer") ADD_EXECUTABLE(lp_test lp_test.cc) ELSE() ADD_EXECUTABLE(lp_test EXCLUDE_FROM_ALL lp_test.cc) ENDIF() SET(LP_TEST_LIBS lemon) IF(LEMON_HAVE_GLPK) SET(LP_TEST_LIBS ${LP_TEST_LIBS} ${GLPK_LIBRARIES}) ENDIF() IF(LEMON_HAVE_CPLEX) SET(LP_TEST_LIBS ${LP_TEST_LIBS} ${ILOG_LIBRARIES}) ENDIF() IF(LEMON_HAVE_CLP) SET(LP_TEST_LIBS ${LP_TEST_LIBS} ${COIN_CLP_LIBRARIES}) ENDIF() IF(LEMON_HAVE_SOPLEX) SET(LP_TEST_LIBS ${LP_TEST_LIBS} ${SOPLEX_LIBRARIES}) ENDIF() TARGET_LINK_LIBRARIES(lp_test ${LP_TEST_LIBS}) ADD_TEST(lp_test lp_test) ADD_DEPENDENCIES(check lp_test) IF(WIN32 AND LEMON_HAVE_GLPK) GET_TARGET_PROPERTY(TARGET_LOC lp_test LOCATION) GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH) ADD_CUSTOM_COMMAND(TARGET lp_test POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/glpk.dll ${TARGET_PATH} COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/libltdl3.dll ${TARGET_PATH} COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/zlib1.dll ${TARGET_PATH} ) ENDIF() IF(WIN32 AND LEMON_HAVE_CPLEX) GET_TARGET_PROPERTY(TARGET_LOC lp_test LOCATION) GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH) ADD_CUSTOM_COMMAND(TARGET lp_test POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${ILOG_CPLEX_DLL} ${TARGET_PATH} ) ENDIF() ENDIF() IF(LEMON_HAVE_MIP) IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer") ADD_EXECUTABLE(mip_test mip_test.cc) ELSE() ADD_EXECUTABLE(mip_test EXCLUDE_FROM_ALL mip_test.cc) ENDIF() SET(MIP_TEST_LIBS lemon) IF(LEMON_HAVE_GLPK) SET(MIP_TEST_LIBS ${MIP_TEST_LIBS} ${GLPK_LIBRARIES}) ENDIF() IF(LEMON_HAVE_CPLEX) SET(MIP_TEST_LIBS ${MIP_TEST_LIBS} ${ILOG_LIBRARIES}) ENDIF() IF(LEMON_HAVE_CBC) SET(MIP_TEST_LIBS ${MIP_TEST_LIBS} ${COIN_CBC_LIBRARIES}) ENDIF() TARGET_LINK_LIBRARIES(mip_test ${MIP_TEST_LIBS}) ADD_TEST(mip_test mip_test) ADD_DEPENDENCIES(check mip_test) IF(WIN32 AND LEMON_HAVE_GLPK) GET_TARGET_PROPERTY(TARGET_LOC mip_test LOCATION) GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH) ADD_CUSTOM_COMMAND(TARGET mip_test POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/glpk.dll ${TARGET_PATH} COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/libltdl3.dll ${TARGET_PATH} COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/zlib1.dll ${TARGET_PATH} ) ENDIF() IF(WIN32 AND LEMON_HAVE_CPLEX) GET_TARGET_PROPERTY(TARGET_LOC mip_test LOCATION) GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH) ADD_CUSTOM_COMMAND(TARGET mip_test POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${ILOG_CPLEX_DLL} ${TARGET_PATH} ) ENDIF() ENDIF() FOREACH(TEST_NAME ${TESTS}) IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer") ADD_EXECUTABLE(${TEST_NAME} ${TEST_NAME}.cc) ELSE() ADD_EXECUTABLE(${TEST_NAME} EXCLUDE_FROM_ALL ${TEST_NAME}.cc) ENDIF() TARGET_LINK_LIBRARIES(${TEST_NAME} lemon) IF(TEST_WITH_VALGRIND) ADD_TEST(${TEST_NAME} valgrind --error-exitcode=1 ${VALGRIND_FLAGS} ${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME} ) ELSE() ADD_TEST(${TEST_NAME} ${TEST_NAME}) ENDIF() ADD_DEPENDENCIES(check ${TEST_NAME}) ENDFOREACH() ``` -------------------------------- ### Conditionally add GLPK support Source: https://github.com/hjwdzh/quadriflow/blob/master/3rd/lemon-1.3.1/lemon/CMakeLists.txt Adds glpk.cc to sources and includes GLPK headers when LEMON_HAVE_GLPK is enabled. On Windows, installs required DLLs (glpk.dll, libltdl3.dll, zlib1.dll) to the bin directory. ```CMake IF(LEMON_HAVE_GLPK) SET(LEMON_SOURCES ${LEMON_SOURCES} glpk.cc) INCLUDE_DIRECTORIES(${GLPK_INCLUDE_DIRS}) IF(WIN32) INSTALL(FILES ${GLPK_BIN_DIR}/glpk.dll DESTINATION bin) INSTALL(FILES ${GLPK_BIN_DIR}/libltdl3.dll DESTINATION bin) INSTALL(FILES ${GLPK_BIN_DIR}/zlib1.dll DESTINATION bin) ENDIF() ENDIF() ``` -------------------------------- ### Enable Sharp Edge Preservation with -sharp Source: https://github.com/hjwdzh/quadriflow/blob/master/README.md Explicitly detect and preserve sharp edges in the model. The -sharp flag is passed to the quadriflow command. ```bash ./quadriflow -sharp -i input.obj -o output.obj -f [resolution] ``` -------------------------------- ### Enable Min-cost Flow Solver with -mcf Source: https://github.com/hjwdzh/quadriflow/blob/master/README.md Use the adaptive network simplex minimum-cost flow solver instead of the default Boykov maximum flow solver. The -mcf flag is passed to the quadriflow command. ```bash ./quadriflow -mcf -i input.obj -o output.obj -f [resolution] ``` -------------------------------- ### Configure include directories and config files Source: https://github.com/hjwdzh/quadriflow/blob/master/3rd/lemon-1.3.1/lemon/CMakeLists.txt Sets up include directories for the project and generates config.h and lemon.pc from templates using CONFIGURE_FILE. The lemon.pc generation uses @ONLY to substitute only @VAR@ references. ```CMake INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} ) CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h ) CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/lemon.pc.in ${CMAKE_CURRENT_BINARY_DIR}/lemon.pc @ONLY ) ``` -------------------------------- ### CMakeLists.txt for LEMON demo executables Source: https://github.com/hjwdzh/quadriflow/blob/master/3rd/lemon-1.3.1/demo/CMakeLists.txt Configures include and link directories for the LEMON library, then builds demo executables (arg_parser_demo, graph_to_eps_demo, lgf_demo) from their .cc sources, linking each against the lemon library. ```CMake INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} ) LINK_DIRECTORIES( ${PROJECT_BINARY_DIR}/lemon ) SET(DEMOS arg_parser_demo graph_to_eps_demo lgf_demo ) FOREACH(DEMO_NAME ${DEMOS}) ADD_EXECUTABLE(${DEMO_NAME} ${DEMO_NAME}.cc) TARGET_LINK_LIBRARIES(${DEMO_NAME} lemon) ENDFOREACH() ``` -------------------------------- ### Build lemon library and link dependencies Source: https://github.com/hjwdzh/quadriflow/blob/master/3rd/lemon-1.3.1/lemon/CMakeLists.txt Creates the lemon library from LEMON_SOURCES and links against GLPK, COIN, ILOG, and SoPlex libraries. On UNIX, sets the output name to 'emon' with version and SOVERSION properties. ```CMake ADD_LIBRARY(lemon ${LEMON_SOURCES}) TARGET_LINK_LIBRARIES(lemon ${GLPK_LIBRARIES} ${COIN_LIBRARIES} ${ILOG_LIBRARIES} ${SOPLEX_LIBRARIES} ) IF(UNIX) SET_TARGET_PROPERTIES(lemon PROPERTIES OUTPUT_NAME emon VERSION ${LEMON_VERSION} SOVERSION ${LEMON_VERSION}) ENDIF() ``` -------------------------------- ### Define LEMON_SOURCES list Source: https://github.com/hjwdzh/quadriflow/blob/master/3rd/lemon-1.3.1/lemon/CMakeLists.txt Lists the core source files for the lemon library, including platform-specific bits/windows.cc. ```CMake SET(LEMON_SOURCES arg_parser.cc base.cc color.cc lp_base.cc lp_skeleton.cc random.cc bits/windows.cc ) ``` -------------------------------- ### Include directories and build definitions in CMake Source: https://github.com/hjwdzh/quadriflow/blob/master/CMakeLists.txt Adds include directories for source and third-party libraries. Adds preprocessor definitions based on build options: PERFORMANCE_TEST, WITH_OMP, LOG_OUTPUT, WITH_GUROBI, WITH_TBB, and EIGEN_MPL2_ONLY. ```CMake include_directories(src) include_directories(3rd/pcg32) include_directories(3rd/pss) include_directories(${Boost_INCLUDE_DIRS}) include_directories(${EIGEN_INCLUDE_DIRS}) include_directories(${GLM_INCLUDE_DIRS}) include_directories(${GLUT_INCLUDE_DIRS}) include_directories(${LEMON_INCLUDE_DIRS}) include_directories(${TBB_INCLUDE_DIRS}) include_directories(${GUROBI_INCLUDE_DIRS}) if (BUILD_PERFORMANCE_TEST) add_definitions(-DPERFORMANCE_TEST) endif(BUILD_PERFORMANCE_TEST) if (BUILD_OPENMP) add_definitions(-DWITH_OMP) endif(BUILD_OPENMP) if (BUILD_LOG) add_definitions(-DLOG_OUTPUT) endif(BUILD_LOG) if (BUILD_GUROBI) add_definitions(-DWITH_GUROBI) endif(BUILD_GUROBI) if (BUILD_TBB) add_definitions(-DWITH_TBB) endif(BUILD_TBB) if (BUILD_FREE_LICENSE) add_definitions(-DEIGEN_MPL2_ONLY) endif(BUILD_FREE_LICENSE) ``` -------------------------------- ### Conditionally add CLP support Source: https://github.com/hjwdzh/quadriflow/blob/master/3rd/lemon-1.3.1/lemon/CMakeLists.txt Adds clp.cc to sources and includes COIN headers when LEMON_HAVE_CLP is enabled. ```CMake IF(LEMON_HAVE_CLP) SET(LEMON_SOURCES ${LEMON_SOURCES} clp.cc) INCLUDE_DIRECTORIES(${COIN_INCLUDE_DIRS}) ENDIF() ``` -------------------------------- ### Conditionally add CBC support Source: https://github.com/hjwdzh/quadriflow/blob/master/3rd/lemon-1.3.1/lemon/CMakeLists.txt Adds cbc.cc to sources and includes COIN headers when LEMON_HAVE_CBC is enabled. ```CMake IF(LEMON_HAVE_CBC) SET(LEMON_SOURCES ${LEMON_SOURCES} cbc.cc) INCLUDE_DIRECTORIES(${COIN_INCLUDE_DIRS}) ENDIF() ``` -------------------------------- ### CMake include and link directories for LEMON Source: https://github.com/hjwdzh/quadriflow/blob/master/3rd/lemon-1.3.1/contrib/CMakeLists.txt Sets up include and link directories for building against LEMON. The include directories point to the project source and binary directories, while the link directory points to the LEMON build output. ```CMake INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR} ${PROJECT_BINARY_DIR} ) LINK_DIRECTORIES( ${PROJECT_BINARY_DIR}/lemon ) ``` -------------------------------- ### Conditionally add CPLEX support Source: https://github.com/hjwdzh/quadriflow/blob/master/3rd/lemon-1.3.1/lemon/CMakeLists.txt Adds cplex.cc to sources and includes ILOG headers when LEMON_HAVE_CPLEX is enabled. ```CMake IF(LEMON_HAVE_CPLEX) SET(LEMON_SOURCES ${LEMON_SOURCES} cplex.cc) INCLUDE_DIRECTORIES(${ILOG_INCLUDE_DIRS}) ENDIF() ``` -------------------------------- ### QuadriFlow executable target and linking Source: https://github.com/hjwdzh/quadriflow/blob/master/CMakeLists.txt Defines the quadriflow executable from source files and links against TBB, LEMON, and GUROBI libraries. ```CMake set( quadriflow_SRC src/adjacent-matrix.cpp src/adjacent-matrix.hpp src/compare-key.hpp src/config.hpp src/dedge.cpp src/dedge.hpp src/disajoint-tree.hpp src/dset.hpp src/field-math.hpp src/flow.hpp src/hierarchy.cpp src/hierarchy.hpp src/loader.cpp src/loader.hpp src/localsat.cpp src/localsat.hpp src/main.cpp src/merge-vertex.cpp src/merge-vertex.hpp src/optimizer.cpp src/optimizer.hpp src/parametrizer.cpp src/parametrizer-flip.cpp src/parametrizer-int.cpp src/parametrizer-mesh.cpp src/parametrizer-scale.cpp src/parametrizer-sing.cpp src/parametrizer.hpp src/serialize.hpp src/subdivide.cpp src/subdivide.hpp ) add_executable( quadriflow ${quadriflow_SRC} ) target_link_libraries( quadriflow ${TBB_LIBRARIES} ${LEMON_LIBRARIES} ${GUROBI_LIBRARIES} ) ``` -------------------------------- ### Conditionally add SoPlex support Source: https://github.com/hjwdzh/quadriflow/blob/master/3rd/lemon-1.3.1/lemon/CMakeLists.txt Adds soplex.cc to sources and includes SoPlex headers when LEMON_HAVE_SOPLEX is enabled. ```CMake IF(LEMON_HAVE_SOPLEX) SET(LEMON_SOURCES ${LEMON_SOURCES} soplex.cc) INCLUDE_DIRECTORIES(${SOPLEX_INCLUDE_DIRS}) ENDIF() ``` -------------------------------- ### Compiler flags and standards in CMake Source: https://github.com/hjwdzh/quadriflow/blob/master/CMakeLists.txt Sets C++14 standard and compiler flags. For GNU, adds -Wall, -fopenmp, and address sanitizer in debug. For MSVC, defines M_PI and disables specific warnings. ```CMake set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") set(CMAKE_CXX_FLAGS_RELEASE "-O3") # enable assert set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g") # enable assert set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS}") set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG}") if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fopenmp -Wno-int-in-bool-context -Wno-sign-compare") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address") set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS}") set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fsanitize=address") endif() if(MSVC) # Enable M_PI and disable fopen() etc. warnings ADD_DEFINITIONS(-D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS) # Disable the following warnings : C4267 and 4244 (conversions) C4018 (sign compare) and C4800 (bool to int) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3 /wd4267 /wd4244 /wd4018 /wd4800") endif() ``` -------------------------------- ### CMake build configuration for MapleCOMSPS_LRB minisat executable Source: https://github.com/hjwdzh/quadriflow/blob/master/3rd/MapleCOMSPS_LRB/CMakeLists.txt Configures a C++14 project named MapleCOMSPS_LRB that finds ZLIB, includes its headers, compiles the listed minisat source files into an executable named minisat, and links against ZLIB libraries. ```CMake cmake_minimum_required(VERSION 3.1) project(MapleCOMSPS_LRB) find_package(ZLIB) set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_INCLUDE_CURRENT_DIR ON) include_directories(${ZLIB_INCLUDE_DIRS}) set( minisat_SRC core/Solver.cc simp/Main.cc simp/SimpSolver.cc utils/Options.cc utils/System.cc ) add_executable( minisat ${minisat_SRC} ) target_link_libraries( minisat ${ZLIB_LIBRARIES} ) ``` -------------------------------- ### CMake project configuration for QuadriFlow Source: https://github.com/hjwdzh/quadriflow/blob/master/CMakeLists.txt Defines the CMake project with C++14, sets build options for performance test, logging, GUROBI, OpenMP, TBB, and free license. Finds required Eigen and Boost packages, and conditionally finds GUROBI and TBB. ```CMake cmake_minimum_required(VERSION 3.1) project(QuadriFlow LANGUAGES CXX) option(BUILD_PERFORMANCE_TEST "More subdivisition for performance test" OFF) option(BUILD_LOG "Enable verbose log" OFF) option(BUILD_GUROBI "Enable GUROBI for comparison ONLY" OFF) option(BUILD_OPENMP "Enable support for OpenMP" OFF) option(BUILD_TBB "Enable support for TBB" OFF) option(BUILD_FREE_LICENSE "Only use libraries with permissive licenses" OFF) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") set(Boost_USE_STATIC_LIBS ON) find_package(Eigen REQUIRED) find_package(Boost REQUIRED) if (BUILD_GUROBI) find_package(GUROBI REQUIRED) endif(BUILD_GUROBI) if (BUILD_TBB) find_package(TBB REQUIRED) endif(BUILD_TBB) ``` -------------------------------- ### CMake custom dist target for archiving and packaging Source: https://github.com/hjwdzh/quadriflow/blob/master/3rd/lemon-1.3.1/CMakeLists.txt Defines a CMake custom target 'dist' that creates source and documentation archives (tar.gz and zip) using Mercurial archive and CMake commands. It depends on the 'html' target and runs in the project binary directory. ```CMake SET(ARCHIVE_BASE_NAME ${CMAKE_PROJECT_NAME}) STRING(TOLOWER ${ARCHIVE_BASE_NAME} ARCHIVE_BASE_NAME) SET(ARCHIVE_NAME ${ARCHIVE_BASE_NAME}-${PROJECT_VERSION}) ADD_CUSTOM_TARGET(dist COMMAND cmake -E remove_directory ${ARCHIVE_NAME} COMMAND hg archive ${ARCHIVE_NAME} COMMAND cmake -E copy cmake/version.cmake ${ARCHIVE_NAME}/cmake/version.cmake COMMAND tar -czf ${ARCHIVE_BASE_NAME}-nodoc-${PROJECT_VERSION}.tar.gz ${ARCHIVE_NAME} COMMAND zip -r ${ARCHIVE_BASE_NAME}-nodoc-${PROJECT_VERSION}.zip ${ARCHIVE_NAME} COMMAND cmake -E copy_directory doc/html ${ARCHIVE_NAME}/doc/html COMMAND tar -czf ${ARCHIVE_NAME}.tar.gz ${ARCHIVE_NAME} COMMAND zip -r ${ARCHIVE_NAME}.zip ${ARCHIVE_NAME} COMMAND cmake -E copy_directory doc/html ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION} COMMAND tar -czf ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}.tar.gz ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION} COMMAND zip -r ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION}.zip ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION} COMMAND cmake -E remove_directory ${ARCHIVE_NAME} COMMAND cmake -E remove_directory ${ARCHIVE_BASE_NAME}-doc-${PROJECT_VERSION} DEPENDS html WORKING_DIRECTORY ${PROJECT_BINARY_DIR}) ```