-
Notifications
You must be signed in to change notification settings - Fork 12
/
CMakeLists.txt
73 lines (57 loc) · 2.22 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
cmake_minimum_required(VERSION 3.0)
project(PowerTools)
# The version number.
set (PowerTools_VERSION_MAJOR 1)
set (PowerTools_VERSION_MINOR 0)
# Find Gurobi (optional).
option(ENABLE_GUROBI "Link to Gurobi libraries" OFF)
# Find BONMIN (optional).
option(ENABLE_BONMIN "Link to BONMIN libraries" OFF)
# configure a header file to pass some of the CMake settings
# to the source code.
configure_file (
"${PROJECT_SOURCE_DIR}/PowerToolsConfig.h.in"
"${PROJECT_BINARY_DIR}/include/PowerTools++/PowerToolsConfig.h")
# add the binary tree to the search path for include files
# so that we will find PowerToolsConfig.h.
include_directories("${PROJECT_BINARY_DIR}/include")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)
# Find Ipopt.
find_package(IPOPT REQUIRED)
include_directories(${IPOPT_INCLUDE_DIRS}/..)
set(LIBS ${LIBS} ${IPOPT_LIBRARIES})
# Find Gurobi?
if (ENABLE_GUROBI)
message(STATUS "Enable GUROBI")
add_definitions(-DUSE_GUROBI)
find_package(GUROBI)
include_directories(${GUROBI_INCLUDE_DIRS}/..)
set(LIBS ${LIBS} ${GUROBI_LIBRARIES})
endif()
# Find BONMIN.
if (ENABLE_BONMIN)
message(STATUS "Enable BONMIN")
add_definitions(-DUSE_BONMIN)
find_package(BONMIN)
include_directories(${BONMIN_INCLUDE_DIRS}/..)
set(LIBS ${LIBS} ${BONMIN_LIBRARIES})
endif()
# Compiler options
# specify the cross compiler
set(CMAKE_C_COMPILER_ID GNU)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -g")
#set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -ggdb")
#string (REPLACE "-Wmost" "" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Ofast")
set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--export-all-symbols")
# Build options
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
set(PROJECT_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include)
set(CMAKE_BUILD_TYPE "Release")
#set(CMAKE_BUILD_TYPE "Debug")
add_subdirectory(src)
# Install
install(DIRECTORY include/PowerTools++ DESTINATION include)
install(FILES ${PROJECT_BINARY_DIR}/include/PowerTools++/PowerToolsConfig.h DESTINATION include/PowerTools++)