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

CMake + MSVC fixes #37

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
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
80 changes: 67 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,20 @@ endif()
##############################################################################
# HDF5
##############################################################################
find_package(HDF5 1.8.0)
include_directories(${HDF5_INCLUDE_DIR})

# http://t3hmikez0r.com/2014/07/11/cmake-and-hdf5-revisited/
# back up any user-defined HDF5_DIR setting
set(_SAVED_HDF5_DIR ${HDF5_DIR})
# First look for hdf5-config.cmake in defined locations.
# This file is generated by HDF5 team and is likely more up to date than FindHDF5.cmake included in CMake.
FIND_PACKAGE(HDF5 1.8.0 NO_MODULE)
IF(NOT HDF5_FOUND)
# didn't find hdf5-config.cmake. Need to fall back on CMake's built-in FindHDF5.cmake logic.
# required says we fail if it isn't found.
# Restore the value reset by the previous call to 'find_package(HDF5 NO_MODULE)'
set(HDF5_DIR ${_SAVED_HDF5_DIR} CACHE PATH "HDF5 install dir" FORCE)
FIND_PACKAGE(HDF5 1.8.0)
ENDIF()

##############################################################################
# Gurobi
Expand Down Expand Up @@ -120,10 +132,14 @@ if(COMPILER_SUPPORTS_CXX0X OR COMPILER_SUPPORTS_CXX11)
add_test(test-graph-multicut-greedy-additive test-graph-multicut-greedy-additive)

if(HDF5_FOUND)
include_directories(PUBLIC ${HDF5_INCLUDE_DIRS})
add_executable(test-hdf5 src/andres/graph/unit-test/hdf5.cxx ${headers})
target_link_libraries(test-hdf5 ${HDF5_LIBRARIES})
add_test(test-hdf5 test-hdf5)
if(TARGET hdf5-shared)
target_link_libraries(test-hdf5 hdf5-shared)
else()
target_link_libraries(test-hdf5 ${HDF5_LIBRARIES})
target_include_directories(test-hdf5 PRIVATE ${HDF5_INCLUDE_DIRS})
add_test(test-hdf5 test-hdf5)
endif()
endif()
endif(COMPILER_SUPPORTS_CXX0X OR COMPILER_SUPPORTS_CXX11)

Expand Down Expand Up @@ -157,23 +173,61 @@ if((COMPILER_SUPPORTS_CXX0X OR COMPILER_SUPPORTS_CXX11) AND HDF5_FOUND)
add_test(test-probabilistic-lifting test-probabilistic-lifting)

add_executable(lift-mp src/command-line-tools/lift-mp.cxx ${headers})
target_link_libraries(lift-mp ${HDF5_LIBRARIES})
if(TARGET hdf5-shared)
target_link_libraries(lift-mp hdf5-shared)
else()
target_link_libraries(lift-mp ${HDF5_LIBRARIES})
target_include_directories(lift-mp PRIVATE ${HDF5_INCLUDE_DIRS})
endif()

add_executable(lift-mp-grid-graph src/command-line-tools/lift-mp-grid-graph.cxx ${headers})
target_link_libraries(lift-mp-grid-graph ${HDF5_LIBRARIES})
if(TARGET hdf5-shared)
target_link_libraries(lift-mp-grid-graph hdf5-shared)
else()
target_link_libraries(lift-mp-grid-graph ${HDF5_LIBRARIES})
target_include_directories(lift-mp-grid-graph PRIVATE ${HDF5_INCLUDE_DIRS})
endif()

add_executable(solve-mp src/command-line-tools/solve-mp.cxx ${headers})
target_link_libraries(solve-mp ${HDF5_LIBRARIES} ${GUROBI_LIBRARIES})
if(TARGET hdf5-shared)
target_link_libraries(solve-mp hdf5-shared ${GUROBI_LIBRARIES})
else()
target_link_libraries(solve-mp ${HDF5_LIBRARIES} ${GUROBI_LIBRARIES})
target_include_directories(solve-mp PRIVATE ${HDF5_INCLUDE_DIRS})
endif()

add_executable(solve-mp-complete-graph src/command-line-tools/solve-mp-complete-graph.cxx ${headers})
target_link_libraries(solve-mp-complete-graph ${HDF5_LIBRARIES} ${GUROBI_LIBRARIES})
if(TARGET hdf5-shared)
target_link_libraries(solve-mp-complete-graph hdf5-shared ${GUROBI_LIBRARIES})
else()
target_link_libraries(solve-mp-complete-graph ${HDF5_LIBRARIES} ${GUROBI_LIBRARIES})
target_include_directories(solve-mp-complete-graph PRIVATE ${HDF5_INCLUDE_DIRS})
endif()

add_executable(solve-mp-grid-graph src/command-line-tools/solve-mp-grid-graph.cxx ${headers})
target_link_libraries(solve-mp-grid-graph ${HDF5_LIBRARIES} ${GUROBI_LIBRARIES})
if(TARGET hdf5-shared)
target_link_libraries(solve-mp-grid-graph hdf5-shared ${GUROBI_LIBRARIES})
else()
target_link_libraries(solve-mp-grid-graph ${HDF5_LIBRARIES} ${GUROBI_LIBRARIES})
target_include_directories(solve-mp-grid-graph PRIVATE ${HDF5_INCLUDE_DIRS})
endif()

add_executable(solve-lmp src/command-line-tools/solve-lmp.cxx ${headers})
target_link_libraries(solve-lmp ${HDF5_LIBRARIES} ${GUROBI_LIBRARIES})
if(TARGET hdf5-shared)
target_link_libraries(solve-lmp hdf5-shared ${GUROBI_LIBRARIES})
else()
target_link_libraries(solve-lmp ${HDF5_LIBRARIES} ${GUROBI_LIBRARIES})
target_include_directories(solve-lmp PRIVATE ${HDF5_INCLUDE_DIRS})
endif()

add_executable(solve-lmp-grid-graph src/command-line-tools/solve-lmp-grid-graph.cxx ${headers})
target_link_libraries(solve-lmp-grid-graph ${HDF5_LIBRARIES} ${GUROBI_LIBRARIES})
endif()
if(TARGET hdf5-shared)
target_link_libraries(solve-lmp-grid-graph hdf5-shared ${GUROBI_LIBRARIES})
else()
target_link_libraries(solve-lmp-grid-graph ${HDF5_LIBRARIES} ${GUROBI_LIBRARIES})
target_include_directories(solve-lmp-grid-graph PRIVATE ${HDF5_INCLUDE_DIRS})
endif()
endif()

# Install the headers.
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/andres" DESTINATION include)
2 changes: 1 addition & 1 deletion include/andres/graph/lifting.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ lift(
{
if (metric == LiftingMetric::PathLength)
{
const std::size_t distance = std::abs(x - cv[0]) + std::abs(y - cv[1]);
const std::size_t distance = std::abs(static_cast<long>(x - cv[0])) + std::abs(static_cast<long>(y - cv[1]));

if (distance > distanceLowerBound)
{
Expand Down
8 changes: 4 additions & 4 deletions src/andres/graph/unit-test/graph-grid.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class IteratorTest {

static_assert(std::is_same<pointer,value_type*>::value,"Iterator pointer type mismatch.");
static_assert(std::is_same<reference,value_type&>::value,"Iterator pointer type mismatch.");

void operator()(iterator begin,iterator end) {
difference_type d = std::distance(begin,end);
assert(d>0);
Expand All @@ -223,7 +223,7 @@ void testIteratorCompile(G& g, size_t pivot) {
typedef typename GridGraph::AdjacencyIterator AdjacencyIterator ;
typedef typename GridGraph::VertexIterator VertexIterator;
typedef typename GridGraph::EdgeIterator EdgeIterator;

{
VertexIterator begin = g.verticesFromVertexBegin(pivot);
VertexIterator end = g.verticesFromVertexEnd(pivot);
Expand Down Expand Up @@ -509,9 +509,9 @@ void testConstructionAndNumbers() {
// Simple examples
{
GridGraphType gridGraph({6,5});
VertexCoordinate originCoordinate({{0,0}});
VertexCoordinate originCoordinate{{0,0}};
size_t originIndex(0);
VertexCoordinate tenthCoordinate({{3,1}});
VertexCoordinate tenthCoordinate{{3,1}};
size_t tenthIndex(9);
test(originIndex == gridGraph.vertex(originCoordinate));
test(tenthIndex == gridGraph.vertex(tenthCoordinate));
Expand Down
2 changes: 1 addition & 1 deletion src/command-line-tools/fast-marching.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ fastMarching(
typedef typename InputGraph::AdjacencyType Adjacency;
typedef typename InputGraph::EdgeCoordinate EdgeCoordinate;
typedef typename std::iterator_traits<TARGET_EDGE_VALUE_ITERATOR>::value_type Value;
typedef typename detail::my_make_signed<Value>::type signedValue;
typedef typename ::detail::my_make_signed<Value>::type signedValue;
if(interpolationOrder > 1) {
throw std::runtime_error("specified interpolation order not implemented.");
}
Expand Down