Skip to content

Commit

Permalink
update with packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
ErDumont committed Jun 16, 2020
1 parent 607be71 commit 7eb0119
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 69 deletions.
15 changes: 15 additions & 0 deletions cmake/Findsirius_solver.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
set(sirius_solver_FOUND FALSE)

if(NOT sirius_solver_ROOT)
set(sirius_solver_ROOT $ENV{sirius_solver_ROOT})
endif()
message(STATUS "sirius_solver_ROOT: ${sirius_solver_ROOT}")
if(NOT sirius_solver_ROOT)
message(FATAL_ERROR "sirius_solver_ROOT: not found")
else()
set(CMAKE_MODULE_PATH_BACKUP ${CMAKE_MODULE_PATH})
set(CMAKE_MODULE_PATH "")
set(sirius_solver_DIR "${sirius_solver_ROOT}/cmake")
find_package(sirius_solver REQUIRED)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH_BACKUP})
endif()
119 changes: 50 additions & 69 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(PNE)
CMAKE_MINIMUM_REQUIRED(VERSION 3.12)
PROJECT(sirius_solver)

if(MSVC)
add_compile_definitions("_CRT_SECURE_NO_WARNINGS")
set(BUILD_SHARED_LIBS OFF)
SET(BUILD_SHARED_LIBS OFF)
SET(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
SET(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1)
endif(MSVC)

SET(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
SET(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1)
MESSAGE("CMAKE_BINARY_DIR : ${CMAKE_BINARY_DIR}")
MESSAGE("CMAKE_SOURCE_DIR : ${CMAKE_SOURCE_DIR}")

Expand All @@ -20,28 +20,13 @@ INCLUDE_DIRECTORIES(. ALLOCATEUR BRANCH_AND_BOUND POINT_INTERIEUR PRESOLVE SIMPL

FILE(GLOB HEADERS ALLOCATEUR/*.h PRESOLVE/*.h BRANCH_AND_BOUND/*.h POINT_INTERIEUR/*.h SIMPLEXE/*.h SIMPLEXE/LU/*.h ./PNE/*.h ./SRS/*.h)

MESSAGE("-- ALLOCATEUR")
FILE(GLOB ALLOCATEUR_FILES ALLOCATEUR/*.c ALLOCATEUR/*.h)

MESSAGE("-- PRESOLVE")
FILE(GLOB PRESOLVE_FILES PRESOLVE/*.c PRESOLVE/*.h)

MESSAGE("-- BRANCH_AND_BOUND")
FILE(GLOB BRANCH_AND_BOUND_FILES BRANCH_AND_BOUND/*.c BRANCH_AND_BOUND/*.h)

MESSAGE("-- POINT_INTERIEUR")
FILE(GLOB POINT_INTERIEUR_FILES POINT_INTERIEUR/*.c POINT_INTERIEUR/*.h)

MESSAGE("-- SIMPLEXE")
FILE(GLOB SIMPLEXE_FILES SIMPLEXE/*.c SIMPLEXE/*.h)

MESSAGE("-- LU")
FILE(GLOB LU_FILES SIMPLEXE/LU/*.c SIMPLEXE/LU/*.h)

MESSAGE("-- PNE")
FILE(GLOB PNE_FILES PNE/*.c PNE/*.h)

MESSAGE("-- SRS")
FILE(GLOB SRS_FILES SRS/*.c SRS/*.h)

GET_FILENAME_COMPONENT(FULL_PATH_TEST_CPP ${CMAKE_CURRENT_SOURCE_DIR}/PNE/pne_standalone.c ABSOLUTE)
Expand All @@ -50,58 +35,54 @@ MESSAGE("REMOVING FROM SOURCE ${FULL_PATH_TEST_CPP}")
LIST(REMOVE_ITEM PNE_FILES ${FULL_PATH_TEST_CPP})
# MESSAGE("-- PNE_FILES : ${PNE_FILES}")

ADD_LIBRARY(bib_solveur_static STATIC ${ALLOCATEUR_FILES} ${PRESOLVE_FILES} ${BRANCH_AND_BOUND_FILES} ${POINT_INTERIEUR_FILES} ${SIMPLEXE_FILES} ${LU_FILES} ${PNE_FILES} ${SRS_FILES})
ADD_LIBRARY(bib_solveur SHARED ${ALLOCATEUR_FILES} ${PRESOLVE_FILES} ${BRANCH_AND_BOUND_FILES} ${POINT_INTERIEUR_FILES} ${SIMPLEXE_FILES} ${LU_FILES} ${PNE_FILES} ${SRS_FILES})
ADD_EXECUTABLE(PNE_STANDALONE PNE/pne_standalone.c )
ADD_EXECUTABLE(NEWSPX_STANDALONE SPX_STANDALONE/spx_standalone.c )
ADD_EXECUTABLE(TEST_API TEST_API/main.c )

#SET_SOURCE_FILES_PROPERTIES(pne_standalone.c ${ALLOCATEUR_FILES} ${PRESOLVE_FILES} ${BRANCH_AND_BOUND_FILES} ${POINT_INTERIEUR_FILES} ${SIMPLEXE_FILES} ${LU_FILES} ${PNE_FILES} PROPERTIES LANGUAGE CXX)

ADD_LIBRARY(sirius_solver_static STATIC ${ALLOCATEUR_FILES} ${PRESOLVE_FILES} ${BRANCH_AND_BOUND_FILES} ${POINT_INTERIEUR_FILES} ${SIMPLEXE_FILES} ${LU_FILES} ${PNE_FILES} ${SRS_FILES})
ADD_LIBRARY(sirius_solver SHARED ${ALLOCATEUR_FILES} ${PRESOLVE_FILES} ${BRANCH_AND_BOUND_FILES} ${POINT_INTERIEUR_FILES} ${SIMPLEXE_FILES} ${LU_FILES} ${PNE_FILES} ${SRS_FILES})
#ADD_EXECUTABLE(PNE_STANDALONE PNE/pne_standalone.c )
#ADD_EXECUTABLE(NEWSPX_STANDALONE SPX_STANDALONE/spx_standalone.c )
#ADD_EXECUTABLE(TEST_API TEST_API/main.c )

FILE(GLOB LIB_PNE_FILES LIBRAIRIE_PNE/*.c)
FILE(GLOB LIB_PNE_HEADERS LIBRAIRIE_PNE/*.h)

MESSAGE("-- LIB_PNE_FILES : ${LIB_PNE_FILES}")
MESSAGE("-- LIB_PNE_HEADERS : ${LIB_PNE_HEADERS}")
MESSAGE("-- COINDIRINC : $ENV{COINDIRINC}")
MESSAGE("-- COINDIRLIB : $ENV{COINDIRLIB}")

INCLUDE_DIRECTORIES($ENV{COINDIRINC} $ENV{XPRESSDIR}/include)

SET(COMPILE_PNE_LIBRARY OFF)
IF(COMPILE_PNE_LIBRARY)
ADD_LIBRARY(PNE_LIBRARY SHARED ${LIB_PNE_FILES} ${LIB_PNE_HEADERS})
#TARGET_COMPILE_DEFINITIONS(PNE_LIBRARY PUBLIC COIN_EXTERN_C)
#TARGET_COMPILE_DEFINITIONS(PNE_LIBRARY PUBLIC CLP_EXTERN_C)
TARGET_COMPILE_DEFINITIONS(PNE_LIBRARY PUBLIC SHARED_EXPORTS)
ENDIF(COMPILE_PNE_LIBRARY)

IF(WIN32)
TARGET_LINK_LIBRARIES(PNE_STANDALONE bib_solveur_static)
TARGET_LINK_LIBRARIES(NEWSPX_STANDALONE bib_solveur_static)
TARGET_LINK_LIBRARIES(TEST_API bib_solveur_static)
IF(COMPILE_PNE_LIBRARY)
TARGET_LINK_LIBRARIES(PNE_LIBRARY bib_solveur_static $ENV{XPRESSDIR}/lib/xprs.lib $ENV{COINDIRLIB}/CoinUtils.lib $ENV{COINDIRLIB}/Clp.lib C:/ProgramData/Anaconda2/Library/lib/zlib.lib C:/ProgramData/Anaconda2/Library/lib/bzip2.lib)
ENDIF(COMPILE_PNE_LIBRARY)
ELSE()
TARGET_LINK_LIBRARIES(PNE_STANDALONE bib_solveur_static m)
TARGET_LINK_LIBRARIES(NEWSPX_STANDALONE bib_solveur_static m)
TARGET_LINK_LIBRARIES(TEST_API bib_solveur_static m)
IF(COMPILE_PNE_LIBRARY)
TARGET_LINK_LIBRARIES(PNE_LIBRARY bib_solveur_static $ENV{XPRESSDIR}/lib/xprs.lib m)
ENDIF(COMPILE_PNE_LIBRARY)
ENDIF(WIN32)

set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install")
INSTALL(FILES ${HEADERS} DESTINATION "${CMAKE_BINARY_DIR}/install/includes")
IF (MSVC)
INSTALL(TARGETS bib_solveur RUNTIME DESTINATION "${CMAKE_BINARY_DIR}/install/lib/Release" CONFIGURATIONS Release)
INSTALL(TARGETS bib_solveur ARCHIVE DESTINATION "${CMAKE_BINARY_DIR}/install/lib/Release" CONFIGURATIONS Release)
INSTALL(TARGETS bib_solveur RUNTIME DESTINATION "${CMAKE_BINARY_DIR}/install/lib/Debug" CONFIGURATIONS Debug)
INSTALL(TARGETS bib_solveur ARCHIVE DESTINATION "${CMAKE_BINARY_DIR}/install/lib/Debug" CONFIGURATIONS Debug)
# TARGET_LINK_LIBRARIES(TEST_API sirius_solver_static)
ELSE()
INSTALL(TARGETS bib_solveur DESTINATION "${CMAKE_BINARY_DIR}/install/lib/")
ENDIF()

#INSTALL(TARGETS bib_solveur PUBLIC_HEADER DESTINATION "${CMAKE_BINARY_DIR}/install/includes")
TARGET_LINK_LIBRARIES(sirius_solver m)
TARGET_LINK_LIBRARIES(sirius_solver_static m)
# TARGET_LINK_LIBRARIES(TEST_API sirius_solver_static)
ENDIF(WIN32)

SET_TARGET_PROPERTIES(sirius_solver_static PROPERTIES PUBLIC_HEADER "${HEADERS}")
SET_TARGET_PROPERTIES(sirius_solver PROPERTIES PUBLIC_HEADER "${HEADERS}")
target_include_directories(sirius_solver PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/SRS/>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/LU/>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/PNE/>)

IF (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
SET(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install")
ENDIF (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)

MESSAGE("CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}")

INSTALL(TARGETS sirius_solver
EXPORT sirius_solver
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES DESTINATION include
)

INSTALL(EXPORT sirius_solver
FILE sirius_solverConfig.cmake
DESTINATION cmake
)

SET(CPACK_PACKAGE_NAME "sirius_solver")
SET(CPACK_PACKAGE_VERSION_MAJOR "1")
SET(CPACK_PACKAGE_VERSION_MINOR "0")
SET(CPACK_PACKAGE_VERSION_PATCH "0")

SET(CPACK_GENERATOR "ZIP")

INCLUDE(CPack)

0 comments on commit 7eb0119

Please sign in to comment.