Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
*.out
*.app

# Build folder
build
# Build folders
build*

# CTest folder
Testing
Expand Down
329 changes: 217 additions & 112 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,27 +1,100 @@
cmake_minimum_required(VERSION 3.11)

if(${CMAKE_VERSION} VERSION_LESS "3.12")
project(
Bliss
VERSION 0.77
LANGUAGES CXX C
DESCRIPTION "A Tool for Computing Automorphism Groups and Canonical Labelings of Graphs. http://www.tcs.hut.fi/Software/bliss/."
)
##### PROJECT DEFINITIONS #####

if(CMAKE_VERSION VERSION_LESS 3.12)
set(description "A Tool for Computing Automorphism Groups and Canonical Labelings of Graphs. http://www.tcs.hut.fi/Software/bliss/.")
set(homepage_url)
else()
project(
Bliss
VERSION 0.77
LANGUAGES CXX C
DESCRIPTION "A Tool for Computing Automorphism Groups and Canonical Labelings of Graphs"
HOMEPAGE_URL "http://www.tcs.hut.fi/Software/bliss/"
set(description "A Tool for Computing Automorphism Groups and Canonical Labelings of Graphs")
set(homepage_url HOMEPAGE_URL "http://www.tcs.hut.fi/Software/bliss/")
endif()

# Project definition.
project(
Bliss
VERSION 0.77
LANGUAGES CXX C
DESCRIPTION ${description}
${homepage_url}
)
set(BLISS_VERSION ${Bliss_VERSION})

# Set installation directories according to GNU coding standards.
include(GNUInstallDirs)

# Path to CMake modules such as FindGMP.cmake.
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")


##### OPTIONS #####

# Whether to build shared libraries.
option(BUILD_SHARED_LIBS "Whether to build shared libraries" OFF)

set(GMP AUTO CACHE STRING "should Bliss link to GNU Multiple Precision Arithmetic library")
set_property(CACHE GMP PROPERTY STRINGS AUTO ON OFF)
string(TOUPPER "${GMP}" GMP)

# Deprecated option.
set(USE_GMP UNSET CACHE STRING "Use GNU Multiple Precision Arithmetic library")
set_property(CACHE USE_GMP PROPERTY STRINGS UNSET ON OFF)
string(TOUPPER "${USE_GMP}" USE_GMP)
if((NOT USE_GMP STREQUAL "UNSET") AND (GMP STREQUAL "AUTO"))
set(GMP ${USE_GMP})
message(WARNING "USE_GMP option is deprecated. Use GMP = {AUTO, ON, OFF} instead.")
endif()

option(USE_GMP "Use GNU Multiple Precision Arithmetic library" OFF)
##### BASIC SETTINGS #####

# Shared or static lib?
if(BUILD_SHARED_LIBS)
message(STATUS "Building shared libraries.")
else()
message(STATUS "Building static libraries.")
endif()


# Set the default build type to the given value if no build type was specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Build type: Release (default)")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build" FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
else()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
endif()

set(
BLISS_SOURCE_FILES
##### DEPENDENCIES #####

# Search for GMP.
set(BLISS_USE_GMP 0)
if(GMP)
if(GMP STREQUAL "AUTO")
find_package(GMP)
else()
find_package(GMP REQUIRED)
endif()
if(GMP_FOUND)
set(BLISS_USE_GMP 1)
endif()
else()
message(STATUS "GMP is disabled.")
endif()


##### TOOLS #####

# Global compilation settings

# In MSVC, the executable and libraries should go to the top directory
if(MSVC)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}")
endif()

# Library target.
add_library(libbliss
src/abstractgraph.cc
src/bliss_C.cc
src/defs.cc
Expand All @@ -31,116 +104,148 @@ set(
src/partition.cc
src/uintseqhash.cc
src/utils.cc
)

# In MSVC, the executable and libraries should go to the top directory
if(MSVC)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})
endif(MSVC)

# Add the shared library
add_library(libbliss ${BLISS_SOURCE_FILES})

set_target_properties(libbliss PROPERTIES OUTPUT_NAME bliss )
add_library(Bliss::libbliss ALIAS libbliss)

target_include_directories(
libbliss
)
target_include_directories(libbliss
PUBLIC
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
)

"${CMAKE_CURRENT_SOURCE_DIR}/src"
)
target_link_libraries(libbliss
$<$<BOOL:${BLISS_USE_GMP}>:GMP::GMP>
)
target_compile_definitions(libbliss
PUBLIC
$<$<BOOL:${BLISS_USE_GMP}>:BLISS_USE_GMP>
)
set_target_properties(libbliss PROPERTIES
# All code ending in a shared library should be made PIC
POSITION_INDEPENDENT_CODE ON
# Compiling with hidden visibility
# We cannot do this currently, because the code does not ensure that the API is made visible / exported
#CXX_VISIBILITY_PRESET hidden
#VISIBILITY_INLINES_HIDDEN ON
# But for Windows, we can ensure that all symbols are exported, which is anyway necessary when building a DLL
WINDOWS_EXPORT_ALL_SYMBOLS 1
)

add_executable(bliss src/bliss.cc)
add_executable(Bliss::bliss ALIAS bliss)
target_link_libraries(bliss PRIVATE libbliss)
if(USE_GMP)
target_link_libraries(bliss ${GMP_LIBRARIES})
endif(USE_GMP)

set_target_properties(libbliss bliss PROPERTIES COMPILE_OPTIONS "")

# specify the C++ standard
set_target_properties(libbliss bliss
PROPERTIES CXX_STANDARD 11
CXX_STANDARD_REQUIRED True)

if (MSVC)
# /permissive- for standard C++ with "and" and "or" logical operators
target_compile_options(libbliss PUBLIC /permissive-)
target_compile_options(bliss PUBLIC /permissive-)
else()
# Warnings, optimization, no assertions
target_compile_options(libbliss PRIVATE -O3 -DNDEBUG) #-Wextra -Werror ### disable as part of scip build
target_compile_options(bliss PRIVATE -O3 -DNDEBUG) #-Wextra -Werror ### disable as part of scip build
endif()
POSITION_INDEPENDENT_CODE ON # Even static libraries should be position-independent.
WINDOWS_EXPORT_ALL_SYMBOLS 1 # All symbols are exported; necessary when building a DLL.
OUTPUT_NAME "bliss"
CXX_STANDARD 11
CXX_STANDARD_REQUIRED TRUE
)

if(USE_GMP)
find_path(GMP_INCLUDE_DIR NAMES gmp.h)
find_library(GMP_LIBRARIES NAMES gmp libgmp mpir REQUIRED)
if (MSVC)
target_compile_options(libbliss PUBLIC /DBLISS_USE_GMP /I${GMP_INCLUDE_DIR})
target_compile_options(bliss PUBLIC /DBLISS_USE_GMP /I${GMP_INCLUDE_DIR})
else()
target_compile_options(libbliss PUBLIC -DBLISS_USE_GMP -I${GMP_INCLUDE_DIR})
target_compile_options(bliss PUBLIC -DBLISS_USE_GMP -I${GMP_INCLUDE_DIR})
endif()
endif(USE_GMP)

# Set the default build type to the given value if no build type was specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to Release as none was specified")
set(
CMAKE_BUILD_TYPE Release
CACHE STRING "Choose the type of build" FORCE
# Executable target.
add_executable(bliss
src/bliss.cc
)
# Set the possible values of build type for cmake-gui, ccmake
set_property(
CACHE CMAKE_BUILD_TYPE
PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo"
target_link_libraries(bliss
PRIVATE libbliss
)
endif()


# Create main interface target.
add_library(Bliss INTERFACE)
set_target_properties(Bliss PROPERTIES
INTERFACE_LINK_LIBRARIES libbliss
)

# Add aliases to allow inclusion via add_subdirectory.
add_library(Bliss::libbliss ALIAS libbliss)
add_executable(Bliss::bliss ALIAS bliss)
add_library(Bliss::Bliss ALIAS libbliss)


##### INSTALLATION #####

# Install the header files.
install(
TARGETS libbliss bliss
EXPORT Bliss
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)

if(${CMAKE_VERSION} VERSION_LESS "3.14")
install(
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/bliss"
DESTINATION include
COMPONENT lib
FILES
include/bliss/abstractgraph.hh
include/bliss/bliss_C.h
include/bliss/digraph.hh
include/bliss/heap.hh
include/bliss/kstack.hh
include/bliss/partition.hh
include/bliss/timer.hh
include/bliss/utils.hh
include/bliss/bignum.hh
include/bliss/defs.hh
include/bliss/graph.hh
include/bliss/kqueue.hh
include/bliss/orbit.hh
include/bliss/stats.hh
include/bliss/uintseqhash.hh
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/bliss/"
)
else()
install(
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/bliss"
TYPE INCLUDE
COMPONENT lib

# Install targets, and record them in scip-targets export set.
install(TARGETS libbliss bliss Bliss
EXPORT bliss-targets
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)

# Install the debug program database files.
if(MSVC)
install(
FILES "$<TARGET_PDB_FILE:bliss>"
DESTINATION "${CMAKE_INSTALL_BINDIR}"
OPTIONAL
)
if(BUILD_SHARED_LIBS)
install(
FILES "$<TARGET_PDB_FILE:libbliss>"
DESTINATION "${CMAKE_INSTALL_BINDIR}"
OPTIONAL
)
endif()
endif()

install(EXPORT Bliss
DESTINATION lib/cmake/Bliss
# Install license files.
install(
FILES
"${PROJECT_SOURCE_DIR}/COPYING"
"${PROJECT_SOURCE_DIR}/COPYING.LESSER"
DESTINATION "${CMAKE_INSTALL_DATADIR}/licenses/bliss"
)

# Create bliss-config-version.cmake.
include(CMakePackageConfigHelpers)
write_basic_package_version_file("${CMAKE_BINARY_DIR}/bliss-config-version.cmake"
VERSION ${Bliss_VERSION_MAJOR}.${Bliss_VERSION_MINOR}.${BLISS_Version_PATCH}
COMPATIBILITY SameMinorVersion
)

# Configure bliss-config.cmake for the build-tree:
# We add the CMake module path from the sources.
set(EXTRA_CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
configure_file("${PROJECT_SOURCE_DIR}/bliss-config.cmake.in"
"${CMAKE_BINARY_DIR}/bliss-config.cmake"
@ONLY)

# Configure bliss-config.cmake for the installation.
# We add the current directory of the installed scip-config.cmake.
set(EXTRA_CMAKE_MODULE_PATH "\${CMAKE_CURRENT_LIST_DIR}")
configure_file("${PROJECT_SOURCE_DIR}/bliss-config.cmake.in"
"${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/bliss-config.cmake"
@ONLY)

# Install CMake config and modules.
install(FILES
"${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/bliss-config.cmake"
"${CMAKE_BINARY_DIR}/bliss-config-version.cmake"
$<$<BOOL:${BLISS_USE_GMP}>:${PROJECT_SOURCE_DIR}/cmake/FindGMP.cmake>
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/bliss"
)

# Install the bliss-targets export set.
install(EXPORT bliss-targets
NAMESPACE Bliss::
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/bliss"
)

# Export targets for the build-tree.
export(EXPORT bliss-targets
NAMESPACE Bliss::
FILE BlissConfig.cmake
)
FILE "${CMAKE_BINARY_DIR}/bliss-targets.cmake"
)

# If we include this directory then we mark Bliss as found.
set(BLISS_FOUND 1)

Loading