Skip to content

Commit

Permalink
add cmake files
Browse files Browse the repository at this point in the history
  • Loading branch information
limbo018 committed Jul 24, 2019
1 parent 5f354fb commit a9f697a
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 0 deletions.
42 changes: 42 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
cmake_minimum_required(VERSION 3.8.2)

project(OpenMPL)

set(CMAKE_INSTALL_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}" CACHE PATH "Prefix prepended to install directories")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
"Choose the type of build, options are: Debug Release."
FORCE)
endif(NOT CMAKE_BUILD_TYPE)
message("-- CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")

if(NOT CMAKE_CXX_ABI)
set(CMAKE_CXX_ABI 0 CACHE STRING
"Choose the value for _GLIBCXX_USE_CXX11_ABI, options are: 0|1."
FORCE)
endif(NOT CMAKE_CXX_ABI)
message("-- CMAKE_CXX_ABI: _GLIBCXX_USE_CXX11_ABI=${CMAKE_CXX_ABI}")
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=${CMAKE_CXX_ABI})

#option(ENABLE_GUROBI "whether enable Gurobi" OFF)
#message("-- GUROBI: ${ENABLE_GUROBI}")
#option(ENABLE_LEMONCBC "whether enable Lemon-CBC" OFF)
#message("-- LEMONCBC: ${ENABLE_LEMONCBC}")
#option(ENABLE_CSDP "whether enable CSDP" OFF)
#message("-- CSDP: ${ENABLE_CSDP}")

set(CMAKE_CXX_STANDARD 11)

set(LIMBO_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/Limbo)
message("-- LIMBO_SOURCE_DIR ${LIMBO_SOURCE_DIR}")
set(LIMBO_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/thirdparty/Limbo)
message("-- LIMBO_BINARY_DIR ${LIMBO_BINARY_DIR}")

find_package(ZLIB REQUIRED)
find_package(Boost 1.55.0 REQUIRED COMPONENTS iostreams chrono timer unit_test_framework graph regex)
find_package(Gurobi)

add_subdirectory(thirdparty)
add_subdirectory(src)
52 changes: 52 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

if(CMAKE_BUILD_TYPE STREQUAL "DEBUG")
set(COMPILE_DEFINITIONS -DDEBUG_SDPCOLORING -DDEBUG_ILPCOLORING -DDEBUG_LPCOLORING)
else()
set(COMPILE_DEFINITIONS "")
endif()

set(LIBS programoptions gdsdb gdsparser ${Boost_LIBRARIES} ${ZLIB_LIBRARIES})
if(UNIX AND NOT APPLE)
set(LIBS ${LIBS} rt)
endif(UNIX AND NOT APPLE)

if(GUROBI_FOUND)
include_directories(
${GUROBI_INCLUDE_DIRS}
)
set(LIBS ${GUROBI_LIBRARIES} ${LIBS})
set(COMPILE_DEFINITIONS "GUROBI=1" ${COMPILE_DEFINITIONS})
else(GUROBI_FOUND)
set(COMPILE_DEFINITIONS GUROBI=0 ${COMPILE_DEFINITIONS})
endif(GUROBI_FOUND)
#if(ENABLE_LEMONCBC)
# set(COMPILE_DEFINITIONS LEMONCBC=1 ${COMPILE_DEFINITIONS})
#else(ENABLE_LEMONCBC)
# set(COMPILE_DEFINITIONS LEMONCBC=0 ${COMPILE_DEFINITIONS})
#endif(ENABLE_LEMONCBC)
set(COMPILE_DEFINITIONS CSDP=1 ${COMPILE_DEFINITIONS})
set(LIBS ${LIBS} sdp openblas m ${CMAKE_THREAD_LIBS_INIT} gfortran)

file(GLOB SOURCES
DL_MPL.cpp
DL_struct.cpp
Enums.cpp
GdsiiIO.cpp
LayoutDB.cpp
LayoutDBPolygon.cpp
LayoutDBRect.cpp
Msg.cpp
Params.cpp
RecoverHiddenVertex.cpp
SimpleMPL.cpp
)

include_directories(${LIMBO_SOURCE_DIR} ${Boost_INCLUDE_DIRS})
add_library(${PROJECT_NAME}_lib STATIC ${SOURCES})
add_executable(${PROJECT_NAME} main.cpp)
target_link_libraries(${PROJECT_NAME} LINK_PUBLIC ${PROJECT_NAME}_lib ${LIBS})
if(COMPILE_DEFINITIONS)
target_compile_definitions(${PROJECT_NAME} PRIVATE ${COMPILE_DEFINITIONS})
endif(COMPILE_DEFINITIONS)
install(TARGETS ${PROJECT_NAME} DESTINATION bin)

0 comments on commit a9f697a

Please sign in to comment.