1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650
|
#-------------------------------------------------------------------------------
# SuiteSparse/Mongoose/CMakeLists.txt: building SuiteSparse_Mongoose with cmake
#-------------------------------------------------------------------------------
#
# SuiteSparse_Mongoose, Copyright (c) 2018-2023, All Rights Reserved.
# Nuri Yeralan, Microsoft Research
# Scott Kolodziej, Texas A&M University
# Tim Davis, Texas A&M University
# William Hager, University of Florida.
#
# SPDX-License-Identifier: GPL-3.0-only
#
# http://suitesparse.com See Mongoose/Doc/License.txt for license.
#
# To compile the SuiteSparse_Mongoose library and demo programs just do "make"
# in this directory. The Mongoose/Makefile will then run cmake
# in the build directory.
#
# To install SuiteSparse_Mongoose in /usr/local/lib and /usr/local/include,
# and also in ../lib, ../include, and ../bin:
#
# sudo make install
#
# To install only in ../lib and ../include (no sudo required):
#
# make local ; make install
#
# To remove all compiled files and libraries (except installed ones):
#
# make distclean
#-------------------------------------------------------------------------------
# get the version
#-------------------------------------------------------------------------------
cmake_minimum_required ( VERSION 3.22 )
set ( Mongoose_DATE "July 25, 2025" )
set ( Mongoose_NUMERIC_DATE "2025-07-25" )
set ( Mongoose_VERSION_MAJOR 3 CACHE STRING "" FORCE )
set ( Mongoose_VERSION_MINOR 3 CACHE STRING "" FORCE )
set ( Mongoose_VERSION_PATCH 5 CACHE STRING "" FORCE )
message ( STATUS "Building Mongoose version: v"
${Mongoose_VERSION_MAJOR}.
${Mongoose_VERSION_MINOR}.
${Mongoose_VERSION_PATCH} " (" ${Mongoose_DATE} ")" )
#-------------------------------------------------------------------------------
# define the project
#-------------------------------------------------------------------------------
project ( Mongoose
VERSION "${Mongoose_VERSION_MAJOR}.${Mongoose_VERSION_MINOR}.${Mongoose_VERSION_PATCH}"
LANGUAGES CXX C )
#-------------------------------------------------------------------------------
# SuiteSparse policies
#-------------------------------------------------------------------------------
set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
${PROJECT_SOURCE_DIR}/cmake_modules
${PROJECT_SOURCE_DIR}/../SuiteSparse_config/cmake_modules )
include ( SuiteSparsePolicy )
#-------------------------------------------------------------------------------
# find library dependencies
#-------------------------------------------------------------------------------
if ( NOT SUITESPARSE_ROOT_CMAKELISTS )
find_package ( SuiteSparse_config 7.11.0
PATHS ${CMAKE_SOURCE_DIR}/../SuiteSparse_config/build NO_DEFAULT_PATH )
if ( NOT TARGET SuiteSparse::SuiteSparseConfig )
find_package ( SuiteSparse_config 7.11.0 REQUIRED )
endif ( )
endif ( )
# For ctests
find_package ( Python COMPONENTS Interpreter )
#-------------------------------------------------------------------------------
# Mongoose installation location
include ( GNUInstallDirs )
# Configure files to pass CMake information
configure_file (
"Version/Mongoose.hpp.in"
"${PROJECT_SOURCE_DIR}/Include/Mongoose.hpp"
NEWLINE_STYLE LF
)
configure_file (
"Version/title-info.tex.in"
"${PROJECT_SOURCE_DIR}/Doc/title-info.tex"
NEWLINE_STYLE LF
)
configure_file (
"Version/codemeta.json.in"
"${PROJECT_SOURCE_DIR}/codemeta.json"
NEWLINE_STYLE LF
)
include_directories("${PROJECT_BINARY_DIR}")
set(MONGOOSE_FILES
Include/Mongoose_BoundaryHeap.hpp
Include/Mongoose_Coarsening.hpp
Include/Mongoose_CSparse.hpp
Include/Mongoose_CutCost.hpp
Include/Mongoose_Debug.hpp
Include/Mongoose_EdgeCutOptions.hpp
Include/Mongoose_EdgeCutProblem.hpp
Include/Mongoose_EdgeCut.hpp
Include/Mongoose_Graph.hpp
Include/Mongoose_GuessCut.hpp
Include/Mongoose_ImproveFM.hpp
Include/Mongoose_ImproveQP.hpp
Include/Mongoose_Internal.hpp
Include/Mongoose_IO.hpp
Include/Mongoose_Logger.hpp
Include/Mongoose_Matching.hpp
Include/Mongoose_Random.hpp
Include/Mongoose_Refinement.hpp
Include/Mongoose_Sanitize.hpp
Include/Mongoose_Waterdance.hpp
Source/Mongoose_BoundaryHeap.cpp
Source/Mongoose_Coarsening.cpp
Source/Mongoose_CSparse.cpp
Source/Mongoose_Debug.cpp
Source/Mongoose_EdgeCut.cpp
Source/Mongoose_Graph.cpp
Source/Mongoose_GuessCut.cpp
Source/Mongoose_ImproveFM.cpp
Source/Mongoose_ImproveQP.cpp
Source/Mongoose_IO.cpp
Source/Mongoose_Logger.cpp
Source/Mongoose_Matching.cpp
Source/Mongoose_EdgeCutOptions.cpp
Source/Mongoose_EdgeCutProblem.cpp
Source/Mongoose_EdgeCut.cpp
Source/Mongoose_Random.cpp
Source/Mongoose_Refinement.cpp
Source/Mongoose_Sanitize.cpp
Source/Mongoose_Version.cpp
Source/Mongoose_Waterdance.cpp
)
set(NAPHEAP_FILES
Include/Mongoose_QPBoundary.hpp
Include/Mongoose_QPDelta.hpp
Include/Mongoose_QPGradProj.hpp
Include/Mongoose_QPLinks.hpp
Include/Mongoose_QPMaxHeap.hpp
Include/Mongoose_QPMinHeap.hpp
Include/Mongoose_QPNapDown.hpp
Include/Mongoose_QPNapsack.hpp
Include/Mongoose_QPNapUp.hpp
Source/Mongoose_QPBoundary.cpp
Source/Mongoose_QPDelta.cpp
Source/Mongoose_QPGradProj.cpp
Source/Mongoose_QPLinks.cpp
Source/Mongoose_QPMaxHeap.cpp
Source/Mongoose_QPMinHeap.cpp
Source/Mongoose_QPNapDown.cpp
Source/Mongoose_QPNapsack.cpp
Source/Mongoose_QPNapUp.cpp
)
set(MMIO_FILES
External/mmio/Source/mmio.c
External/mmio/Include/mmio.h)
set(MONGOOSE_LIB_FILES
${MONGOOSE_FILES}
${NAPHEAP_FILES}
${MMIO_FILES})
set(EXE_FILES
Executable/mongoose.cpp)
set(DEMO_FILES
Demo/demo.cpp
Include/Mongoose.hpp)
# Specify the Include directory for *.hpp files
include_directories(Include
External/mmio/Include
)
# Require C++11
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# set the output directories
# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
# set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
# set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
if ( BUILD_STATIC_LIBS )
# Build the Mongoose library
add_library ( Mongoose_static STATIC ${MONGOOSE_LIB_FILES} )
set_target_properties ( Mongoose_static PROPERTIES
OUTPUT_NAME suitesparse_mongoose
PUBLIC_HEADER "Include/Mongoose.hpp" )
if ( MSVC OR ("${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC") )
set_target_properties ( Mongoose_static PROPERTIES
OUTPUT_NAME suitesparse_mongoose_static )
endif ( )
if ( ${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.25" )
set_target_properties ( Mongoose_static PROPERTIES EXPORT_NO_SYSTEM ON )
endif ( )
target_include_directories ( Mongoose_static
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Include>
$<INSTALL_INTERFACE:${SUITESPARSE_INCLUDEDIR}> )
if ( TARGET SuiteSparse::SuiteSparseConfig_static )
target_link_libraries ( Mongoose_static PUBLIC SuiteSparse::SuiteSparseConfig_static )
else ( )
target_link_libraries ( Mongoose_static PUBLIC SuiteSparse::SuiteSparseConfig )
endif ( )
target_compile_definitions ( Mongoose_static PUBLIC MONGOOSE_STATIC )
endif ( )
if ( BUILD_SHARED_LIBS )
# Build the Mongoose library for dynamic linking
add_library ( Mongoose SHARED ${MONGOOSE_LIB_FILES} )
set_target_properties ( Mongoose PROPERTIES
OUTPUT_NAME suitesparse_mongoose
SOVERSION ${Mongoose_VERSION_MAJOR}
PUBLIC_HEADER "Include/Mongoose.hpp"
WINDOWS_EXPORT_ALL_SYMBOLS ON
POSITION_INDEPENDENT_CODE ON )
if ( ${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.25" )
set_target_properties ( Mongoose PROPERTIES EXPORT_NO_SYSTEM ON )
endif ( )
target_include_directories ( Mongoose
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Include>
$<INSTALL_INTERFACE:${SUITESPARSE_INCLUDEDIR}> )
target_link_libraries ( Mongoose PRIVATE SuiteSparse::SuiteSparseConfig )
target_include_directories ( Mongoose PUBLIC
"$<TARGET_PROPERTY:SuiteSparse::SuiteSparseConfig,INTERFACE_INCLUDE_DIRECTORIES>" )
target_include_directories ( Mongoose PRIVATE . )
target_compile_definitions ( Mongoose PRIVATE MONGOOSE_BUILDING )
endif ( )
#-------------------------------------------------------------------------------
# Build the Mongoose executable
add_executable ( mongoose_exe ${EXE_FILES} )
set_target_properties ( mongoose_exe PROPERTIES
OUTPUT_NAME suitesparse_mongoose )
if ( BUILD_SHARED_LIBS )
target_link_libraries ( mongoose_exe PRIVATE Mongoose )
else ( )
target_link_libraries ( mongoose_exe PRIVATE Mongoose_static )
endif ( )
target_link_libraries ( mongoose_exe PRIVATE SuiteSparse::SuiteSparseConfig )
# Build the Demo executable
add_executable ( demo_exe ${DEMO_FILES} )
set_target_properties ( demo_exe PROPERTIES
OUTPUT_NAME demo )
if ( BUILD_SHARED_LIBS )
target_link_libraries ( demo_exe Mongoose )
else ( )
target_link_libraries ( demo_exe Mongoose_static )
endif ( )
target_link_libraries ( demo_exe SuiteSparse::SuiteSparseConfig )
# Coverage and Unit Testing Setup
include ( CTest )
if ( BUILD_TESTING )
set ( TESTING_OUTPUT_PATH ${PROJECT_BINARY_DIR}/tests )
if ( FALSE )
# I/O Tests
add_executable ( mongoose_test_io
Tests/Mongoose_Test_IO.cpp
Tests/Mongoose_Test_IO_exe.cpp )
if ( BUILD_SHARED_LIBS )
target_link_libraries ( mongoose_test_io PRIVATE Mongoose )
else ( )
target_link_libraries ( mongoose_test_io PRIVATE Mongoose_static )
endif ( )
target_link_libraries ( mongoose_test_io PRIVATE SuiteSparse::SuiteSparseConfig )
set_target_properties ( mongoose_test_io PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${TESTING_OUTPUT_PATH} )
add_test ( NAME Mongoose_IO_Test
COMMAND ${Python_EXECUTABLE} ${PROJECT_SOURCE_DIR}/Tests/runTests -min 1 -max 15 -t io -k )
# Edge Separator Tests
add_executable ( mongoose_test_edgesep
Tests/Mongoose_Test_EdgeSeparator.cpp
Tests/Mongoose_Test_EdgeSeparator_exe.cpp)
if ( BUILD_SHARED_LIBS )
target_link_libraries ( mongoose_test_edgesep PRIVATE Mongoose )
else ( )
target_link_libraries ( mongoose_test_edgesep PRIVATE Mongoose_static )
endif ( )
target_link_libraries ( mongoose_test_edgesep PRIVATE SuiteSparse::SuiteSparseConfig )
set_target_properties ( mongoose_test_edgesep PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${TESTING_OUTPUT_PATH} )
add_test ( NAME Mongoose_Edge_Separator_Test
COMMAND ${Python_EXECUTABLE} ${PROJECT_SOURCE_DIR}/Tests/runTests -min 1 -max 15 -t edgesep )
add_test ( NAME Mongoose_Edge_Separator_Test_2
COMMAND ${Python_EXECUTABLE} ${PROJECT_SOURCE_DIR}/Tests/runTests -t edgesep -i 21 39 191 1557 1562 353 2468 1470 1380 505 182 201 2331 760 1389 2401 2420 242 250 1530 1533 360 1437 )
add_test ( NAME Mongoose_Weighted_Edge_Separator_Test
COMMAND ${Python_EXECUTABLE} ${PROJECT_SOURCE_DIR}/Tests/runTests -t edgesep -i 2624 )
add_test ( NAME Mongoose_Target_Split_Test
COMMAND ${Python_EXECUTABLE} ${PROJECT_SOURCE_DIR}/Tests/runTests -min 1 -max 15 -t edgesep -s 0.3 )
# Memory Tests
add_executable ( mongoose_test_memory
Tests/Mongoose_Test_Memory.cpp
Tests/Mongoose_Test_Memory_exe.cpp)
if ( BUILD_SHARED_LIBS )
target_link_libraries ( mongoose_test_memory PRIVATE Mongoose )
else ( )
target_link_libraries ( mongoose_test_memory PRIVATE Mongoose_static )
endif ( )
target_link_libraries ( mongoose_test_memory PRIVATE SuiteSparse::SuiteSparseConfig )
set_target_properties ( mongoose_test_memory PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${TESTING_OUTPUT_PATH} )
add_test ( NAME Mongoose_Memory_Test
COMMAND ${Python_EXECUTABLE} ${PROJECT_SOURCE_DIR}/Tests/runTests -min 1 -max 15 -t memory )
# Performance Test
add_executable ( mongoose_test_performance
Tests/Mongoose_Test_Performance.cpp
Tests/Mongoose_Test_Performance_exe.cpp )
if ( BUILD_SHARED_LIBS )
target_link_libraries ( mongoose_test_performance PRIVATE Mongoose )
else ( )
target_link_libraries ( mongoose_test_performance PRIVATE Mongoose_static )
endif ( )
target_link_libraries ( mongoose_test_performance PRIVATE SuiteSparse::SuiteSparseConfig )
set_target_properties ( mongoose_test_performance PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${TESTING_OUTPUT_PATH} )
add_test ( NAME Mongoose_Performance_Test
COMMAND ${Python_EXECUTABLE} ${PROJECT_SOURCE_DIR}/Tests/runTests -min 1 -max 15 -t performance -p )
add_test ( NAME Mongoose_Performance_Test_2
COMMAND ${Python_EXECUTABLE} ${PROJECT_SOURCE_DIR}/Tests/runTests -t performance -i 21 39 1557 1562 353 2468 1470 1380 505 182 201 2331 760 1389 2401 2420 242 250 1530 1533 -p )
if ( WIN32 AND BUILD_SHARED_LIBS )
set_tests_properties ( Mongoose_IO_Test
Mongoose_Edge_Separator_Test Mongoose_Edge_Separator_Test_2 Mongoose_Weighted_Edge_Separator_Test Mongoose_Target_Split_Test
Mongoose_Memory_Test
Mongoose_Performance_Test Mongoose_Performance_Test_2
PROPERTIES
ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$<TARGET_FILE_DIR:Mongoose>;PATH=path_list_prepend:$<TARGET_FILE_DIR:SuiteSparse::SuiteSparseConfig>" )
endif ( )
endif ( )
# Reference Test
add_executable ( mongoose_test_reference
Tests/Mongoose_Test_Reference.cpp
Tests/Mongoose_Test_Reference_exe.cpp )
if ( BUILD_SHARED_LIBS )
target_link_libraries ( mongoose_test_reference PRIVATE Mongoose )
else ( )
target_link_libraries ( mongoose_test_reference PRIVATE Mongoose_static )
endif ( )
target_link_libraries ( mongoose_test_reference PRIVATE SuiteSparse::SuiteSparseConfig )
set_target_properties ( mongoose_test_reference PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${TESTING_OUTPUT_PATH} )
# Fixme: Is there a test that is using this executable?
# Unit Tests
add_executable ( mongoose_unit_test_io
Tests/Mongoose_UnitTest_IO_exe.cpp )
if ( BUILD_SHARED_LIBS )
target_link_libraries ( mongoose_unit_test_io PRIVATE Mongoose )
else ( )
target_link_libraries ( mongoose_unit_test_io PRIVATE Mongoose_static )
endif ( )
target_link_libraries ( mongoose_unit_test_io PRIVATE SuiteSparse::SuiteSparseConfig )
set_target_properties ( mongoose_unit_test_io PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${TESTING_OUTPUT_PATH} )
add_test ( NAME Mongoose_Unit_Test_IO
COMMAND ${TESTING_OUTPUT_PATH}/mongoose_unit_test_io
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/Tests )
add_executable ( mongoose_unit_test_graph
Tests/Mongoose_UnitTest_Graph_exe.cpp )
if ( BUILD_SHARED_LIBS )
target_link_libraries ( mongoose_unit_test_graph PRIVATE Mongoose )
else ( )
target_link_libraries ( mongoose_unit_test_graph PRIVATE Mongoose_static )
endif ( )
target_link_libraries ( mongoose_unit_test_graph PRIVATE SuiteSparse::SuiteSparseConfig )
set_target_properties ( mongoose_unit_test_graph PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${TESTING_OUTPUT_PATH} )
add_executable ( mongoose_unit_test_edgesep
Tests/Mongoose_UnitTest_EdgeSep_exe.cpp )
if ( BUILD_SHARED_LIBS )
target_link_libraries ( mongoose_unit_test_edgesep PRIVATE Mongoose )
else ( )
target_link_libraries ( mongoose_unit_test_edgesep PRIVATE Mongoose_static )
endif ( )
target_link_libraries ( mongoose_unit_test_edgesep PRIVATE SuiteSparse::SuiteSparseConfig )
set_target_properties ( mongoose_unit_test_edgesep PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${TESTING_OUTPUT_PATH} )
add_test ( NAME Mongoose_Unit_Test_EdgeSep
COMMAND ${TESTING_OUTPUT_PATH}/mongoose_unit_test_edgesep
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/Tests )
if ( WIN32 AND BUILD_SHARED_LIBS )
set_tests_properties ( Mongoose_Unit_Test_IO Mongoose_Unit_Test_EdgeSep PROPERTIES
ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$<TARGET_FILE_DIR:Mongoose>;PATH=path_list_prepend:$<TARGET_FILE_DIR:SuiteSparse::SuiteSparseConfig>" )
endif ( )
if ( $ENV{MONGOOSE_COVERAGE} )
set ( COV ON )
else ( )
set ( COV OFF )
endif ( )
option ( MONGOOSE_COVERAGE "OFF: do not compile debug library with test coverage. ON: debug with test coverage" ${COV} )
message ( STATUS "test coverage for debug library: ${MONGOOSE_COVERAGE}" )
message(STATUS "CMAKE_CXX_COMPILER: " ${BoldBlue} ${CMAKE_CXX_COMPILER_ID} ${ColourReset})
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
# using Clang
# SET(CMAKE_CXX_FLAGS "-O3 -fwrapv")
# Debug flags for Clang
# SET(CMAKE_CXX_FLAGS_DEBUG "-g -fwrapv")
# SET(CMAKE_C_FLAGS_DEBUG "-g")
# SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "-g")
if ( MONGOOSE_COVERAGE )
SET ( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} --coverage" )
SET ( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} --coverage" )
SET ( CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} --coverage" )
endif ( )
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# using GCC
# SET(CMAKE_CXX_FLAGS "-O3 -fwrapv")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-but-set-variable -Wno-unused-variable" )
# Debug flags for GCC
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.6")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
message(WARNING "${BoldRed} WARNING:${ColourReset} Your compiler does not support the C++11 ISO standard. Future versions of Mongoose will require a compiler with C++11 support. We recommend you upgrade to at least GCC 4.6.")
endif ()
# SET(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall -fwrapv -W -Wshadow -Wunused-parameter -Wunused-function -Wunused -Wno-system-headers -Wno-deprecated -Woverloaded-virtual -Wwrite-strings ")
# SET(CMAKE_C_FLAGS_DEBUG "-g -O0 -Wall -fwrapv -W ")
# SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall -W ")
# SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "")
if ( MONGOOSE_COVERAGE )
SET (CMAKE_CXX_FLAGS_DEBUG " ${CMAKE_CXX_FLAGS_DEBUG} -Wall -W -Wshadow -Wunused-parameter -Wunused-function -Wunused -Wno-system-headers -Wno-deprecated -Woverloaded-virtual -Wwrite-strings ")
SET ( CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage" )
SET ( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage" )
SET ( CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage" )
endif ( )
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
# using Intel C++
# SET(CMAKE_CXX_FLAGS "-O3 -no-prec-div -xHOST -ipo -fwrapv")
# Debug flags for Intel
# SET(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -Wall -fwrapv")
# SET(CMAKE_C_FLAGS_DEBUG "-g -O0 -Wall")
#elseif ( MSVC )
# using Visual Studio C++
endif ()
if ( MONGOOSE_COVERAGE )
if ( BUILD_SHARED_LIBS )
set_target_properties ( Mongoose PROPERTIES
COMPILE_FLAGS "${CMAKE_CXX_FLAGS_DEBUG}"
LINK_FLAGS "${CMAKE_EXE_LINKER_FLAGS_DEBUG}" )
else ( )
set_target_properties ( Mongoose_static PROPERTIES
COMPILE_FLAGS "${CMAKE_CXX_FLAGS_DEBUG}"
LINK_FLAGS "${CMAKE_EXE_LINKER_FLAGS_DEBUG}" )
endif ( )
# Add debug compile/linker flags
if ( FALSE )
set_target_properties ( mongoose_test_io mongoose_test_memory
mongoose_test_edgesep PROPERTIES
COMPILE_FLAGS "${CMAKE_CXX_FLAGS_DEBUG}"
LINK_FLAGS "${CMAKE_EXE_LINKER_FLAGS_DEBUG}" )
endif ( )
set_target_properties ( mongoose_unit_test_io mongoose_unit_test_graph
mongoose_unit_test_edgesep PROPERTIES
COMPILE_FLAGS "${CMAKE_CXX_FLAGS_DEBUG}"
LINK_FLAGS "${CMAKE_EXE_LINKER_FLAGS_DEBUG}" )
set ( CMAKE_CXX_OUTPUT_EXTENSION_REPLACE 1 ) # Necessary for gcov - prevents file.cpp.gcda instead of file.gcda
endif ( )
# if ( BUILD_STATIC_LIBS )
# add_custom_command ( TARGET Mongoose_static
# POST_BUILD
# COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:Mongoose_static> ${PROJECT_SOURCE_DIR}/Lib
# COMMENT "Copying libmongoose (static) to root Lib directory"
# )
# endif ( )
# add_custom_command ( TARGET Mongoose
# POST_BUILD
# COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:Mongoose> ${PROJECT_SOURCE_DIR}/Lib
# COMMENT "Copying libmongoose (dynamic) to root Lib directory"
# )
endif ( )
#add_custom_target ( purge
# COMMAND rm -rf ${PROJECT_BINARY_DIR}/*
## COMMAND rm -f ${PROJECT_SOURCE_DIR}/Lib/libmongoose.*
# COMMAND rm -f ${PROJECT_SOURCE_DIR}/Doc/title-info.tex
# COMMAND rm -f ${PROJECT_SOURCE_DIR}/Doc/title-info.tex.aux
# COMMAND rm -f ${PROJECT_SOURCE_DIR}/Doc/Mongoose_UserGuide.idx
# COMMAND rm -f ${PROJECT_SOURCE_DIR}/Doc/Mongoose_UserGuide.log
# COMMAND rm -f ${PROJECT_SOURCE_DIR}/Doc/Mongoose_UserGuide.out
# COMMAND rm -f ${PROJECT_SOURCE_DIR}/Doc/Mongoose_UserGuide.aux
# COMMAND rm -f ${PROJECT_SOURCE_DIR}/Doc/Mongoose_UserGuide.toc
# COMMAND rm -f ${PROJECT_SOURCE_DIR}/Doc/Mongoose_UserGuide.bbl
# COMMAND rm -f ${PROJECT_SOURCE_DIR}/Doc/Mongoose_UserGuide.blg
# COMMAND rm -f ${PROJECT_SOURCE_DIR}/Matrix/*.tar.gz
# COMMAND rm -f ${PROJECT_SOURCE_DIR}/Matrix/*.csv
# WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
# )
add_custom_target(userguide
COMMAND make
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/Doc
)
#-------------------------------------------------------------------------------
# Mongoose installation location
#-------------------------------------------------------------------------------
include ( CMakePackageConfigHelpers )
if ( BUILD_SHARED_LIBS )
install ( TARGETS Mongoose
EXPORT SuiteSparse_MongooseTargets
LIBRARY DESTINATION ${SUITESPARSE_LIBDIR}
ARCHIVE DESTINATION ${SUITESPARSE_LIBDIR}
RUNTIME DESTINATION ${SUITESPARSE_BINDIR}
PUBLIC_HEADER DESTINATION ${SUITESPARSE_INCLUDEDIR} )
# create (temporary) export target file during build
export ( EXPORT SuiteSparse_MongooseTargets
NAMESPACE SuiteSparse::
FILE ${CMAKE_CURRENT_BINARY_DIR}/SuiteSparse_MongooseTargets.cmake )
# install export target, config and version files for find_package
install ( EXPORT SuiteSparse_MongooseTargets
NAMESPACE SuiteSparse::
DESTINATION ${SUITESPARSE_PKGFILEDIR}/cmake/SuiteSparse_Mongoose )
endif ( )
if ( BUILD_STATIC_LIBS )
install ( TARGETS Mongoose_static
EXPORT SuiteSparse_MongooseTargets_static
ARCHIVE DESTINATION ${SUITESPARSE_LIBDIR}
PUBLIC_HEADER DESTINATION ${SUITESPARSE_INCLUDEDIR} )
# create (temporary) export target file during build
export ( EXPORT SuiteSparse_MongooseTargets_static
NAMESPACE SuiteSparse::
FILE ${CMAKE_CURRENT_BINARY_DIR}/SuiteSparse_MongooseTargets_static.cmake )
# install export target, config and version files for find_package
install ( EXPORT SuiteSparse_MongooseTargets_static
NAMESPACE SuiteSparse::
DESTINATION ${SUITESPARSE_PKGFILEDIR}/cmake/SuiteSparse_Mongoose )
endif ( )
install ( TARGETS mongoose_exe
RUNTIME DESTINATION ${SUITESPARSE_BINDIR} )
# generate config file to be used in common build tree
set ( SUITESPARSE_IN_BUILD_TREE ON )
configure_package_config_file (
Config/SuiteSparse_MongooseConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/SuiteSparse_MongooseConfig.cmake
INSTALL_DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/SuiteSparse_MongooseConfig.cmake )
# generate config file to be installed
set ( SUITESPARSE_IN_BUILD_TREE OFF )
configure_package_config_file (
Config/SuiteSparse_MongooseConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/target/SuiteSparse_MongooseConfig.cmake
INSTALL_DESTINATION ${SUITESPARSE_PKGFILEDIR}/cmake/SuiteSparse_Mongoose )
write_basic_package_version_file (
${CMAKE_CURRENT_BINARY_DIR}/SuiteSparse_MongooseConfigVersion.cmake
COMPATIBILITY SameMajorVersion )
install ( FILES
${CMAKE_CURRENT_BINARY_DIR}/target/SuiteSparse_MongooseConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/SuiteSparse_MongooseConfigVersion.cmake
DESTINATION ${SUITESPARSE_PKGFILEDIR}/cmake/SuiteSparse_Mongoose )
#-------------------------------------------------------------------------------
# create pkg-config file
#-------------------------------------------------------------------------------
if ( NOT MSVC )
set ( prefix "${CMAKE_INSTALL_PREFIX}" )
set ( exec_prefix "\${prefix}" )
cmake_path ( IS_ABSOLUTE SUITESPARSE_LIBDIR SUITESPARSE_LIBDIR_IS_ABSOLUTE )
if (SUITESPARSE_LIBDIR_IS_ABSOLUTE)
set ( libdir "${SUITESPARSE_LIBDIR}")
else ( )
set ( libdir "\${exec_prefix}/${SUITESPARSE_LIBDIR}")
endif ( )
cmake_path ( IS_ABSOLUTE SUITESPARSE_INCLUDEDIR SUITESPARSE_INCLUDEDIR_IS_ABSOLUTE )
if (SUITESPARSE_INCLUDEDIR_IS_ABSOLUTE)
set ( includedir "${SUITESPARSE_INCLUDEDIR}")
else ( )
set ( includedir "\${prefix}/${SUITESPARSE_INCLUDEDIR}")
endif ( )
if ( BUILD_SHARED_LIBS )
set ( SUITESPARSE_LIB_BASE_NAME $<TARGET_FILE_BASE_NAME:Mongoose> )
else ( )
set ( SUITESPARSE_LIB_BASE_NAME $<TARGET_FILE_BASE_NAME:Mongoose_static> )
endif ( )
configure_file (
Config/SuiteSparse_Mongoose.pc.in
SuiteSparse_Mongoose.pc.out
@ONLY
NEWLINE_STYLE LF )
file ( GENERATE
OUTPUT SuiteSparse_Mongoose.pc
INPUT ${CMAKE_CURRENT_BINARY_DIR}/SuiteSparse_Mongoose.pc.out
NEWLINE_STYLE LF )
install ( FILES
${CMAKE_CURRENT_BINARY_DIR}/SuiteSparse_Mongoose.pc
DESTINATION ${SUITESPARSE_PKGFILEDIR}/pkgconfig )
endif ( )
#-------------------------------------------------------------------------------
# report status
#-------------------------------------------------------------------------------
include ( SuiteSparseReport )
|