Skip to content

Commit

Permalink
Installation of library added to CMake
Browse files Browse the repository at this point in the history
  • Loading branch information
krzysg committed Jan 16, 2020
1 parent 84ec999 commit 797b2a5
Show file tree
Hide file tree
Showing 20 changed files with 91 additions and 49 deletions.
71 changes: 50 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,54 @@ option(FASP_HEURISTIC_BUILD_TESTS "Build tests?" ON)
option(FASP_HEURISTIC_BUILD_BENCHMARKS "Build benchmarks?" OFF)
option(FASP_HEURISTIC_INSTALL "Install FaspHeuristic?" OFF)

message(STATUS "FASP build type: " ${CMAKE_BUILD_TYPE})
###############################################################################
# Create FASP TightCut library
###############################################################################
set(LIB_NAMESPACE FaspTightCut)
set(LIB_NAME FaspTightCut)

add_library(${LIB_NAME} INTERFACE)
target_include_directories(${LIB_NAME} INTERFACE
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)

###############################################################################
# Install
###############################################################################
message(STATUS "FASP: Install library in [${CMAKE_INSTALL_PREFIX}]")

include(GNUInstallDirs)

# copy includes
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

# generate target target file
set(TARGET_FILE_NAME ${LIB_NAME}Targets)
install(TARGETS ${LIB_NAME} EXPORT ${TARGET_FILE_NAME} INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(EXPORT ${LIB_NAME}Targets NAMESPACE ${LIB_NAMESPACE}:: DESTINATION lib/cmake/${LIB_NAME})

# generate version config version file
include(CMakePackageConfigHelpers)
write_basic_package_version_file(${LIB_NAME}ConfigVersion.cmake
VERSION ${CMAKE_PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)

# generate config file
configure_file(cmake/${LIB_NAME}Config.cmake.in ${LIB_NAME}Config.cmake @ONLY)

install(FILES
${CMAKE_CURRENT_BINARY_DIR}/${LIB_NAME}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${LIB_NAME}ConfigVersion.cmake
DESTINATION
lib/cmake/${LIB_NAME})

#Add an alias so that library can be used inside the build tree, e.g. when testing
add_library(${LIB_NAMESPACE}::${LIB_NAME} ALIAS ${LIB_NAME})


###############################################################################
# Find all required libraries
###############################################################################
Expand Down Expand Up @@ -38,8 +86,8 @@ include_directories(src/tools)
###############################################################################
add_library(testObjLib OBJECT src/tools/easylogging++.cc)
set(FASP_BENCHMARK_LIB benchmarkLib)
add_library(${FASP_BENCHMARK_LIB} STATIC $<TARGET_OBJECTS:testObjLib>)

add_library(${FASP_BENCHMARK_LIB} STATIC $<TARGET_OBJECTS:testObjLib> )
target_link_libraries(${FASP_BENCHMARK_LIB} ${LIB_NAME})

###############################################################################
# Benchmarks
Expand All @@ -56,30 +104,11 @@ endif()
###############################################################################
if (FASP_HEURISTIC_BUILD_TESTS)
message(STATUS "FASP: Building tests")
# set(BUILD_GMOCK ON CACHE BOOL "" FORCE)
# set(BUILD_GTEST ON CACHE BOOL "" FORCE)
# set(INSTALL_GTEST OFF CACHE BOOL "" FORCE)
set(TEST_BUILD_LIBRARY ${FASP_BENCHMARK_LIB})
# add_subdirectory("libs/googletest")
# include_directories(libs/googletest/googlemock/include)
# set(GTEST_LIBRARIES gtest gmock_main)
enable_testing()
add_subdirectory(test)
endif()

###############################################################################
# Install
###############################################################################
add_library(FASP_LIB INTERFACE)
target_include_directories(FASP_LIB INTERFACE
"${PROJECT_SOURCE_DIR}/src/"
)
set(INSTALL_INCLUDE_DIR include CACHE PATH "Installation directory for header files")
set(INSTALL_INCLUDE_PROJECT_DIR ${INSTALL_INCLUDE_DIR}/FASP_LIB CACHE PATH "Installation directory for header files")

message(STATUS "APR: Install library in [${CMAKE_INSTALL_PREFIX}]")

install(DIRECTORY ${INC_DIRS} DESTINATION ${INSTALL_INCLUDE_PROJECT_DIR} COMPONENT DEV FILES_MATCHING PATTERN "*.hpp" PATTERN "*.h")

#message(STATUS "---------------------- VARS BEG ---------------------")
#get_cmake_property(_variableNames VARIABLES)
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# FASP heuristic
## TIGHT-CUT FASP heuristic


### How to clone code

### How to compile

### How to use in your project

### Simple example

File renamed without changes.
2 changes: 0 additions & 2 deletions src/graph/graph.h → include/FaspTightCut/graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
#ifndef GRAPH_H
#define GRAPH_H

#include "tools/prettyprint.h"
#include "tools/tools.h"
#include <vector>
#include <set>
#include <map>
Expand Down
File renamed without changes.
19 changes: 13 additions & 6 deletions src/graph/graphFasp.h → include/FaspTightCut/graphFasp.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@
#define GRAPHFASP_H


#include "graph/graph.h"
#include "graph/graphExt.h"
#include "graph/graphFaspTools.h"
#include "graph.h"
#include "graphExt.h"
#include "hipr/hi_pr.h"
#include "tools/dynamicBitset.h"
#include "tools/stack.h"
#include "tools/tools.h"
#include <future>
#include <cstddef>
#include <vector>
#include "graph/hipr/hi_pr.h"
#include <unordered_map>
#include <unordered_set>
#include <random>


namespace Graph::Fasp {

Expand Down Expand Up @@ -280,6 +282,11 @@ namespace Graph::Fasp {
return result;
}

auto randInt(int min, int max) {
static std::mt19937 mt(std::random_device{}());
return std::uniform_int_distribution<>(min, max)(mt);
}

/**
* Generates subgraph of input graph (modifies it) by removing wanted number of edges with cycles.
* There will be one cycle left in a input graph (if there was at least one cycle in input graph).
Expand All @@ -306,7 +313,7 @@ namespace Graph::Fasp {
if (edgesRemovedCnt > 0) aGraph.addEdge(lastRemovedRndEdge);
return;
} else {
lastRemovedRndEdge = edgesWithCycles[::Tools::randInt(0, n - 1)];
lastRemovedRndEdge = edgesWithCycles[randInt(0, n - 1)];
aGraph.removeEdge(lastRemovedRndEdge);
++edgesRemovedCnt;
}
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/graph/hipr/hi_pr.h → include/FaspTightCut/hipr/hi_pr.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "graph/graph.h"
#include "graph/graphExt.h"
#include "../graph.h"
#include "../graphExt.h"

namespace Graph {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <bitset>
#include <memory>
#include <cstring>

#include <utility>

template <typename ELEMENT_TYPE = uint8_t, typename IDX=uint32_t>
class DynamicBitset {
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/benchmarks/benchGraphsFromPaper1/benchGraphsFromPaper1.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
#include "prettyprint.h"
#include "tools/easylogging++.h"
#include "hdf5/dataHdf5.h"
#include "graph/graph.h"
#include "../../../include/FaspTightCut/graph.h"
#include "graph/graphFaspTools.h"
#include "graph/graphFasp.h"
#include "../../../include/FaspTightCut/graphFasp.h"
#include "graph/graphIO.h"
#include <regex>

Expand Down
4 changes: 2 additions & 2 deletions src/benchmarks/benchHeuristics/benchHeuristics.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
#include "prettyprint.h"
#include "tools/easylogging++.h"
#include "hdf5/dataHdf5.h"
#include "graph/graph.h"
#include "../../../include/FaspTightCut/graph.h"
#include "graph/graphFaspTools.h"
#include "graph/graphFasp.h"
#include "../../../include/FaspTightCut/graphFasp.h"
#include "graph/graphIO.h"
#include <sstream>

Expand Down
4 changes: 2 additions & 2 deletions src/benchmarks/benchIsoCut/benchIsoCut.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
#include "prettyprint.h"
#include "tools/easylogging++.h"
#include "hdf5/dataHdf5.h"
#include "graph/graph.h"
#include "../../../include/FaspTightCut/graph.h"
#include "graph/graphFaspTools.h"
#include "graph/graphFasp.h"
#include "../../../include/FaspTightCut/graphFasp.h"
#include <string>


Expand Down
4 changes: 2 additions & 2 deletions src/graph/graphFaspTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#define GRAPHFASPTOOLS_H


#include "graph.h"
#include "graphExt.h"
#include "FaspTightCut/graph.h"
#include "FaspTightCut/graphExt.h"
#include "tools/tools.h"
#include "tools/prettyprint.h"
#include "tools/timer.h"
Expand Down
4 changes: 2 additions & 2 deletions src/graph/graphIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#define GRAPHIO_H


#include "graph.h"
#include "graphExt.h"
#include "../../include/FaspTightCut/graph.h"
#include "../../include/FaspTightCut/graphExt.h"
#include <dirent.h>

namespace Graph::IO {
Expand Down
2 changes: 1 addition & 1 deletion test/TestDynamicBitset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Created by gonciarz on 2019-04-02.
//

#include "tools/dynamicBitset.h"
#include "FaspTightCut/tools/dynamicBitset.h"

#include "gtest/gtest.h"

Expand Down
2 changes: 1 addition & 1 deletion test/TestGraph.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "graph/graph.h"
#include "../include/FaspTightCut/graph.h"
#include "graph/graphFaspTools.h"

#include "gtest/gtest.h"
Expand Down
4 changes: 2 additions & 2 deletions test/TestGraphFasp.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "graph/graphFasp.h"
#include "graph/graph.h"
#include "../include/FaspTightCut/graphFasp.h"
#include "../include/FaspTightCut/graph.h"

#include <gtest/gtest.h>
#include <gmock/gmock.h>
Expand Down
2 changes: 1 addition & 1 deletion test/TestGraphIO.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "graph/graph.h"
#include "../include/FaspTightCut/graph.h"
#include "graph/graphIO.h"

#include "gtest/gtest.h"
Expand Down
2 changes: 1 addition & 1 deletion test/TestStack.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "tools/stack.h"
#include "FaspTightCut/tools/stack.h"

#include "gtest/gtest.h"

Expand Down

0 comments on commit 797b2a5

Please sign in to comment.