-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathCMakeLists.txt
executable file
·62 lines (51 loc) · 1.98 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
## You can just modify your project name, in line 5.
cmake_minimum_required(VERSION 2.8)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
set(MY_PROJECT_NAME Demo)
project(${MY_PROJECT_NAME})
######## Cplex Dependency
find_package(CPLEX REQUIRED)
if(CPLEX_FOUND)
include_directories(${CPLEX_INCLUDE_DIR})
link_directories(${CPLEX_LIBRARY})
endif()
if(CPLEX_CONCERT_FOUND)
include_directories(${CPLEX_CONCERT_INCLUDE_DIR})
link_directories(${CPLEX_CONCERT_LIBRARY})
endif()
if(CPLEX_ILOCPLEX_FOUND)
include_directories(${CPLEX_ILOCPLEX_INCLUDE_DIR})
link_directories(${CPLEX_ILOCPLEX_LIBRARY})
endif()
if(CPLEX_CP_FOUND)
include_directories(${CPLEX_CP_INCLUDE_DIR})
link_directories(${CPLEX_CP_LIBRARY})
endif()
######## Complier message
set(CMAKE_BUILD_TYPE Release)
message(STATUS "System: ${CMAKE_SYSTEM}")
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
message(STATUS "Compiler version: ${CMAKE_CXX_COMPILER_VERSION}")
######## Set output directories.
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build//bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build/lib)
######## Set C++ 11 standard
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-std=c++11" COMPILER_SUPPORTS_CXX11)
if (COMPILER_SUPPORTS_CXX11)
if (CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
else ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif ()
else ()
message(STATUS "Fatal Error: Your compiler doesn't support c++11, please install it!")
endif ()
######## find all the source files.
file(GLOB HEADER_FILES include/*.h)
file(GLOB SOURCE_FILES src/*.cpp)
######## Set executable file name, and add the source files for it.
add_executable(${MY_PROJECT_NAME} ${HEADER_FILES} ${SOURCE_FILES})
######## Add Dependency Library
target_link_libraries(${MY_PROJECT_NAME} cplex-library cplex-concert ilocplex cplex-cp)