-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathCMakeLists.txt
51 lines (43 loc) · 1.73 KB
/
CMakeLists.txt
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
cmake_minimum_required(VERSION 3.3...3.19)
project(
VPSolver
VERSION 3.0
LANGUAGES CXX)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR})
set(CMAKE_CXX_STANDARD 11)
# Visual Studio compiler with static runtime libraries
if(MSVC AND MT)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /MT")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /MTd")
endif()
add_library(vpsolver-lib OBJECT
src/instance.cpp src/instance.hpp
src/graph.cpp src/graph.hpp
src/arcflow.cpp src/arcflow.hpp
src/arcflowsol.cpp src/arcflowsol.hpp
src/common.cpp src/common.hpp)
# VPSolver executable
find_package(GUROBI)
if(GUROBI_CXX_LIBRARY AND GUROBI_LIBRARY AND GUROBI_INCLUDE_DIRS)
add_executable(vpsolver src/vpsolver.cpp $<TARGET_OBJECTS:vpsolver-lib>)
target_include_directories(vpsolver PRIVATE ${GUROBI_INCLUDE_DIRS})
target_link_libraries(vpsolver ${GUROBI_CXX_LIBRARY} ${GUROBI_LIBRARY})
install(TARGETS vpsolver DESTINATION bin)
endif()
# Auxiliary executables
add_executable(vbp2afg src/vbp2afg.cpp $<TARGET_OBJECTS:vpsolver-lib>)
add_executable(afg2ampl src/afg2ampl.cpp $<TARGET_OBJECTS:vpsolver-lib>)
add_executable(afg2mps src/afg2mps.cpp $<TARGET_OBJECTS:vpsolver-lib>)
add_executable(afg2lp src/afg2lp.cpp $<TARGET_OBJECTS:vpsolver-lib>)
add_executable(vbpsol src/vbpsol.cpp $<TARGET_OBJECTS:vpsolver-lib>)
install(TARGETS vbp2afg afg2mps afg2lp vbpsol DESTINATION bin)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/scripts/ DESTINATION scripts)
# CPack
set(CPACK_GENERATOR ZIP)
set(CPACK_PACKAGE_FILE_NAME vpsolver)
include(CPack)
# CTest
include(CTest)
enable_testing()